摘要: 问题:In many applications very large integers numbers are required. Some of these applications are using keys for secure transmission of data, encryptio... 阅读全文
posted @ 2015-05-26 08:54 chaoer 阅读(366) 评论(0) 推荐(0)
摘要: 问题:给定一个整数N,那么N的阶乘N!末尾有多少个0? 比如:N=10,N!=3628800,N!的末尾有2个0,写出算法。回答:int countZero(int N) { int ans = 0; int maxInt = 1000000000;//10^9 int tmpn = N; whil... 阅读全文
posted @ 2015-05-25 09:10 chaoer 阅读(408) 评论(0) 推荐(0)
摘要: 问题:在25匹马中,挑选最快的三匹马,每场比赛最多只能有5匹马一起参赛。请问最少需要进行多少场比赛?回答:至少需要进行7场比赛。给25匹马编号:A1 A2 A3 A4 A5 B1 B2 B3 B4 B5C1 C2 C3 C4 C5 D1 D2 D3 D4 D5E1 E2 E3 E4 E5按照A1-A... 阅读全文
posted @ 2015-05-25 08:37 chaoer 阅读(181) 评论(0) 推荐(0)
摘要: 问题:Tetris (Russian: Тeтрис) is a puzzle video game originally designed and programmed by Alexey Pajitnov in the Soviet Union. The Tetris game is a pop... 阅读全文
posted @ 2015-05-25 08:17 chaoer 阅读(806) 评论(0) 推荐(0)
摘要: 问题:打印出杨辉三角形的前n行(nint main() { int n; scanf("%d",&n); int arr[25][25]; int i,j; //计算每一行的值 arr[1][1] = 1; for( i=2; i<=20; i++){ arr[i][1] = arr[i][i] ... 阅读全文
posted @ 2015-05-24 08:46 chaoer 阅读(235) 评论(0) 推荐(0)
摘要: 问题:Write a program to solve a Sudoku puzzle by filling the empty cells.Empty cells are indicated by the character '.'.You may assume that there will b... 阅读全文
posted @ 2015-05-24 08:37 chaoer 阅读(200) 评论(0) 推荐(0)
摘要: 问题:输入一个正整数(<10000),输出颠倒后的整数。【样例输入】1234【样例输出】4321回答:#include int main(){ int num ; scanf("%d",&num); int x,y,z,n,result; if(num > 999) { x = num / 1000... 阅读全文
posted @ 2015-05-23 10:40 chaoer 阅读(253) 评论(0) 推荐(0)
摘要: 问题:InputThe first line of input contains a single integer P, (1 ≤ P ≤ 1000), which is the number of data sets that follow. Each data set consists of a... 阅读全文
posted @ 2015-05-23 10:27 chaoer 阅读(207) 评论(0) 推荐(0)
摘要: 问题:有一扇门, 一开始是好的, 一次来了n个人, 每个人有p的概率把门弄坏, 维修门的费用为a, 被一个人发现门坏的罚款为b, 求期望最小花费。回答:用f[i][0]表示第i个人来之前门坏, 到结束时的期望最小花费, f[i][1]则表示门好. 显然f[n][0] = min(a, b), f[n... 阅读全文
posted @ 2015-05-22 08:47 chaoer 阅读(156) 评论(0) 推荐(0)
摘要: 问题:设有n 个程序{1,2,…, n }要存放在长度为L的磁带上。程序i存放在磁带上的长度是i l , 1 ≤i ≤n。程序存储问题要求确定这n 个程序在磁带上的一个存储方案,使得能够在磁带上存储尽可能多的程序。对于给定的n个程序存放在磁带上的长度,编程计算磁带上最多可以存储的程序数。回答:题目要... 阅读全文
posted @ 2015-05-22 08:27 chaoer 阅读(570) 评论(0) 推荐(0)