题目大体概括

A

#include <cstdio>
#include <cstring>
#include <algorithm>
#include <iostream>
using namespace std;typedef long long LL;
const int N = 500;
LL a[N];
int sz;
bool Check(LL n)
{for (int i = 0; i <= sz; i ++ ){if (n == a[i]) return false;}return true;
}int main()
{int T;  cin >> T;LL n;a[0] = 1;sz = 60;for (int i = 1; i <= sz; i ++ )a[i] = a[i - 1] * 2;while (T -- ){scanf("%lld", &n);if (Check(n)){cout << "YES" << endl;}else{cout << "NO" << endl;}}return 0;
}

B

#include <cstdio>
#include <cstring>
#include <algorithm>
#include <iostream>
using namespace std;typedef long long LL;
const int N = 1000010;
bool st[N + 10];int main()
{int T;  cin >> T;memset(st, false, sizeof st);st[2020] = st[2021] = true;for (int i = 2022; i < N; i ++ ){st[i] = st[i - 2020] | st[i - 2021];}while (T -- ){static int x;   scanf("%d", &x);if (st[x])  cout << "YES\n";else    cout << "NO\n";}return 0;
}

C

#include <cstdio>
#include <cstring>
#include <algorithm>
#include <iostream>
using namespace std;typedef long long LL;
const int N = 200010;
int cnt1[N], cnt2[N];
int n, m, k;int main()
{int T;  cin >> T;while (T -- ){scanf("%d%d%d", &n, &m, &k);static int x;   static LL res;res = 0LL;memset(cnt1, 0, sizeof cnt1);memset(cnt2, 0, sizeof cnt2);for (int i = 1; i <= k; i ++ ){scanf("%d", &x);cnt1[x] ++;}for (int i = 1; i <= k; i ++ ){scanf("%d", &x);cnt2[x] ++;}res = LL(k) * (k - 1);for (int i = 1; i <= n; i ++ ){res -= LL(cnt1[i]) * (cnt1[i] - 1);}for (int i = 1; i <= m; i ++ ){res -= LL(cnt2[i]) * (cnt2[i] - 1);}cout << res / 2 << endl;}return 0;
}

D

#include <cstdio>
#include <cstring>
#include <algorithm>
#include <iostream>
using namespace std;typedef long long LL;
const int N = 200010, INF = 0x3f3f3f3f;
int n, m;
int a[N];
LL c[N], d[N];
int szc, szd;bool cmp(LL a, LL b)
{return a > b;
}
int main()
{int T;  cin >> T;while (T -- ){static int b;cin >> n >> m;for (int i = 1; i <= n; i ++ )  scanf("%d", &a[i]);c[0] = d[0] = szc = szd = 0;for (int i = 1; i <= n; i ++ ){scanf("%d", &b);if (b & 1)c[++ szc] = a[i];elsed[++ szd] = a[i];}sort(c + 1, c + szc + 1, cmp);sort(d + 1, d + szd + 1, cmp);for (int i = 1; i <= szc; i ++ )    c[i] += c[i - 1];for (int i = 1; i <= szd; i ++ )    d[i] += d[i - 1];if (c[szc] + d[szd] < m){puts("-1");}else{int res = INF;for (int i = 0; i <= szc; i ++ ){if (c[i] + d[szd] < m)continue;else if (c[i] >= m){res = min(res, i);break;}else{static int tmp;tmp = lower_bound(d + 1, d + 1 + szd, m - c[i]) - d;res = min(res, tmp + tmp + i);}}cout << res << endl;}}return 0;
}

E

#include <cstdio>
#include <cstring>
#include <algorithm>
#include <iostream>
using namespace std;typedef long long LL;
const int N = 1010, INF = 0x3f3f3f3f;
const int MOD = 1e9 + 7;
int n, k;
int a[N];
int f[N][N];bool cmp(LL a, LL b)
{return a > b;
}int main()
{memset(f, 0, sizeof f);for (int i = 0; i < N; i ++ )f[i][i] = f[i][0] = 1;for (int i = 1; i < N; i ++ )for (int j = 1; j <= i; j ++ )f[i][j] = (f[i - 1][j] + f[i - 1][j - 1]) % MOD;int T;  cin >> T;while (T -- ){cin >> n >> k;for (int i = 1; i <= n; i ++ )scanf("%d", &a[i]);sort(a + 1, a + n + 1, cmp);static int x, sidx, eidx;x = a[k], sidx = -1, eidx = -1;for (int i = 1; i <= n; i ++ ){if (a[i] == x){if (sidx == -1) sidx = i;eidx = i;}}cout << f[eidx - sidx + 1][k - sidx + 1] << endl;}return 0;
}

F

#include <cstdio>
#include <cstring>
#include <algorithm>
#include <iostream>
using namespace std;typedef long long LL;
const int N = 1010, INF = 0x3f3f3f3f;
const int MOD = 1e9 + 7;
int n;
char a[N][N], b[N][N];
char c[N][N];inline void Change(char c[][N], int x, bool row);
bool Same(char c[][N], char d[][N], int x)
{for (int i = 1; i <= n; i ++ )if (c[x][i] != d[x][i])return false;return true;
}bool Check(char c[][N], char d[][N])
{// 第一行是不需要动的,我们看看 列 的影响for (int i = 1; i <= n; i ++ )if (c[1][i] != d[1][i])Change(c, i, false);for (int i = 2; i <= n; i ++ ){if (c[i][1] != d[i][1]) // 修改 行Change(c, i, true);if (!Same(c, d, i))return false;}return true;
}
inline void Change(char c[][N], int x, bool row)
{if (row)    // rowfor (int i = 1; i <= n; i ++ ){c[x][i] = 97 - c[x][i];   // 48 + 49 - c[i]}else        // colfor (int i = 1; i <= n; i ++ ){c[i][x] = 97 - c[i][x];   // 48 + 49 - c[i]}
}int main()
{int T;  cin >> T;while (T -- ){cin >> n;for (int i = 1; i <= n; i ++ )scanf("%s", a[i] + 1);for (int i = 1; i <= n; i ++ )scanf("%s", b[i] + 1);memcpy(c, a, sizeof c);if (Check(c, b) || (memcpy(c, a, sizeof c), Change(c, 1, true), Check(c, b)))puts("YES");elseputs("NO");}return 0;
}

G

#include <cstdio>
#include <cstring>
#include <algorithm>
#include <iostream>
using namespace std;typedef long long LL;
const int N = 200010, INF = 0x3f3f3f3f;int cnt[N];
int a[N];
bool st[N];
int f[N];
int n;int main()
{int T;  cin >> T;while (T -- ){static int res;cin >> n;for (int i = 1; i <= n; i ++ )scanf("%d", &a[i]);res = INF;sort(a + 1, a + 1 + n);memset(cnt, 0, sizeof cnt);memset(st, false, sizeof st);memset(f, 0, sizeof f);for (int i = 1; i <= n; i ++ )  cnt[a[i]] ++;for (int i = 1, val; i <= n; i ++ ){val = a[i];if (st[val])    continue;st[val] = true;// cnt[val] = max(cnt[val], 1);f[val] = f[val] + cnt[val];    // 给自己加的for (int j = val + val; j < N; j += val){f[j] = max(f[j], f[val]); // 给别的数字加的}res = min(res, n - f[val]);}cout << res << endl;}return 0;
}

Codeforces Round #697 (Div.3) A~G解题报告与解法证明相关推荐

  1. Codeforces Round #697 (Div. 3)A~G解题报告

    Codeforces Round #697 (Div. 3)A~G解题报告 题 A Odd Divisor 题目介绍 解题思路 乍一想本题,感觉有点迷迷糊糊,但是证难则反,直接考虑没有奇数因子的情况, ...

  2. Codeforces Round #693 (Div. 3)A~G解题报告

    Codeforces Round #693 (Div. 3)A~G解题报告 A Cards for Friends 原题信息 http://codeforces.com/contest/1472/pr ...

  3. Codeforces Round #700 (Div. 2)A~D2解题报告

    Codeforces Round #700 (Div. 2)A~D2解题报告 A Yet Another String Game 原题链接 http://codeforces.com/contest/ ...

  4. Codeforces Round #830 (Div. 2) B. Ugu 解题报告

    原题链接: Problem - B - Codeforces 题目描述: A binary string is a string consisting only of the characters 0 ...

  5. 【Codeforces Round #570 (Div. 3) A-H 】解题报告

    cf570 cf570A 题意 一个数的数位和%4如果为 0 是我们要的答案 问加几次能使得他数位和 %4 为0 暴力即可 /*if you can't see the repayWhy not ju ...

  6. Codeforces Round #698 (Div. 2) A-E解题报告与解法证明

    Codeforces Round #698 (Div. 2) A-E解题报告与解法证明 题目解法总体概括 A Nezzar and Colorful Balls #include <bits/s ...

  7. Codeforces Round #701 (Div. 2)赛后补题报告(A~D)

    Codeforces Round #701 (Div. 2)赛后补题报告(A~D) A. Add and Divide 原题信息 http://codeforces.com/contest/1485/ ...

  8. Codeforces Round #827 (Div. 4) A~G

     比赛链接:Dashboard - Codeforces Round #827 (Div. 4) - Codeforces 目录 A Sum B Increasing C Stripes D. Cop ...

  9. Codeforces Round #697 (Div. 3) G. Strange Beauty 线性筛变形思维

    原题链接 题意: n个数,问删除多少个数之后剩下的数组中的数满足:对于任意一对i,j满足ai%aj==0 || aj%ai ==0. 思路: 题目给的ai只有2e5,很容易想到从ai入手,算出如果当前 ...

最新文章

  1. L-SNET:从区域定位到尺度不变的医学图像分割
  2. Spring事务配置探究
  3. Symbian 编程总结导读
  4. Ruby. Vs . Python
  5. 【音乐】想不起来歌名的瞎唱
  6. 问题六十:怎么用ray tracing画回旋体(rotational sweeping / revolution)
  7. 服务器linux命令aux,Linux查看所有进程ps -aux命令介绍
  8. Word文字怎么添加下划线
  9. Acwing 1402. 星空之夜(搜索+哈希)
  10. TOEFL 9个托福独立写作模板总结
  11. matlab gmm,GMM聚类及Matlab代码实现
  12. 三分钟快速解决vs2015连接数据库显示该文件正在使用/该sql文件被占用等问题
  13. 从外网到域控(vulnstack靶机实战一)
  14. WIN7桌面IE图标删除
  15. Longhorn入门级教程!轻松实现持久化存储!
  16. 删除的微信好友可以恢复吗?不小心把微信好友删了怎么找回
  17. 被打脸!谁说区块链无落地?这50大落地场景拿走不谢
  18. Java+SSM(Spring+SpringMVC+Mybatis)个性化购物商城推荐系统 电子商务推荐系统 基于用户、项目、聚类、混合的协同过滤推荐算法WebShopRSMEx 源代码下载
  19. 宏杰文件夹加密软件 v2928 官方免费版
  20. 小酌重构系列[3]——方法、字段的提升和降低

热门文章

  1. centos清除dns cache.
  2. Java微信公众平台获取签名
  3. css那些事儿4 背景图像
  4. android基础知识之一
  5. memcache 原理 监测 查看状态 stats 结构
  6. 嵌入式系统Linux内核开发工程师必须掌握的三十道题
  7. boost库在ubuntu下的安装
  8. 解析一个C语言俄罗斯方块游戏,包你看了就会
  9. CC2540 串口0 通道2配置
  10. nts包如何下周 php_windows下PHP7安装方法(ts版和nts版)