zrq495
www.zrq495.com
摘要: 代码: 1 #include<iostream> 2 3 using namespace std; 4 5 long long comb(long long m, long long n) 6 { 7 long long s=1; 8 m=n-m>m?m:n-m; 9 long long k=1, i;10 for (i=0; i<m; i++)11 {12 s*=n-i;13 while(k <=m && s%k==0)14 {15 s/=k;16 k+... 阅读全文
posted @ 2012-07-31 13:59 zrq495 阅读(266) 评论(0) 推荐(0) 编辑
摘要: 差不多懂了,解析过程别人写了,代码自己写的。在正整数n的所有不同划分中,将最大加数n1不大于m的划分个数记为q(n,m)。可以建立q(n,m)的如下递归关系:<1> q(n,m) = 1, n >= 1当最大加数n1不大于1时,任何正整数n只有一种划分形式,n = 1 + 1 + 1 +...+ 1<2> q(n,m) = q(n,n), m >= n最大加数n1实际上不能大于n<3> q(n,n) = 1 + q(n,n - 1)正整数n的划分由n1 = n的划分和n1 < n - 1的划分组成<4> q(n,m) = q(n 阅读全文
posted @ 2012-07-31 11:40 zrq495 阅读(219) 评论(0) 推荐(0) 编辑
摘要: 给出一个数列ci(1<=ci<=n),然后给出数列ai中的a0和a(n+1),并给出一个公式ai = ( a(i-1) + a(i+1) ) / 2 - ci。求a1。做了很长时间,也没弄对,最后看的别人的解题报告。。。。。由给出公式得:2ai = a(i-1) + a(i+1) -2ci ,依次使i=1,2......n,写出n个式子,把它们相加,得到:a1 + an = a0 + a - 2(c1 + …… + cn), 再使c的下标i=1......n,写出n个式子,把他们相加。得到:(n + 1)a1 = na0 + an+1 - 2(nc1 + (n-1)c2 + (n- 阅读全文
posted @ 2012-07-29 19:36 zrq495 阅读(373) 评论(0) 推荐(0) 编辑
摘要: 没啥好说的,输入n,m,输出 n*m-1。。。代码: 1 #include<iostream> 2 3 using namespace std; 4 5 int main() 6 { 7 int n, m; 8 while(cin >> n >> m) 9 cout << n*m-1<< endl;10 return 0;11 } 阅读全文
posted @ 2012-07-28 16:03 zrq495 阅读(163) 评论(2) 推荐(0) 编辑
摘要: m! <= 2^n ,求最大的m;两边同时取对数。 1 #include<iostream> 2 #include<cmath> 3 4 using namespace std; 5 6 int f[21]; 7 8 int main() 9 {10 int n, i, j, k;11 double sum=0;12 for (i=0, j=0, k=4; i<21; i++, k*=2)13 {14 for (j++; ; j++)15 {16 sum+=log10((double)j);17 ... 阅读全文
posted @ 2012-07-28 09:56 zrq495 阅读(170) 评论(0) 推荐(0) 编辑
摘要: 令q(x)=bmX^m+bm-1X^(m-1)+...b1X+b0,展开 q(x) * (x-k) = X^(m+1)+[-Kbm+b(m-1)]X^m+...(K+b0)x+K。相同次数的项的系数相等,所以推出 b(m-1)=k*bm+a[n-1], r=k*b0+a[0]。代码如下: 1 #include<iostream> 2 #include<cstdio> 3 4 using namespace std; 5 6 int main() 7 { 8 int n, p[10010], q[10010], i, k; 9 while (cin >> k) 阅读全文
posted @ 2012-07-27 17:25 zrq495 阅读(138) 评论(0) 推荐(0) 编辑
摘要: 求n*m的网格中有多少九宫格,公式:(n/3)*(m/3)。代码: 1 #include<iostream> 2 3 using namespace std; 4 5 int main() 6 { 7 int n, m; 8 int t; 9 cin >> t;10 while(t--)11 {12 cin >> n >> m;13 cout << (n/3)*(m/3) << endl;14 }15 return 0;16 } 阅读全文
posted @ 2012-07-27 15:34 zrq495 阅读(168) 评论(0) 推荐(0) 编辑
摘要: Problem DescriptionOld contest software uses bubble sort for generating final standings. But now, there are too many teams and that software works too slow. You are asked to write a program, which generates exactly the same final standings as old software, but fast.InputThe first line of input conta 阅读全文
posted @ 2012-07-27 14:49 zrq495 阅读(181) 评论(0) 推荐(0) 编辑
摘要: 大数加法 + 打表。代码: 1 #include<iostream> 2 #include<cstring> 3 #include<cstdlib> 4 #include<cstdio> 5 6 using namespace std; 7 8 struct node 9 {10 char s[1000];11 };12 13 int main()14 {15 struct node f[1001];16 int i, j, l, n, m;17 int a[1000], b[1000], r[1000];18 int alen, blen, l 阅读全文
posted @ 2012-07-27 14:33 zrq495 阅读(209) 评论(0) 推荐(0) 编辑
摘要: 固定下面的个数,依次增加上面点的个数,公式:n*(n-1)*m*(m-1)/4 。代码: 1 #include<iostream> 2 3 using namespace std; 4 5 int main() 6 { 7 long long int n, m, c=1; 8 while(cin >> n >> m, n||m) 9 cout << "Case " << c++ << ": " << n*(n-1)*m*(m-1)/4 << endl;10 r 阅读全文
posted @ 2012-07-26 20:54 zrq495 阅读(202) 评论(0) 推荐(0) 编辑
摘要: 球的表面积 :4*π*r*r, 分割后多出的面积 :n*π*r*r,利润 :25*n % 。当n=1时, 利润:0%。 1 #include<iostream> 2 3 using namespace std; 4 5 int main() 6 { 7 long long n; 8 while(cin >> n, n>0) 9 {10 if (n == 1) cout << "0%" << endl;11 else cout << 25*n << "%" << en 阅读全文
posted @ 2012-07-26 19:24 zrq495 阅读(193) 评论(0) 推荐(0) 编辑
摘要: 最小步数 距离 0 01 12 23 44 65 96 12代码: 1 #include<iostream> 2 #include<cmath> 3 4 using namespace std; 5 6 int main() 7 { 8 int T, n, m; 9 int dis, step;10 cin >> T;11 while(T--)12 {13 cin >> n >> m;14 dis=m-n;15 if (dis == ... 阅读全文
posted @ 2012-07-26 17:10 zrq495 阅读(268) 评论(0) 推荐(0) 编辑
摘要: 蜗牛,白天向上爬,晚上向下滑,还有疲劳(常数)。蜗牛不能向下爬,所以蜗牛爬行的距离不能是负数。代码: 1 #include<iostream> 2 3 using namespace std; 4 5 int main() 6 { 7 int flag, day; 8 double h, u, d, p, t; 9 while(cin >> h >> u >> d >> p, h)10 {11 day=0;12 flag=0;13 t=0;14 p=p*u*1.0/100;15 ... 阅读全文
posted @ 2012-07-26 14:52 zrq495 阅读(326) 评论(0) 推荐(0) 编辑
摘要: 注:本文转自 http://developer.51cto.com/art/200509/3578.htmC、传统 C++#include <assert.h>//设定插入点#include <ctype.h> //字符处理#include <errno.h> //定义错误码#include <float.h> //浮点数处理#include <fstream.h> //文件输入/输出#include <iomanip.h> //参数化输入/输出#include <iostream.h> //数据流输入/输出# 阅读全文
posted @ 2012-07-25 19:23 zrq495 阅读(139) 评论(0) 推荐(0) 编辑
摘要: 大数加法。注意:输入100000输出0代码如下: 1 #include<iostream> 2 #include<cstring> 3 using namespace std; 4 int main() 5 { 6 int T, i; 7 char a[1000]; 8 int sum[1000], b[1000]; 9 cin >> T;10 while(T--)11 {12 memset(a, 0, sizeof(a));13 ... 阅读全文
posted @ 2012-07-25 18:41 zrq495 阅读(296) 评论(0) 推荐(0) 编辑