放假了,cf记录一下吧
A:
#include<bits/stdc++.h>
using namespace std;
#define pii pair<int,int>
#define ll long long
#define mp make_pair
#define pb push_back
#define mt(a,val) memset(a,val,sizeof(a))
const int mod = 998244353;
const int inf = 0x3f3f3f3f;
const ll INF = 0x3f3f3f3f3f3f3f3f;
const double pi = 3.14159265;
const int maxn = 3e5 + 7;
int t;
ll n;
int main()
{
scanf("%D", &t);
while(t --)
{
scanf("%lld", &n);
int flag = 0;
while(n > 1)
{
if(n & 1)
{
flag = 1;
break;
}
else
n /= 2;
}
if(flag)
printf("YES\n");
else
printf("NO\n");
}
}
/*
*/
B:
#include<bits/stdc++.h>
using namespace std;
#define pii pair<int,int>
#define ll long long
#define mp make_pair
#define pb push_back
#define mt(a,val) memset(a,val,sizeof(a))
const int mod = 998244353;
const int inf = 0x3f3f3f3f;
const ll INF = 0x3f3f3f3f3f3f3f3f;
const double pi = 3.14159265;
const int maxn = 3e5 + 7;
int t, n;
int main()
{
scanf("%d", &t);
while(t --)
{
scanf("%d", &n);
int cnt = n / 2020;
n = n - cnt * 2020;
if(n <= cnt)
printf("YES\n");
else
printf("NO\n");
}
}
/*
*/
C:
#include<bits/stdc++.h>
using namespace std;
#define pii pair<int,int>
#define ll long long
#define mp make_pair
#define pb push_back
#define mt(a,val) memset(a,val,sizeof(a))
const int mod = 998244353;
const int inf = 0x3f3f3f3f;
const ll INF = 0x3f3f3f3f3f3f3f3f;
const double pi = 3.14159265;
const int maxn = 3e5 + 7;
int t, a, b, k;
vector<int> na[maxn];
vector<int> nb[maxn];
int x[maxn], y[maxn];
int main()
{
scanf("%d", &t);
while(t --)
{
ll ans = 0;
scanf("%d%d%d", &a, &b, &k);
for(int i = 0; i <= max(a, b); i ++)
na[i].clear(),nb[i].clear();
for(int i = 0; i < k; i ++)
{
scanf("%d", &x[i]);
}
for(int i = 0; i < k; i ++)
{
scanf("%d", &y[i]);
}
for(int i = 0; i < k; i ++)
{
na[x[i]].pb(y[i]);
nb[y[i]].pb(x[i]);
}
for(int i = 0; i <= a; i ++)
{
for(int j = 0; j < na[i].size(); j ++)
{
ans += max(0, int(k - nb[na[i][j]].size() - na[i].size() + 1));
}
}
printf("%lld\n", ans / 2 );
}
}
/*
*/
D:
#include<bits/stdc++.h>
using namespace std;
#define pii pair<int,int>
#define ll long long
#define mp make_pair
#define pb push_back
#define mt(a,val) memset(a,val,sizeof(a))
const int mod = 998244353;
const int inf = 0x3f3f3f3f;
const ll INF = 0x3f3f3f3f3f3f3f3f;
const double pi = 3.14159265;
const int maxn = 3e5 + 7;
int t, n, m;
ll a[maxn];
ll b[maxn];
vector <ll> one, two;
ll preone[maxn],pretwo[maxn];
int pone, ptwo;
int main()
{
scanf("%d", &t);
while(t --)
{
scanf("%d%d", &n, &m);
for(int i = 0; i <= n; i ++)
preone[i] = pretwo[i] = 0;
one.clear();
two.clear();
for(int i = 0; i < n; i ++)
scanf("%lld", &a[i]);
for(int i = 0; i < n; i ++)
{
scanf("%lld", &b[i]);
if(b[i] == 1)
one.pb(a[i]);
else
two.pb(a[i]);
}
sort(one.begin(), one.end());
sort(two.begin(), two.end());
pone = ptwo = 1;
for(int i = one.size() - 1; i >= 0; i --)
{
preone[pone] = preone[pone - 1] + one[i];
pone ++;
}
//for(int i = 1; i < pone; i ++)
// cout<<preone[i]<<endl;
for(int i = two.size() - 1; i >= 0; i --)
{
pretwo[ptwo] = pretwo[ptwo - 1] + two[i];
ptwo ++;
}
//for(int i = 1; i < ptwo; i ++)
// cout<<pretwo[i]<<endl;
int i = 0, j = ptwo - 1;
ll ans = inf;
while(i < pone && j >= 0)
{
if(preone[i] + pretwo[j] >= m)
{
ans = min(ans, 1ll * i + j * 2);
j --;
}
else
{
i ++;
}
}
if(ans != inf)
printf("%lld\n", ans);
else
printf("-1\n");
}
}
/*
*/
E:
#include<bits/stdc++.h>
using namespace std;
#define pii pair<int,int>
#define ll long long
#define mp make_pair
#define pb push_back
#define mt(a,val) memset(a,val,sizeof(a))
const int mod = 1e9 + 7;
const int inf = 0x3f3f3f3f;
const ll INF = 0x3f3f3f3f3f3f3f3f;
const double pi = 3.14159265;
const int maxn = 1e5 + 7;
int t, n, m;
int a[maxn];
ll ans;
int f[maxn], inv[maxn], finv[maxn];
void init(){
inv[1] = 1;
for (int i = 2; i < maxn; i++) inv[i] = (mod - mod / i) * 1ll * inv[mod % i] % mod;
f[0] = finv[0] = 1;
for (int i = 1; i < maxn; i++) {
f[i] = f[i - 1] * 1ll * i % mod;
finv[i] = finv[i - 1] * 1ll * inv[i] % mod;
}
}
int C(int n, int m){
if (m < 0 || m > n) return 0;
return f[n] * 1ll * finv[n - m] % mod * finv[m] % mod;
}
int main()
{
scanf("%d", &t);
init();
while(t --)
{
scanf("%d%d", &n, &m);
for(int i = 0; i < n; i ++)
{
scanf("%d", &a[i]);
a[i] = - a[i];
}
sort(a , a + n );
int fz = 0, fm = 0;
for(int i = 0; i < n; i ++)
{
//cout<<a[i]<<endl;
if(a[i] == a[m - 1])
{
fm ++;
if(i < m)
fz ++;
}
}
cout<<C(fm,fz)<<endl;
}
}
/*
*/
F:
#include<bits/stdc++.h>
using namespace std;
#define pii pair<int,int>
#define ll long long
#define mp make_pair
#define pb push_back
#define mt(a,val) memset(a,val,sizeof(a))
const int mod = 998244353;
const int inf = 0x3f3f3f3f;
const ll INF = 0x3f3f3f3f3f3f3f3f;
const double pi = 3.14159265;
const int maxn = 3e5 + 7;
int t;
int n;
int a[1005];
int b[1005];
char x[1005][1005], s[1005];
int main()
{
scanf("%d", &t);
while(t --)
{
scanf("%d", &n);
for(int i = 0; i < n; i ++)
scanf("%s", x[i]);
for(int i = 0; i < n; i ++)
{
scanf("%s", s);
for(int j = 0; j < n; j ++)
{
x[i][j] ^= s[j];
}
}
int flag = 1;
for(int i = 0; i <n; i ++)
{
if(i)
{
for(int j = 0; j < n; j ++)
x[i][j] = a[j] ^ (int)x[i][j];
b[i] = x[i][0];
for(int j = 1; j < n; j ++)
if(b[i] != (int)x[i][j])
flag = 0;
}
else
{
for(int j = 0; j < n; j ++)
a[j] = (int)x[i][j];
}
}
if(flag)
printf("YES\n");
else
printf("NO\n");
}
}
/*
*/
G:
#include<bits/stdc++.h>
using namespace std;
#define pii pair<int,int>
#define ll long long
#define mp make_pair
#define pb push_back
#define mt(a,val) memset(a,val,sizeof(a))
const int mod = 998244353;
const int inf = 0x3f3f3f3f;
const ll INF = 0x3f3f3f3f3f3f3f3f;
const double pi = 3.14159265;
const int maxn = 2e5 + 7;
int t, n;
int a[maxn];
int num[maxn];
int dp[maxn];
int main()
{
scanf("%d", &t);
while(t --)
{
scanf("%d", &n);
for(int i = 0; i < maxn; i ++)
num[i] = dp[i] = 0;
for(int i = 0; i < n; i ++)
{
scanf("%d", &a[i]);
num[a[i]] ++;
}
for(int i = 1; i < maxn; i ++)
{
dp[i] += num[i];
for(int j = i * 2; j < maxn; j += i)
{
dp[j] = max(dp[j], dp[i]);
}
}
int ans = 0;
for(int i = 0; i < maxn; i ++)
ans = max(ans, dp[i]);
printf("%d\n", n - ans);
}
}
/*
*/