随笔分类 -  ACM~~CoderForces

摘要:按照半径排序,然后累加人数直到超过百万#include #include #include #include #include using namespace std;int main(){ int n,s; cin >> n >>s; map a; for(int i = ... 阅读全文
posted @ 2014-04-25 18:14 OpenSoucre 阅读(247) 评论(0) 推荐(0)
摘要:解题思路是:Q=q1^q2.......^qn = p1^p2......^pn^((1%1)^....(1%n))^((2%1)^......(2%n))^....故Q的求解过程分成两部分第一部分是求p1^p2......^pn第二部分是求((1%1)^....(1%n))^((2%1)^....... 阅读全文
posted @ 2014-04-25 17:30 OpenSoucre 阅读(732) 评论(2) 推荐(0)
摘要:题目的意思是老板给n个人发工资,x欠y的工资,the joy of personxfrom his brand new money reward will be much less,老板想避免x后面是y领工资,故利用bfs,找到无后继的点在提交代码的时候输出时格式好像没有oj的平台那么严,可以包含多... 阅读全文
posted @ 2014-04-25 11:24 OpenSoucre 阅读(255) 评论(0) 推荐(0)
摘要:水题#include #include #include using namespace std;int main(){ int n,a,b; cin >> n >>a >> b; vector apple(n+1,0); int k; for(int i = 0 ; ... 阅读全文
posted @ 2014-04-22 23:37 OpenSoucre 阅读(178) 评论(0) 推荐(0)
摘要:需要满足的条件是(1)每个字母是对称的(2)每个字符串是对称的#include #include #include using namespace std;const string mirrorChar = "AHIMOTUVWXY";int main(){ string str; ci... 阅读全文
posted @ 2014-04-22 23:34 OpenSoucre 阅读(273) 评论(0) 推荐(0)
摘要:此题题意就是匹配邮箱,提交时一直在test 14上WA,看了测试用例之后才发现计数用的int溢出,要用long long还是做题经验不够,导致此题未能通过,以后一定要考虑数据量大小题意是找出邮件地址的数量,永许出现相同的地址此题最重要的部分是要注意邮件地址的构成规则1、邮件开始部分必须是字母串,数字... 阅读全文
posted @ 2014-04-19 12:59 OpenSoucre 阅读(263) 评论(0) 推荐(0)
摘要:题目的意思是给出n个长度相同的字符串然后找出与他们匹配的字符串将字符串存入类似二维数组的里面,每一行代表一个字符串,遍历每列,判断每列是否有公共的匹配字符,如果有输出任意一个如果没有输出'?'#include #include #include #include using namespace st... 阅读全文
posted @ 2014-04-19 12:36 OpenSoucre 阅读(180) 评论(0) 推荐(0)
摘要:题目的意思就是给每台电脑的最大传输速度,可以限制每台电脑的最大速度,然后选择k台电脑,使这k台电脑有相同的速度,且这个速度最大典型的贪心算法,电脑的速度排个序,选择第k大速度即可#include #include #include using namespace std;int main(){ ... 阅读全文
posted @ 2014-04-19 12:32 OpenSoucre 阅读(156) 评论(0) 推荐(0)
摘要:主要就是先将梯子移动到最左边或者最右边k>n/2时移动到最右边k#include #include using namespace std;int main(){ int n,k; cin >> n >> k; string poster ; cin >> poster; ... 阅读全文
posted @ 2014-04-19 12:28 OpenSoucre 阅读(148) 评论(0) 推荐(0)
摘要:让对角线的元素为k就行#include using namespace std;int main() { int n,k; cin >> n >> k; for(int i = 0 ; i < n; ++ i){ for(int j = 0 ; j < n ; ++ j){ if(j != 0) cout<<" "; if( i == j) cout<<k; else cout<<0; } cout<<endl; } return 0;} 阅读全文
posted @ 2014-03-15 19:35 OpenSoucre 阅读(259) 评论(0) 推荐(0)
摘要:解题思路:如果序列a是单调递增的,则序列为1,2,..... 2n,则将给出的式子化简得Σ(a2i - a2i-1) = n如果序列a是单调递减的,则序列为2n,.........2, 1,则将给出的式子化简得为0故本题的解决方法是前面2k个序列即a1,a2......a2k是单调递增的,后面的序列是单调递减的#include using namespace std;int main(){ int n , k; cin >> n >> k; bool flag = false; for(int i = 1; i 2*k; --i){ if(!flag) ... 阅读全文
posted @ 2014-03-15 19:15 OpenSoucre 阅读(197) 评论(0) 推荐(0)
摘要:#include #include using namespace std;int main(){ int n,m; cin >> n >> m; int a[50][50]; bool flag = false; for(int i = 0 ; i > a[i][j]; } } for(int j = 0; j < m; ++ j){ if(a[0][j] || a[n-1][j]){ flag = true; break; } } for(int i... 阅读全文
posted @ 2014-03-15 18:38 OpenSoucre 阅读(211) 评论(0) 推荐(0)
摘要:#include #include #include using namespace std;int main(){ int n,k,l,r,s_n,s_k; cin >> n >> k >> l >> r >> s_n >> s_k; int s_n_k = s_n-s_k; int average_k = s_k/k,left_k = s_k%k; vector a(n,0); for(int i = 0 ; i < k ; ++ i ){ a[i] = average_k; if(i < left_k) 阅读全文
posted @ 2014-03-15 16:22 OpenSoucre 阅读(178) 评论(0) 推荐(0)
摘要:#include using namespace std;int main(){ int n, m , k; cin >> n >> m >> k; int first_type = 0, second_type = 0; for(int i = 0 ; i > a; (a == 1) ? first_type++ : second_type ++ ; } int wash_number = 0; if(first_type - m >= 0 ){ wash_number = first_type - m; ... 阅读全文
posted @ 2014-03-15 15:48 OpenSoucre 阅读(228) 评论(0) 推荐(0)
摘要:一般方法:#include #include #include using namespace std;//形如abaint oneCenter(string const& str, int index){ int len = 1 , i = 1; while((index-i)>=0 && (index+i)= 0 && (index+1+i > str; cout<<"Max longest string lenght is " <<solve(str) <<endl;} 阅读全文
posted @ 2014-03-13 23:10 OpenSoucre 阅读(199) 评论(0) 推荐(0)
摘要:#include #include using namespace std;int main(){ int n; cin >> n; string str; cin >> str; long long cnt = 0, x = 1; for(int i = 0 ; i < n ; ++ i){ if(str[i] == 'B') cnt+=(x << i); } cout<<cnt<<endl;}Codeforces Round #233 (Div. 2) 阅读全文
posted @ 2014-03-13 21:12 OpenSoucre 阅读(166) 评论(0) 推荐(0)
摘要:#include using namespace std;int main(){ int n,p,k; cin >> n >> p >> k; bool hasLeft = true, hasRight = true; int first = p-k,last = p + k; if( p - k = n) last = n,hasRight = false; if(hasLeft) cout>"<<endl;} 阅读全文
posted @ 2014-03-13 20:53 OpenSoucre 阅读(154) 评论(0) 推荐(0)
摘要:#include #include using namespace std;int main(){ int n,m; cin >> n >> m; if(n > (m + 1) || m > (n + 1)*2 ) cout= m) { for(int i = 0; i =m){ for(int i = 0; i< m - n; ++ i) cout<<"110"; for(int i =m-n; i < n; ++ i ) cout<< "10"; }else{ for(int i 阅读全文
posted @ 2014-03-13 19:56 OpenSoucre 阅读(160) 评论(0) 推荐(0)
摘要:#include #include #include using namespace std;int main(){ int x,k; cin >> x >> k; vector num(x+1, false); num[x] = true; for(int i = 0 ; i > index; if( index == 1){ cin >> num1 >> num2; num[num1]=num[num2] = true; }else{ cin >> num1; ... 阅读全文
posted @ 2014-03-12 23:47 OpenSoucre 阅读(222) 评论(0) 推荐(0)
摘要:#include using namespace std;int main(){ int n,x; cin >> n >> x; int sum = 0; for(int i = 0 ; i > number; sum +=number; } if(sum < 0) sum = -sum; cout<<(sum%x ? sum/x+1 : sum/x) <<endl;} 阅读全文
posted @ 2014-03-12 22:36 OpenSoucre 阅读(213) 评论(0) 推荐(0)