Codeforces Round #697 (Div. 3)
A.Odd Divisor
题意:问一个数是不是含有奇数因子
思路:就直接给这个数循环除以2,看看最后剩下的数是不是0,如果不是就有奇数因子,如果是就没有
想不到:1)当时想着用log2来解决问题,后来发现好像这种想法有点偏
代码:

1 #include<iostream>
2 #include<algorithm>
3 #include<cstdio>
4 #include<cstring>
5 #include<cmath>
6 #include<queue>
7 using namespace std;
8 const long long int maxx=2e5+10;
9 int a[maxx];
10 long long int b[maxx];
11 int main(){
12 long long int t;
13 scanf("%lld",&t);
14 while(t--){
15 __int64 n;
16 scanf("%I64d",&n);
17 if(n==1){
18 printf("NO\n");
19 }else{
20 while(n%2==0){
21 n/=2;
22 }
23 if(n>1){
24 printf("YES\n");
25 }else{
26 printf("NO\n");
27 }
28 }
29 }
30 }
B. New Year's Number
题意:问某个数是不是可以由2020和2021构成
思路:直接进行while循环,先进行一个一个的除2021,直到2021褚不开,看看每一次是不是能够%2020魏0,如果出现一次就是可以用他们构成
想错:1)当时第一次想的时候就是简单的进行先除2021再看看余数是不是2020,其实这样就定下了2020只能有一个,这样的思路就是不对的,可能往往最简单的办法,最笨的方法最有效
代码:

1 #include<iostream>
2 #include<algorithm>
3 #include<cstdio>
4 #include<cstring>
5 #include<cmath>
6 #include<queue>
7 using namespace std;
8 const long long int maxx=2e5+10;
9 int a[maxx];
10 long long int b[maxx];
11 int main(){
12 long long int t;
13 scanf("%lld",&t);
14 while(t--){
15 int n;
16 scanf("%d",&n);
17 int flag=0;
18 while(n>=2020){
19 if(n%2020==0){
20 flag=1;
21 break;
22 }
23 n-=2021;
24 }
25 if(flag==1||n==0){
26 printf("YES\n");
27 }else{
28 printf("NO\n");
29 }
30 }
31 }
C. Ball in Berland
题意:就是有a个女生,b个男生,然后构成的小组有k个,从中选取任意两组,问能组成多少组,注意着两组中必须是不同的四个人
思路:定一动一,从头开始先固定一组,然后用总人数减去女生a组成的组数再减男生b组成的组数+1,这样就是第二组的选取
想错:1)当时想用组合数学,发现第四个样例因为需要n*(n-1)可能是太大了,出现了数位不对的状况;2)遍历这几组人的时候,一开始没想对到底是怎么遍历,第一次用了人的编号去遍历出现了错误,应该是从边遍历,才能保证第一组就是对的,这样才会省掉时间和空间
代码:

1 #include<iostream>
2 #include<algorithm>
3 #include<cstdio>
4 #include<cstring>
5 #include<cmath>
6 #include<queue>
7 using namespace std;
8 const long long int maxx=2e5+10;
9 long long int aa[maxx];
10 long long int bb[maxx];
11 //long long int s[maxx][maxx];
12 int main(){
13 long long int t;
14 scanf("%lld",&t);
15 while(t--){
16 long long int ap,bp,k;
17 scanf("%lld %lld %lld",&ap,&bp,&k);
18 long long int a[maxx]={0};
19 long long int b[maxx]={0};
20 for(int i=0;i<k;i++){
21 scanf("%lld",&aa[i]);
22 a[aa[i]]++;
23 }
24
25 for(int i=0;i<k;i++){
26 scanf("%lld",&bb[i]);
27 b[bb[i]]++;
28 }
29 long long int sum=(k-1)*k/2;//
30 for(int i=1;i<=ap;i++){
31 if(a[i]>1){
32 sum-=(a[i]-1)*a[i]/2;
33 }
34 }
35 for(int i=1;i<=bp;i++){
36 if(b[i]>1){
37 sum-=(b[i]-1)*b[i]/2;
38 }
39 }
40 printf("%lld\n",sum);
41 for(int i=0;i<k;i++){
42 aa[i]=0;
43 bb[i]=0;
44 }
45 }
46 }
Codeforces Round #697 (Div. 3)的更多相关文章
- Codeforces Round #697 (Div. 3) G. Strange Beauty (DP,数学)
题意:给你一组数,问你最少删去多少数,使得剩下的数,每个数都能整除数组中其它某个数或被数组中其它某个数整除. 题解:我们直接枚举所有因子,\(dp[i]\)表示\(i\)在数组中所含的最大因子数(当我 ...
- Codeforces Round #697 (Div. 3) F. Unusual Matrix (思维,数学)
题意:给你一个矩阵\(a\)和\(b\),你可以对\(a\)的任意一行或任意一列的所有元素xor\(1\)任意次,问最终是否能够得到\(b\). 题解:由\(a\ xor\ b=c\),可得:\(a\ ...
- Codeforces Round #697 (Div. 3) D. Cleaning the Phone (思维,前缀和)
题意:你的手机有\(n\)个app,每个app的大小为\(a_i\),现在你的手机空间快满了,你需要删掉总共至少\(m\)体积的app,每个app在你心中的珍惜值是\(b_i\),\(b_i\)的取值 ...
- Codeforces Round #366 (Div. 2) ABC
Codeforces Round #366 (Div. 2) A I hate that I love that I hate it水题 #I hate that I love that I hate ...
- Codeforces Round #354 (Div. 2) ABCD
Codeforces Round #354 (Div. 2) Problems # Name A Nicholas and Permutation standard input/out ...
- Codeforces Round #368 (Div. 2)
直达–>Codeforces Round #368 (Div. 2) A Brain’s Photos 给你一个NxM的矩阵,一个字母代表一种颜色,如果有”C”,”M”,”Y”三种中任意一种就输 ...
- cf之路,1,Codeforces Round #345 (Div. 2)
cf之路,1,Codeforces Round #345 (Div. 2) ps:昨天第一次参加cf比赛,比赛之前为了熟悉下cf比赛题目的难度.所以做了round#345连试试水的深浅..... ...
- Codeforces Round #279 (Div. 2) ABCDE
Codeforces Round #279 (Div. 2) 做得我都变绿了! Problems # Name A Team Olympiad standard input/outpu ...
- Codeforces Round #262 (Div. 2) 1003
Codeforces Round #262 (Div. 2) 1003 C. Present time limit per test 2 seconds memory limit per test 2 ...
随机推荐
- Android Studio 之 用 Drawable resource file 美化 Button 样式
shape •新建 Drawable resource file 点击 app/src/main/res 找到 drawable 文件夹,右击->New->Drawable Resourc ...
- 复制文件--cp
cp file1 file2 将文件拷贝到指定路径下 cp -r dir1 dir2 将文件夹拷贝到指定路径下
- 显示目录下的内容--ls
ls 显示当前目录下的所有文件或者文件夹,但不包括 . 和 .. ls -a 显示当前目录下的所有文件或者文件夹 ls -l ...
- CIE标准色度系统(下)
四.色温与相关色温 根据绝对黑体光谱分布特性的普朗克定律,由普朗克公式可以计算出黑体对应于某一温度的光谱分布,并由此应用CIE标准色度系统可获得该温度下黑体发光的三刺激值和色品坐标,从而在色品图上得到 ...
- Dynamics CRM绑定表单查看当前表单的数据参数传递
我们做报表的时候,报表运行的位置可以在列表.也可以在报表区同时也可以在表单界面 其他两个都还好,不需要进行过滤,但是在表单界面运行报表需要将表单的GUID传给报表获取数据,否则就得手动去输入ID 具体 ...
- 《构建之法》& CI/CD调研
项目 内容 这个作业属于哪个课程 2021春季软件工程(罗杰 任健) 这个作业的要求在哪里 2021年软工-个人阅读作业2 我在这个课程的目标是 提升软件开发能力与团队意识 这个作业在哪个具体方面帮助 ...
- springboot项目整合mybatis
记录创建springboot项目并配置mybatis中间件: 资源准备及版本说明 编程工具:IDEA JDK版本:1.8 Maven版本:Apache Maven 3.6.3 springboot版本 ...
- Crackme_003
功能: 拿到文件,先执行一下.功能如下: 1.nag窗口 会先出现如下nag窗口,持续几秒 2.注册窗口: 出现错误会提示:You Get Wrong Try Again 破解: 1.查壳: 无壳, ...
- Python多环境管理——pyenv
1 背景&概述 因某些需求,需要安装TensorFlow,很自然地在终端敲下了以下命令: pip install tensorflow 然后... 好家伙??? 居然没有?? 因为是Pytho ...
- MinIO分布式集群的扩展方案及实现
目录 一.命令行方式扩展 1. MinIO扩展集群支持的命令语法 2. 扩容示例 二.etcd扩展方案 1. 环境变量 2. 运行多个集群 3. 示例 相关链接 MinIO 支持两种扩展方式: 通过修 ...