随笔分类 -  Codeforces

摘要:p.s.这场比赛题目都还挺好的我觉得,但还是做跪了,要是没那4个hack的话就死了...A.略B.解法:可以直接预处理出来距离每个数最近的素数,然后加一遍。当然也可以打个素数表然后二分。我的二分写法 1 #include<cstdio> 2 #include<cstring> 3 #include<algorithm> 4 #include<iostream> 5 #define N 1000010 6 using namespace std; 7 bool p[N]; 8 int s[N]; 9 int x[1010][1010];10 int 阅读全文
posted @ 2013-02-12 20:04 silver__bullet 阅读(187) 评论(0) 推荐(0)
摘要:期末考试真是令人纠结的东西。。。最近除了做比赛之外不打算大规模刷题了。。要不期末稳跪。。。A.有坑的一题。。。需要注意m和n的大小,别的没啥了。。。A 1 #include<cstdio> 2 #include<cstring> 3 #include<algorithm> 4 using namespace std; 5 int main(){ 6 freopen("input.txt","r",stdin); 7 freopen("output.txt","w",stdout) 阅读全文
posted @ 2012-12-11 12:30 silver__bullet 阅读(168) 评论(0) 推荐(0)
摘要:先挖个坑....这几天没时间填..... 阅读全文
posted @ 2012-11-28 10:36 silver__bullet 阅读(118) 评论(0) 推荐(0)
摘要:A.解法:序列n,n-1,n-2...1就是不满足条件的,因为n-1被换到第一个之后就不会再改变位置了...B.解法:如果这些数的总和能被n整除,那么经过多次操作肯定会让所有的数全变成sum/n,如果不能整除的话,那么就舍弃其中一个数,让其他的数都变成相同的某个值....C.题意:给定n个不同的数,需要从中选出k组,其中每组的和都不一样... 解法:暴力构造就行了,别的没什么了...不过比赛的时候我还是sb了...C 1 #include<iostream> 2 #include<vector> 3 #include<algorithm> 4 #includ 阅读全文
posted @ 2012-11-22 12:44 silver__bullet 阅读(174) 评论(0) 推荐(0)
摘要:A....B...C.从后向前进行贪心,因为后一半的硬币只能是在取前一半的时候被拿掉,而对于前一半,不能确定到底是由哪种方式拿掉的... 如果n是偶数,那么拿掉n时,(n/2)*2+1也应该被拿掉,而实际上没有n+1这一堆,所以肯定不行.C 1 #include<iostream> 2 #include<cstdio> 3 #include<algorithm> 4 #include<cstring> 5 #define N 1010 6 using namespace std; 7 int s[N]; 8 int main(){ 9 int n 阅读全文
posted @ 2012-11-21 21:41 silver__bullet 阅读(104) 评论(0) 推荐(0)
摘要:A...随意搞B.题意:从1~n(n<=1e9)中统计最多由两种不同数字组成的数的个数. 解法:枚举两个数字,然后考虑每一位的情况,用二进制的思想..最后统计结果B 1 #include<iostream> 2 #include<cstring> 3 #include<algorithm> 4 #include<set> 5 using namespace std; 6 typedef long long ll; 7 int dig(ll n){ 8 int ans=0; 9 while(n>0){10 n/=10;11 ans++; 阅读全文
posted @ 2012-11-19 23:14 silver__bullet 阅读(153) 评论(0) 推荐(0)
摘要:吐槽:比赛刚开始codeblocks出了点问题。。边看题边弄编译器。。。囧。。 D居然一直没看。。因为E题意好懂。。然后sb地卡了一场E。。。战斗力太不稳定。。。A...A 1 #include<cstdio> 2 #include<cstring> 3 #include<iostream> 4 #define N 100010 5 using namespace std; 6 int ans[N][2]; 7 int main(){ 8 int x,y,a,b; 9 while(cin>>x>>y>>a>>b 阅读全文
posted @ 2012-11-12 13:54 silver__bullet 阅读(1111) 评论(2) 推荐(0)
摘要:A:...比赛的时候居然写挂了。。。A 1 #include<cstdio> 2 int main(){ 3 int y,k,n; 4 while(~scanf("%d%d%d",&y,&k,&n)){ 5 bool f=0; 6 for(int i=1;i*k<=n;i++){ 7 if(i*k>y){ 8 if(f)printf(" "); 9 printf("%d",i*k-y);10 f=1;11 ... 阅读全文
posted @ 2012-11-06 13:48 silver__bullet 阅读(257) 评论(0) 推荐(0)
摘要:A. 排序,把h,m都相同的归为一类,找到最多的 A 1 #include<iostream> 2 #include<cstring> 3 #include<algorithm> 4 #include<map> 5 #define N 100010 6 using namespace std; 7 struct H{ 8 int h,m; 9 }s[N];10 int hash[N];11 bool cmp(H a,H b){12 if(a.h!=b.h)return a.h<b.h;13 return a.m<b.m;14 }15 阅读全文
posted @ 2012-10-26 06:58 silver__bullet 阅读(238) 评论(0) 推荐(0)
摘要:靠手速拿了个还可以的rank。。。不会dp依旧硬伤A.....A 1 #include<iostream> 2 #include<cstring> 3 #include<string> 4 using namespace std; 5 int hash[100]; 6 int main(){ 7 string s; 8 while(cin>>s){ 9 int cnt=0;10 memset(hash,0,sizeof(hash));11 for(int i=0;i<s.size();i++){12 if(... 阅读全文
posted @ 2012-10-21 21:25 silver__bullet 阅读(225) 评论(0) 推荐(0)