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. SpringBoot自动配置探究

    @SpringBootApplication @SpringBootApplication表示SpringBoot应用,标注在某个类上说明这个类是SpringBoot的主配置类,SpringBoot就 ...

  2. Reverse 高校网络信息安全运维挑战赛

    Reverse 高校网络信息安全运维挑战赛 1 signed int sub_403CC0() 2 { 3 unsigned int v0; // eax 4 int key_lens; // eax ...

  3. Java进阶专题(二十七) 将近2万字的Dubbo原理解析,彻底搞懂dubbo (下)

    ...接上文 服务发现 服务发现流程 整体duubo的服务消费原理 Dubbo 框架做服务消费也分为两大部分 , 第一步通过持有远程服务实例生成Invoker,这个Invoker 在客户端是核心的远程 ...

  4. 开源一个比雪花算法更好用的ID生成算法(雪花漂移)

    比雪花算法更好用的ID生成算法(单机或分布式唯一ID) 转载及版权声明 本人从未在博客园之外的网站,发表过本算法长文,其它网站所现文章,均属他人拷贝之作. 所有拷贝之作,均须保留项目开源链接,否则禁止 ...

  5. 翻译:《实用的Python编程》07_04_Function_decorators

    目录 | 上一节 (7.3 返回函数) | 下一节 (7.5 装饰方法) 7.4 函数装饰器 本节介绍装饰器(decorator).因为这是一个高级主题,所以我们只做简单介绍. 译注:根据译者个人的猜 ...

  6. Dapper, Ef core, Freesql 插入大量数据性能比较(一)

    需求:导入9999行数据时Dapper, Ef core, Freesql 谁的性能更优,是如何执行的,级联增加谁性能更佳. 确认方法:sql server 的 sys.dm_exec_query_s ...

  7. xman_2019_format(非栈上格式化字符串仅一次利用的爆破)

    xman_2019_format(非栈上格式化字符串仅一次利用的爆破) 首先检查一下程序的保护机制 然后用IDA分析一下 存在后门 首先malloc了一片堆空间,读入数据 把刚刚读入的数据当作格式化字 ...

  8. 2.EL表达式&JSTL标签库常用方法

    1.EL表达式 Expression Language表达式语言,主要是代替jsp页面中的表达式脚本在jsp页面中进行数据的输出. 格式为${表达式} EL表达式输出Bean的普通属性.数组属性.Li ...

  9. Chrome扩展开发基础教程(附HelloWorld)

    1 概述 Chrome扩展开发的基础教程,代码基于原生JS+H5,教程内容基于谷歌扩展开发官方文档. 2 环境 Chrome 88.0.4324.96 Chromium 87.0.4280.141 B ...

  10. JDBC_14_使用JDBC工具类实现模糊查询

    使用JDBC工具类实现模糊查询 代码: import java.sql.*; /** * 模糊查询 * 测试DBUtils */ public class JDBCTest09 { public st ...