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)的更多相关文章

  1. Codeforces Round #697 (Div. 3) G. Strange Beauty (DP,数学)

    题意:给你一组数,问你最少删去多少数,使得剩下的数,每个数都能整除数组中其它某个数或被数组中其它某个数整除. 题解:我们直接枚举所有因子,\(dp[i]\)表示\(i\)在数组中所含的最大因子数(当我 ...

  2. Codeforces Round #697 (Div. 3) F. Unusual Matrix (思维,数学)

    题意:给你一个矩阵\(a\)和\(b\),你可以对\(a\)的任意一行或任意一列的所有元素xor\(1\)任意次,问最终是否能够得到\(b\). 题解:由\(a\ xor\ b=c\),可得:\(a\ ...

  3. Codeforces Round #697 (Div. 3) D. Cleaning the Phone (思维,前缀和)

    题意:你的手机有\(n\)个app,每个app的大小为\(a_i\),现在你的手机空间快满了,你需要删掉总共至少\(m\)体积的app,每个app在你心中的珍惜值是\(b_i\),\(b_i\)的取值 ...

  4. 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 ...

  5. Codeforces Round #354 (Div. 2) ABCD

    Codeforces Round #354 (Div. 2) Problems     # Name     A Nicholas and Permutation standard input/out ...

  6. Codeforces Round #368 (Div. 2)

    直达–>Codeforces Round #368 (Div. 2) A Brain’s Photos 给你一个NxM的矩阵,一个字母代表一种颜色,如果有”C”,”M”,”Y”三种中任意一种就输 ...

  7. cf之路,1,Codeforces Round #345 (Div. 2)

     cf之路,1,Codeforces Round #345 (Div. 2) ps:昨天第一次参加cf比赛,比赛之前为了熟悉下cf比赛题目的难度.所以做了round#345连试试水的深浅.....   ...

  8. Codeforces Round #279 (Div. 2) ABCDE

    Codeforces Round #279 (Div. 2) 做得我都变绿了! Problems     # Name     A Team Olympiad standard input/outpu ...

  9. 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 ...

随机推荐

  1. PTA 统计二叉树度为1的结点个数

    6-3 统计二叉树度为1的结点个数 (10 分)   本题要求实现一个函数,可统计二叉树中度为1的结点个数. 函数接口定义: int NodeCount ( BiTree T); T是二叉树树根指针, ...

  2. Announcing cnblogs-hardening 1.0 Preview 1

    Release Notes Write about coding Note About coding Share about coding Talk about coding Comment abou ...

  3. mysql数据库忘记密码时如何修改密码

    方法/步骤  1.进入 mysql 的 bin 目录下,打开 cmd ,在此之前关闭mysql服务,并且结束mysqld.exe进程                                  ...

  4. Android控件 之 TextClock & AnalogClock(模拟时钟)

    TextClock •简介 关于时间的文本显示,Android 提供了 DigitalClock 和 TextClock. DigitalClock是Android第1版本发布,功能很简单,只显示时间 ...

  5. 图文详解Java对象内存布局

    作为一名Java程序员,我们在日常工作中使用这款面向对象的编程语言时,做的最频繁的操作大概就是去创建一个个的对象了.对象的创建方式虽然有很多,可以通过new.反射.clone.反序列化等不同方式来创建 ...

  6. UnboundLocalError: local variable 'foo' referenced before assignment Python常见错误

    在定义局部变量前在函数中使用局部变量(此时有与局部变量同名的全局变量存在) 在函数中使用局部变来那个而同时又存在同名全局变量时是很复杂的, 使用规则:如果在函数中定义了任何东西,如果它只是在函数中使用 ...

  7. Etcd常用运维命令

    目录 常用命令 常见操作 如何缩容? 如何扩容? 数据目录丢失或被误删除,节点启动失败或者加入集群报错? 操作步骤 操作步骤不正确的各种常见错误日志 常用命令 #查看集群member情况 etcdct ...

  8. jq分页功能。

    最近在写官网的分页功能.在网上找了很多案例都太复杂也太重.所以准备写一个简单一点的分页. 需求:把请求到的数据做分页. 准备:使用了网上一个简单的分页插件. 思路:分页相当于tab切换功能.具体实操把 ...

  9. 使用 EPPlus 封装的 excel 表格导入功能 (.net core c#)

    使用 EPPlus 封装的 excel 表格导入功能 前言 最近做系统的时候有很多 excel导入 的功能,以前我前后端都做的时候是在前端解析,然后再做个批量插入的接口 我觉着这样挺好的,后端部分可以 ...

  10. SqlServer存储过程应用二:分页查询数据并动态拼接where条件

    前言 开发中查询功能是贯穿全文的,我们来盘一盘使用存储过程分页查询,并且支持动态拼接where条件. 划重点:支持动态拼接where条件 对存储过程的使用有疑问的同学去[SqlServer存储过程的创 ...