Codeforces Round #452 (Div. 2)
第一次打。。(太弱(+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)的更多相关文章
- Codeforces Round #452 (Div. 2) A B C
Codeforces Round #452 (Div. 2) A Splitting in Teams 题目链接: http://codeforces.com/contest/899/problem/ ...
- Codeforces Round #452 (Div. 2) 899E E. Segments Removal
题 OvO http://codeforces.com/contest/899/problem/E Codeforces Round #452 (Div. 2) - e 899E 解 用两个并查集(记 ...
- 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 ...
- 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 ...
- 【Codeforces Round #452 (Div. 2) A】 Splitting in Teams
[链接] 我是链接,点我呀:) [题意] 在这里输入题意 [题解] 贪心 1优先和2组队. 如果1没有了 就结束. 如果1还有多余的. 那么就自己3个3个组队 [代码] #include <bi ...
- 【Codeforces Round #452 (Div. 2) B】Months and Years
[链接] 我是链接,点我呀:) [题意] 在这里输入题意 [题解] 闰,平,平 平,闰,平 平,平,闰 平,平,平 4种情况都考虑到就好. 可能有重复的情况. 但是没关系啦. [代码] #includ ...
- 【Codeforces Round #452 (Div. 2) C】 Dividing the numbers
[链接] 我是链接,点我呀:) [题意] 在这里输入题意 [题解] n为偶数. l = 1, r = n (l,r)放在一组 l++,r-- 新的l,r放在另外一组 直到l+1==r 这个时候,判断两 ...
- 【Codeforces Round #452 (Div. 2) D】Shovel Sale
[链接] 我是链接,点我呀:) [题意] 在这里输入题意 [题解] 让N乘2->a 然后看一下位数是多少. 假设有x位(x>=2) 则(0..(a%10-1) ) + (99..9)[x- ...
- 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 ...
随机推荐
- 使用Docker构建AspNetCore应用
#Build Image Stage FROM microsoft/aspnetcore-build:2 AS build-env WORKDIR /api # 以下为优化还原,因为项目文件不常变动D ...
- iOS设计模式 - 命令
iOS设计模式 - 命令 原理图 说明 命令对象封装了如何对目标执行指令的信息,因此客户端或调用者不必了解目标的任何细节,却仍可以对他执行任何已有的操作.通过把请求封装成对象,客户端可以把它参数化并置 ...
- 关于UIScrollView有些你很难知晓的崩溃情形
关于UIScrollView有些你很难知晓的崩溃情形 为了实现以下的功能(按钮之间的切换效果): 简短的代码如下: // // RootViewController.m // BUG // // Co ...
- 发现微信支付bug
第一张银行卡支付金额不足无法付款,选择另一张同样密码的银行卡,居然不用重新输入密码即可直接付款成功!
- SQL——快速定位相关的外键表
- sqlserver 一个字段分成两个字段 截取,保存
Ma,LeiTo(Ma,lT) 分割后为 姓 名 Ma,LeiTo Ma,lT SELECT LEFT(作者, CHARINDEX('(', 作者) - 1) AS 姓 , repl ...
- 手动安装 pygame
在windows下 用pip 安装pygame,老是失败,下载了 wheel文件,用pip安装还是不行,查了一下资料,可以手动安装: 1.在 http://www.lfd.uci.edu/~gohlk ...
- [T-ARA][I'm so bad]
歌词来源:http://music.163.com/#/song?id=22704433 作曲 : 김태현 , 조영수 [作曲 : k/gim-Tae-hyeon , c/jo-yeong-su] 作 ...
- python中string格式化
python中可以对string, int, float等数据类型进行格式化操作.下面举例来说明一些常用操作. 先贴出 python 对 String Formatting Operations 讲解 ...
- ubuntu16.04更新内核--使用4.6以上的内核会让用A卡的Dell电脑更快--及卸载多余内核
tips:我自己就是Dell的A卡电脑,用16.04桌面感觉不如fedora流畅,后来手动升级到4.6.2内核,发现可以和fedora与windows一般桌面操作流畅度. 我试过了4.7的开发版内核, ...