摘要: View Code #include <iostream>#include<string> using namespace std; int rec[25]; int main() { int a, b, n; rec[0] = rec[1] = rec[2] = 1; while( cin>>a>>b>>n&&a | b | n ) { int beg, end, flag = 0; for( int i = 3; i <= n && !flag; ++i ) { rec[i] = (... 阅读全文
posted @ 2013-04-02 20:44 90后程序媛 阅读(270) 评论(0) 推荐(0) 编辑
摘要: View Code #include<iostream>#include<cmath>using namespace std;int main(){ int ncase,ans;long long t; cin>>ncase; while(ncase--) { cin>>t;ans=0; while(t){ans++;t=t/2;} cout<<ans<<endl; } return 0;}题目大意:给定n个javabeans,每个box中分别有(1 2 3...n)个javabeans 。每次减去一个x。必须是大于... 阅读全文
posted @ 2013-04-02 20:23 90后程序媛 阅读(175) 评论(0) 推荐(0) 编辑
摘要: http://acm.hdu.edu.cn/showproblem.php?pid=1262分析:本题需要找最相近的两个素数的和等于给我们的偶数。首先,判断素数的方法用一个函数,用到cmath的头文件另外,要找到最相近的两个素数,就从偶数的一半上下分别加减i;主程序中调用了函数,来输出素数。View Code #include <iostream>#include<cmath>using namespace std;int prime(int n){int j,k,flag; flag=1; k=sqrt(n); for(j=2;j<=k;j++) {if(n%j 阅读全文
posted @ 2013-04-02 20:04 90后程序媛 阅读(300) 评论(0) 推荐(0) 编辑
摘要: http://acm.hdu.edu.cn/showproblem.php?pid=1161本题主要运用的就是大小写的转换;我写的代码:#include<iostream>#include <string>#include <ctype.h>using namespace std;int main(int argc, char *argv[]){ string a; char c; while( getline(cin,a)){ for(int i=0;i<a.length();i++) { c=a[i]; if(isupper(c)) c=tolow 阅读全文
posted @ 2013-04-02 19:40 90后程序媛 阅读(296) 评论(0) 推荐(0) 编辑
摘要: http://acm.hdu.edu.cn/showproblem.php?pid=1008#include <iostream>using namespace std;int main(int argc, char *argv[]){ int n; int a; while(cin>>n) { if(n>0) { int i=0; int s=0; while(n--) { cin>>a; if(i<a) { s+=6*(a-i); s+=5; i=a; } else { s+=4*(i-a); s+=5; i=a; } } cout<& 阅读全文
posted @ 2013-04-02 11:24 90后程序媛 阅读(130) 评论(0) 推荐(0) 编辑
摘要: http://acm.hdu.edu.cn/showproblem.php?pid=1004本题的主要让我们做的就是在输入的几种颜色中输出颜色最多的那种颜色。c++代码:#include <iostream>#include <string>using namespace std;struct{ string color; int num;}b[1001];int main(){ int max,maxind,i,n; string str; while(cin>>n && n) { for(i=0;i<=n;i++){b[i].col 阅读全文
posted @ 2013-04-02 11:19 90后程序媛 阅读(144) 评论(0) 推荐(0) 编辑
摘要: fromtjubbs作者cnhawk时间WedJul1917:07:502006前天晚上回去,本想敲几个代码,又怕吵醒宿舍里睡觉的同学,只好到各校的BBS上去逛逛,于是看到了下面两张图。这两张图都是AlexanderYi发的,我也不清楚他叫什么名字只知道他是dwyak的队友。dwyak我知道,真名戴文渊,上海交大ACM-ICPC代表队队员、队长、教练,先后获得2004年第29届ACM国际大学生程序设计竞赛亚洲区预选赛台北赛区冠军、日本赛区冠军,2005年第29届ACM国际大学生程序设计竞赛全球总决赛冠军。牛吧?第一张图:AlexanderYi做的题。他的注释:我有个习惯,收集做过的卷子。今天整 阅读全文
posted @ 2013-04-02 11:12 90后程序媛 阅读(220) 评论(0) 推荐(0) 编辑