随笔分类 -  ACM~~CoderForces

摘要:#include <iostream>#define LL long longusing namespace std;int main(){ LL n,k; cin >> n >>k; LL split = n%2 ? n/2+1 : n/2; if( k <= split ) cout<<-1+2*k<<endl; else cout<<2*(k-split)<<endl; return 0;} 阅读全文
posted @ 2013-06-15 11:29 OpenSoucre 阅读(200) 评论(0) 推荐(0)
摘要:#include <iostream>#include <vector>#include <string>#include <algorithm>using namespace std;int main(){ string text; cin >> text; vector<int> heavyPos,metalPos; size_t pos = 0; while((pos = text.find("heavy",pos)) != string::npos) heavyPos.push_back(pos 阅读全文
posted @ 2013-06-15 11:28 OpenSoucre 阅读(203) 评论(0) 推荐(0)
摘要:#include <iostream>#include <vector>#include <cstdio>using namespace std;int main(){ int n; cin >> n; vector<int> neg,zero,pos; int a; for(int i = 0; i < n; i ++ ) { cin >>a; if(a > 0) pos.push_back(a); else if(a < 0) neg.push_back(a); else zero.push_back 阅读全文
posted @ 2013-04-26 01:44 OpenSoucre 阅读(220) 评论(0) 推荐(0)
摘要:很郁闷的一题,完全在考数学的不等式题目简化后的公式为 a^3+b^3+c^3+n=(a+b+c)^3,对其进行化简,最后的等式为 (a+b)(a+c)(b+c)=n/3假设 a<=b<=c,(注意求得a,b,c后对其进行排列,原本的a,b,c是没有顺序的)则 (a+b)<=(a+c)<=(b+c)三个数相乘必然有个数小于等于 开n/3的立方,有一个数大于等于开n/3的立方如 xy=n ,则 x <= √n ,y>=√n设 i=(a+b) , j = (a+c), k =(b+c),则 i<=j<=k令 n=n/3枚举 i=2....sqrt(n) 阅读全文
posted @ 2013-04-24 17:00 OpenSoucre 阅读(187) 评论(0) 推荐(0)
摘要:#include <iostream>#include <vector>#include <algorithm>#include <string>using namespace std;int main(){ int n,k; cin >>n>>k; string ss; cin >> ss; bool isEnd = false; for(int i = 0; i < n; i ++ ){ if(ss[i+1] == '#'){ int j; for( j =i+1; j <= i 阅读全文
posted @ 2013-04-23 09:14 OpenSoucre 阅读(176) 评论(0) 推荐(0)
摘要:#include <iostream>#include <vector>#include <algorithm>using namespace std;int main(){ int n; cin >> n; vector<long long> a(n); long long minv = 1<<30; for(int i = 0; i < n; i++) { cin >> a[i]; minv = min(a[i],minv); } int i = 0; for( i = 0; i < n; i 阅读全文
posted @ 2013-04-23 09:13 OpenSoucre 阅读(176) 评论(0) 推荐(0)
摘要:很悲剧的一提,重提交的了三次,WA 6,第6测试用例是41000100110101101输出:Draw#include <iostream>#include <vector>#include <algorithm>#include <string>using namespace std;int main(){ long n; cin >>n; string s,t; cin >> s>>t; long ones=0,onet =0,oneshare = 0; for(long i =0; i < 2*n; 阅读全文
posted @ 2013-04-23 09:11 OpenSoucre 阅读(211) 评论(0) 推荐(0)