上一页 1 ··· 3 4 5 6 7 8 9 10 下一页

2014年2月26日

摘要: 原题链接题目大意:给出一个格子图,求走完所有节点的最短路径距离。解法:简单啊,如果都是奇数,可以走一次斜边,其他情况就是长*宽。参考代码:#include int main(){ int i,k,m,n; double result; scanf("%d",&k); i=1; while(i<=k){ scanf("%d%d",&m,&n); printf("Scenario #%d:\n",i); if(m%2==0||n%2==0){ result = m*n; printf("%.2f\n 阅读全文
posted @ 2014-02-26 13:57 KK4SBB 阅读(241) 评论(0) 推荐(0) 编辑
 
摘要: /*You may have heard of the book '2001 - A Space Odyssey' by Arthur C. Clarke, or the film of the same name by Stanley Kubrick. In it a spaceship is sent from Earth to Saturn. The crew is put into stasis for the long flight, only two men are awake, and the ship is controlled by the intellige 阅读全文
posted @ 2014-02-26 13:56 KK4SBB 阅读(225) 评论(0) 推荐(0) 编辑
 
摘要: 原题链接题目大意:某人手上有一大批钻石,他同时有一些盒子恰好放下这些钻石,每个盒子可以放一个或多个,问一共有几种方法。解法:这其实是一道排列与组合计算题,主要是写出组合算法的代码,把计算公式转为程序。参考代码:#include#include#include#includeusing namespace std;int fact(int a){ //recursive factorial function if(a==1) return a; else return a*fact(a-1);}int main(){ int i,j,k,m,n,c,c1,c2,sum,ans; int num. 阅读全文
posted @ 2014-02-26 13:56 KK4SBB 阅读(222) 评论(0) 推荐(0) 编辑
 
摘要: 原题链接题目大意:给出一列数据,不多于30个。如果其中的两个或多个数之和等于这组数据中的另一个数,如{1,2,3}这个数组中存在等式1+2=3,输出这个等式。找出满足条件的所有等式。如果,找不到符合条件的,输出“Can’t find any equations.”。解法:把这个数组的所有数字排序。首先,从小到大开始累加数字,直到和超过数组的最大值,这样我们可以知道,等式左边最多可以有几个数字。然后,从两个加数开始,用深度优先的方法,从左往右搜索,寻找是否存在满足条件的等式。依次递增搜索的深度。参考代码://参考了这篇日志http://blog.csdn.net/scnu_jiechao/art 阅读全文
posted @ 2014-02-26 13:56 KK4SBB 阅读(475) 评论(0) 推荐(0) 编辑
 
摘要: 原题链接题目大意:1/2+1/4+1/6+…1/n解法:直接累加即可。参考代码:#includeint main(){ printf("# Cards Overhang\n"); double extend; int n,i; while(scanf("%d",&n)!=EOF){ extend=0.5; for(i=1;i<n;i++) extend+=0.5/(i+1); printf("%5d%10.3lf\n",n,extend); } return 0;} 阅读全文
posted @ 2014-02-26 13:56 KK4SBB 阅读(179) 评论(0) 推荐(0) 编辑
 
摘要: 原题链接题目大意:大数,20进制的加法计算。解法:convert函数把字符串转换成数组,add函数把两个大数相加。参考代码:#include#includechar* Digit="0123456789abcdefghij";void convert(char*,int*);void add(int*,int*,int*);void print(int*);int main(){ char str1[101],str2[101]; while(scanf("%s",str1)!=EOF&&scanf("%s",str2 阅读全文
posted @ 2014-02-26 13:56 KK4SBB 阅读(359) 评论(0) 推荐(0) 编辑
 
摘要: 原题链接题目大意:给一个数组{ A1,A2,…,An } ,要求生成另一个数组B1,B2,…,Bn,使得Bi表示的是在数组A中排在i前面大于i的数字的个数。题目的输入是数组A(字母P表示)或者数组B(字母I表示),要求输出对应的B或者A。解法:先读取首字母,如果是P,则调用permutation(),反之调用inversion()。permutation是按照正常方法寻找。inverse是先设置一个空的数组(相当于A数组),按照B数组的顺序一个个往‘A’中放。参考代码:#includeusing namespace std;void permutation();void inversion() 阅读全文
posted @ 2014-02-26 13:56 KK4SBB 阅读(362) 评论(0) 推荐(0) 编辑
 
摘要: 原题链接题目大意:有这么一个公式 A,B,C(A using namespace std; int dp[5050][1010]; #define maxn 1>ncase; while(ncase--) { cin>>guests>>chopsticks; for(i = chopsticks;i >= 1;i--) cin>>a[i]; for(i = 1;i = j * 3) { dp[i][j] = dp[i - 1][j]; ... 阅读全文
posted @ 2014-02-26 13:55 KK4SBB 阅读(533) 评论(0) 推荐(0) 编辑
 
摘要: /*In this problems, we’ll talk about BIG numbers. Yes, I’m sorry, big numbers again…. Let N be a positive integer, we call S=NN the “big big power” of N. In this time, I will calculate the exact value of S for a positive integer N. Then, I tell you S, you guess N.Note that I may make mistakes in cal 阅读全文
posted @ 2014-02-26 13:55 KK4SBB 阅读(221) 评论(0) 推荐(0) 编辑
 
摘要: /*In the early nineties, the World Wide Web (WWW) was invented. Nowadays, most people think that the WWW simply consists of all the pretty (or not so pretty) HTML-pages that you can read with your WWW browser. But back then, one of the main intentions behind the design of the WWW was to unify severa 阅读全文
posted @ 2014-02-26 13:54 KK4SBB 阅读(341) 评论(0) 推荐(0) 编辑
上一页 1 ··· 3 4 5 6 7 8 9 10 下一页