#include<bits/stdc++.h>usingnamespace std;typedeflonglong ll;typedef pair<ll, ll>PII;constint N =2e6+10;constint MOD =998244353;constint INF =0X3F3F3F3F;int n, m;intmain(){cin >> n;int cnt =0;for(int i =0; i <= n; i ++){if((i ^(2* i)^(3* i))==0) cnt ++;}cout << cnt << endl;return0;}
B:模拟,转置得性质a[i][j] = a[j][i], 模拟一些即可
#include<iostream>usingnamespace std;intmain(){int m,n;int a[501][501];int i,j;cin>>m>>n;//输入矩阵列数、行数for(i=1;i<=m;i++)//输入矩阵for(j=1;j<=n;j++)cin>>a[i][j];cout << n <<" "<< m << endl;for(i=1;i<=n;i++)//输出转至后的矩阵{for(j=1;j<=m;j++)cout<<a[j][i]<<" ";cout<<endl;}return0;}
C:二分枚举这个最大得距离,然后for循环遍历这些隔间之间得距离差,最后枚举出来即可:
#include<iostream>#include<algorithm>usingnamespace std;constint N =1e5+10;typedeflonglong ll;int n, c;int a[N];boolcheck(int x){int cnt =1, mins = a[1];for(int i =2; i <= n; i ++){if(a[i]- mins >= x){cnt ++;mins = a[i];}}if(cnt >= c)returntrue;//说明安排的距离小elsereturnfalse;// 说明安排的距离大}intmain(){cin >> n >> c;for(int i =1; i <= n; i ++){cin >> a[i];}//二分前都需要排序sort(a +1, a +1+ n);int l =0, r = a[n]- a[1]+1;while(l +1!= r){int mid = l + r >>1;if(check(mid)) l = mid;else r = mid;}cout << l << endl;return0;}
#include<bits/stdc++.h>usingnamespace std;typedeflonglong ll;typedef pair<int,int>PII;const ll N =3e5+5,M =3e5;const ll mod =1e9+7;
ll n , a, b, ni[N];
ll kmi(ll a, ll b){ll res =1;while(b){if(b &1){res = res * a % mod;}a = a * a % mod;b >>=1;}return res;}
ll C(ll n , ll m){ll ans =1;for(int i =1;i <= m;i ++){ans = ans *(n - m + i)% mod * ni[i]%mod;}return ans;}intmain(){cin >> n >> a >> b;for(int i =1;i <= M;i ++)ni[i]=kmi(i,mod -2);ll ans =(kmi(2, n)-C(n ,a)-C(n, b)-1+3* mod)%mod;printf("%lld",ans);return0;}
Start SSM from stratch !!! 数据库两个数据库可以共存吗?常见的关系数据库常见的非关系数据库数据库可视化管理工具 java版本reviewee and se?jdk1.7 or jdk7? mysql安装版本对应关系下载[MySQL](https://downloads.mysql.com/archives/installer/)下载[Connecto…
添加层级(Adding Layers) 引言1. Training Data2. Dense Layer Class 引言
我们构建的神经网络变得越来越受人尊敬,但目前我们只有一层。当神经网络具有两层或更多隐藏层时,它们变成了“深度”网络。目前我们只有一层,…
博彦科技笔试: 给定字符,拼接成单词进行反转单词;
package org.example;public class Main {public static void main(String[] args) {char[] input {h, e, l, l, o, , w, o, r, l, d, , J, a, v, a};String inputToString new String(…