摘要: #include <iostream>using namespace std;int main() { long long m,a,b,f[60]; cin>>m; f[1]=1;f[2]=2; for(int i=3;i<60;i++) { f[i]=f[i-1]+f[i-2]; } for(int i=0;i<m;i++) { cin>>a>>b; cout<<f[b-a]<<endl; } return 0;}自信满满的一交,就wa了,结果居然是long long 的原因。。。。要牢记... 阅读全文
posted @ 2012-11-08 19:17 茉莉花茶 阅读(116) 评论(0) 推荐(0)
摘要: #include <iostream>using namespace std;int main() { int m,n,a[40]; cin>>m; for(int i=0;i<m;i++) { cin>>n; a[n+1]=3; for(int j=n;j>0;j--) { a[j]=2*(a[j+1]-1); } cout<<a[1]<<endl; } return 0;}简单dp,学习YY思维 阅读全文
posted @ 2012-11-08 18:59 茉莉花茶 阅读(117) 评论(0) 推荐(0)
摘要: #include <iostream>using namespace std;int main() { int m,n,a[50]; a[1]=1;a[2]=2; for(int j=3;j<=50;j++) { a[j] = a[j-1]+a[j-2]; } cin>>m; for(int i=0;i<m;i++) { cin>>n; cout<<a[n-1]<<endl; } return 0;}及其简单的dp,先打表节约时间。 阅读全文
posted @ 2012-11-08 18:42 茉莉花茶 阅读(129) 评论(0) 推荐(0)
摘要: #include <iostream>using namespace std;int main() { int a,b,c=1; while(cin>>a>>b) { if(a==0&&b==0) break; for(int i=0;i<b;i++) { c=a*c; if(c>999) c=c%1000; } cout<<c<<endl; c=1; } return 0;}简单题啊。。。。。。。结果我硬把这题当1042写了。。。可惜w... 阅读全文
posted @ 2012-11-07 19:57 茉莉花茶 阅读(148) 评论(0) 推荐(0)
摘要: 本文根据经典的TC教程完善和改编。TopCoder:http://www.topcoder.com/基本规则TopCoder的比赛类型很多,最常见的是周赛SRM(Single Round Match),另外还有TCHS SRM(TopCoder High School SRM,题目和SRM一样,仅限中学生参加,参赛者水平较低,据说涨rating很容易),马拉松(Marathon Matchs),还有TCOpen(每年两次的大比赛)之类的比赛。因为大多数人都在做SRM,所以本文介绍的TC比赛即为SRM。SRM的规则总结起来就是一句话:75分钟做完3道难度递增的题。TC的每个用户(handle)都 阅读全文
posted @ 2012-11-07 12:54 茉莉花茶 阅读(260) 评论(0) 推荐(0)
摘要: #include <iostream>#include<string>using namespace std;int main() { string str; int p,m,d,day,y; int month[]={0,31,28,31,30,31,30,31,31,30,31,30,31}; while(cin>>str) { p=0;y=0; int length =str.size(); for(int i=0;i <length;i++) { if(str[i+1]=='/'... 阅读全文
posted @ 2012-11-06 21:01 茉莉花茶 阅读(211) 评论(0) 推荐(0)
摘要: #include <iostream>using namespace std;int main() { char a,b,c,t1,t2,t3; while(cin>>a>>b>>c) { if(c<min(a,b)) t1=c; else { t1=min(a,b); if(a>b) t2=a; else t2=b; } if(c>max(a,b)) t3=c; else ... 阅读全文
posted @ 2012-11-06 18:54 茉莉花茶 阅读(249) 评论(0) 推荐(0)
摘要: #include <iostream>#include<cmath> #include <iomanip>using namespace std;int main() { float x1,x2,y1,y2,count; while(cin >> x1>>y1>>x2>> y2) { count = sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2)); cout <<setprecision(2) << setiosflags(ios::fixed | ios:: 阅读全文
posted @ 2012-11-06 14:59 茉莉花茶 阅读(150) 评论(0) 推荐(0)