第一次打。。(太弱(+99积分是几个意思

A

题意:一堆数,只有1和2,问最多凑出多少个3.

分情况即可

#include<cstdio>
int main(){
int a=0,b=0,k,n;
scanf("%d",&n);
while(n--)scanf("%d",&k),k==1?++a:++b;
if(a<=b)printf("%d\n",a);
else printf("%d\n",b+(a-b)/3);
return 0;
}

B

题意:问你有没有可能找出连续的n个月天数与给定的相同。

这个打表枚举判断即可。

用py的切片很容易实现

据说很多人被hack了,还是复制一遍稳啊

l=[
31,28,31,30,31,30,31,31,30,31,30,31,
31,28,31,30,31,30,31,31,30,31,30,31,
31,28,31,30,31,30,31,31,30,31,30,31,
31,29,31,30,31,30,31,31,30,31,30,31,
]
l+=l
n=int(input())
k=list(map(int,input().split()))
lim=12*4*2-n+1
for i in range(0,lim):
if k==l[i:i+n]:
print("YES");exit()
print("NO")

C

题意:一个排列,分成两个集合,使和的差最小,输出最小的差和任意一组方案。

先当做n%40看,显然一个集合\([1,\frac{n}{4}]\cup (\frac{3}{4}n,n]\)即可。ans=0

n%41:所有集合数++,剩的1放任意一个集合。ans=1

n%42:所有集合数++,剩的1放肛♂才没放1的集合里。ans=1

n%43:所有集合数++,剩的1放n%4==2时放的1的集合里。ans=0

OjbK

#include<cstdio>
#define rg register
int main(){
int n;scanf("%d",&n);
switch(n%4){
case 0:
puts("0");
printf("%d ",n/2);
for(rg int i=1;i<=n>>2;++i)printf("%d %d ",i,n-i+1);
break;
case 1:
puts("1");
n-=1;
printf("%d ",n/2);
for(rg int i=1;i<=n>>2;++i)printf("%d %d ",i+1,n-i+2);
break;
case 2:
puts("1");
n-=2;
printf("%d ",n/2+1);
for(rg int i=1;i<=n>>2;++i)printf("%d %d ",i,n-i+1);
printf("%d",n+1);
break;
default:
puts("0");
n-=3;
printf("%d ",n/2+2);
for(rg int i=1;i<=n>>2;++i)printf("%d %d ",i+1,n-i+2);
printf("%d 1",n+2);
}
return 0;
}

D

题意:[1,n]里选两个不重复的数相加末尾9最多有多少个?输出方案数

先得到最多多少个,然后枚举满足的数(脑补证明,此数不会相对99...9太大)

然后算一算值域

#include<cstdio>
#include<algorithm>
#define rg register
typedef long long ll;
ll bin[1005];ll lim,n;
ll p[]={1,10,100,1000,10000,100000,1000000,10000000,100000000,1000000000,10000000000ll,100000000000ll};
ll ans=0;
int solve(int w){
static ll x,l,r;
x=w*p[lim]+bin[lim];l=std::max(1ll,x-n),r=std::min(n,x-1);
if(l<=r)return (r-l+1)/2;
else return 0;
}
int main(){
scanf("%I64d",&n);
for(rg int i=1;i<=10;i++)bin[i]=bin[i-1]*10+9;
if(n<=4){printf("%I64d\n",n*(n-1)/2);return 0;}
for(lim=1;lim<=10;lim++)
if(n*2<bin[lim]){lim--;break;}
for(rg int i=0;i<1000;i++)ans+=solve(i);
printf("%I64d\n",ans);
return 0;
}

Codeforces Round #452 (Div. 2)的更多相关文章

  1. Codeforces Round #452 (Div. 2) A B C

    Codeforces Round #452 (Div. 2) A Splitting in Teams 题目链接: http://codeforces.com/contest/899/problem/ ...

  2. Codeforces Round #452 (Div. 2) 899E E. Segments Removal

    题 OvO http://codeforces.com/contest/899/problem/E Codeforces Round #452 (Div. 2) - e 899E 解 用两个并查集(记 ...

  3. Codeforces Round #452 (Div. 2)-899A.Splitting in Teams 899B.Months and Years 899C.Dividing the numbers(规律题)

    A. Splitting in Teams time limit per test 1 second memory limit per test 256 megabytes input standar ...

  4. Codeforces Round #452 (Div. 2) C. Dividing the numbers(水)

    C. Dividing the numbers Petya has n integers: 1, 2, 3, ..., n. He wants to split these integers in t ...

  5. 【Codeforces Round #452 (Div. 2) A】 Splitting in Teams

    [链接] 我是链接,点我呀:) [题意] 在这里输入题意 [题解] 贪心 1优先和2组队. 如果1没有了 就结束. 如果1还有多余的. 那么就自己3个3个组队 [代码] #include <bi ...

  6. 【Codeforces Round #452 (Div. 2) B】Months and Years

    [链接] 我是链接,点我呀:) [题意] 在这里输入题意 [题解] 闰,平,平 平,闰,平 平,平,闰 平,平,平 4种情况都考虑到就好. 可能有重复的情况. 但是没关系啦. [代码] #includ ...

  7. 【Codeforces Round #452 (Div. 2) C】 Dividing the numbers

    [链接] 我是链接,点我呀:) [题意] 在这里输入题意 [题解] n为偶数. l = 1, r = n (l,r)放在一组 l++,r-- 新的l,r放在另外一组 直到l+1==r 这个时候,判断两 ...

  8. 【Codeforces Round #452 (Div. 2) D】Shovel Sale

    [链接] 我是链接,点我呀:) [题意] 在这里输入题意 [题解] 让N乘2->a 然后看一下位数是多少. 假设有x位(x>=2) 则(0..(a%10-1) ) + (99..9)[x- ...

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

随机推荐

  1. js和java判断值为空的方式

    js方式判断值为空: name == ""; java方式判断值为空: name==null || name.trim().isEmpty();注:name==null要在前面,不 ...

  2. IIS6.0解析漏洞

    IIS6.0解析漏洞分两种 1.目录解析 以*.asp命名的文件夹里的文件都将会被当成ASP文件执行. 2.文件解析 *.asp;.jpg 像这种畸形文件名在“:”后面的直接被忽略,也就是说当成 *. ...

  3. 实践和感悟 - scala向下转型和减少穷举

    工作中的问题总结: 问题一:scala 之向下转型 引言:假如在复杂的业务逻辑中,变量的类型不能确认,只能给个接口类型,这样数据类型推导不会错误,但是后面要使用实现类的类型时,你却发现转不过来了? 对 ...

  4. QT5.8连接Mysql提示QMYSQL driver not loaded

    我们都知道在QT5.8系列里已经带了Mysql的dll文件 驱动的名字为“qsqlmysql.dll”和“qsqlmysqld.dll” 但是按照网上的各种教程和博客基本都是错的,只有个别人是对的. ...

  5. Extjs tree 过滤查询功能

    转载: http://blog.csdn.net/xiaobai51509660/article/details/36011899 Extjs4.2中,对于treeStore中未实现filterBy函 ...

  6. android小游戏模版—重力感应

               好久没更新博客了,今天来谈谈android小游戏---重力感应,一般在游戏里运用的比較多,比方这类游戏有:神庙逃亡.极品飞车,平衡球.三围重力迷宫,重力赛车等. 首先什么是重力感 ...

  7. 一般处理程序中用到session时

    一般处理程序ashx文件使用session 1.先引用System.Web.SessionState这个命名空间, 2.如果是要在HttpHandler中读取Session的内容,就要在实现IHttp ...

  8. c++ const static

    const作用: 1.定义常量,可以保护被修饰的东西,防止意外的修改,增强程序的健壮性. const int Max = 100; void f(const int i) { i=10;//error ...

  9. Opencv——级联分类器(AdaBoost)

    API说明: cv::CascadeClassifier::detectMultiScale(InputArray image,//输入灰度图像 CV_OUT std::vector<Rect& ...

  10. Spring整合MyBatis(三)sqlSessionFactory创建

    摘要: 本文结合<Spring源码深度解析>来分析Spring 5.0.6版本的源代码.若有描述错误之处,欢迎指正. 目录 一.SqlSessionFactoryBean的初始化 二.获取 ...