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. Srping源码之XMLBeanFactory

    ​ 本文是针对Srping的XMLBeanFactory来进行解析xml并将解析后的信息使用GenericBeanDefinition作为载体进行注册,xmlBeanFactory已经在Spring ...

  2. Dynamics CRM 在表单上显示更改历史记录(审核历史记录)

    前言 虽然Dynamics CRM自带的审计很好,但是对于缺乏使用CRM经验的用户来说,自带的UCI界面实在是太隐藏了: 于是乎就出现了需求:想通过在表单上直接看到看审计历史记录: 在网上搜索了很多中 ...

  3. 【linux】驱动-5-驱动框架分层分离&实战

    目录 前言 5. 分离分层 5.1 回顾-设备驱动实现 5.2 分离分层 5.3 设备 5.4 驱动 5.5 系统,模块 5.6 Makefile 参考: 前言 5. 分离分层 本章节记录实现LED驱 ...

  4. 通俗易懂,android是如何管理内存的

    封面来源:https://medium.com/android-news/android-performance-patterns-rescue-tips-8c1e4c7cb1f0 前言 很高兴遇见你 ...

  5. ffmpeg第五篇:让水印图片旋转起来

    这篇把上次挖的坑填上 ffmpeg正式篇的上一篇(传送门)说了,这一篇要让水印旋转起来,但是后面有事情一直没有时间搞,今天,它来了............ 如果想实现旋转的功能,需要使用ffmpeg过 ...

  6. Spring Cloud Alibaba(2)---Nacos概述

    Spring Cloud Alibaba(2)---nacos概述 上一篇博客讲了有关 SpringCloudAlibaba的概述,这篇开始讲SpringCloudAlibaba组件之一---Naco ...

  7. SHA256sum系列命令检测文件完整性

    1 sha256sum sha256sum是一个检测文件完整性的命令,一般下载的文件都会附带一个哈希值,使用sha256sum计算下载文件的哈希值再与目标哈希值比较即可确定文件是否完整,类似的命令还有 ...

  8. 为Github的README.md生成目录的小工具

    1 概述 因为Github的README.md文件[TOC]不生效,因此封装了一个别人已封装好的JAR包供大家使用. 2 使用方法 用Java做的,只需要JDK11以上的环境: java -jar t ...

  9. BPF for storage:一种受外核启发的反式

    BPF for storage:一种受外核启发的反式 译自:BPF for storage: an exokernel-inspired approach BPF主要用于报文处理,通过绕过网络栈提高报 ...

  10. day9.函数2

    一.函数对象 函数是第一类对象,第一等公民,函数对象即函数可以被当作变量去用. 具体分为四个方面: 1.可以被赋值 def func(): print('from func') f = func pr ...