![](https://img-blog.csdnimg.cn/20201014180756925.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
算法竞赛入门经典---刘汝佳
文章平均质量分 82
校园苦行生
这个作者很懒,什么都没留下…
展开
-
阶乘之和
输入n,计算S=1!+2!+3!+...+n!的末6位(不含前导0)。n样例输入:10样例输出:37913#include#includeint main(){ const int MOD=1000000; int n,i,j; freopen("a.txt","r",stdin); freopen("b.txt","w",stdout); while(scanf("%d原创 2013-04-07 20:12:36 · 584 阅读 · 0 评论 -
习题 2-10 排列(permutation)
用1,2,3...,9组成3个三位数abc,def,ghi,每个数字恰好使用一次,要求abc:def:ghi=1:2:3.输出所有解。#include#includeint flag[10];int repeat(int n){ while(n>0){ int a=n%10; if(++flag[a]>1||a==0) return 0; n/=10; } ret原创 2013-04-10 19:55:42 · 525 阅读 · 0 评论 -
习题2-9 分数化小数
输入正整数a,b,c输出啊a/b的小数形式,精确到小数点后c位。a,b分析了某个人的代码,他先是分别用两个变量储存a/b,a%b,然后用a%b乘c+1次10,依次保存,然后分析c+1位是否大于5,做四舍五入。实在想不出来此也不免是个办法。我们可以根据printf("%.*lf",m,n)(m控制精度,n为输出);函数的特性:#includeint main(){ int a,b原创 2013-04-10 19:33:34 · 622 阅读 · 0 评论 -
最长回文字串
例题3-4 回文串输入一个字符串,求出其中最长的回文字串。字串的含义是:在原串中连续出现的字符串片段。回文的含义是:正着看和倒着看相同,如abba和xyyx。在判断时,应该忽略所以标点符号和空格,且忽略大小写,但输出应保持原样(在回文的首位和尾部不要输出多余字符)。输入字符串长度不超过5000,且占据单独一行。应该输出最长的回文串,如果有多个,输出起始位置最靠右的。样例输入:Confuc原创 2013-04-11 17:15:48 · 576 阅读 · 0 评论 -
生成全排列
1、生成1~n的全排列#include using namespace std;void list(int n,int *a,int cur){ if(n==cur) { for(int i=0;i<n;i++) cout<<a[i]<<" "; cout<<endl; } else for(int i=1;i<=n;i++) { int ok=1原创 2013-05-06 21:08:37 · 416 阅读 · 0 评论 -
Rails
Poj1363:RailsDescriptionThere is a famous railway station in PopPush City. Country there is incredibly hilly. The station was built in last century. Unfortunately, funds were extre原创 2013-07-20 19:45:25 · 389 阅读 · 0 评论 -
Tree Recovery
Poj2255:Tree RecoveryDescriptionLittle Valentine liked playing with binary trees very much. Her favorite game was constructing randomly looking binary trees with capital letters in原创 2013-07-20 13:53:13 · 470 阅读 · 0 评论