zznu 1052 前n项和】的更多相关文章

这算是循环的入门题目了,因为n 是小于 10 的非负数,所以可以知道结果不过超出int范围. 等式左边的数每次自增一个a,可以用一个变量来表示 na = na * 10 + a, 意思就是每循环一次就在最后面添加一个a; 代码比较简单如下: , na=; ; i<=n; i++)      {          na = na *  + a;          sum += na;      }        printf(       ;  }…
A - Farey Sequence Time Limit:1000MS     Memory Limit:65536KB     64bit IO Format:%I64d & %I64u Submit Status Practice POJ 2478 Description The Farey Sequence Fn for any integer n with n >= 2 is the set of irreducible rational numbers a/b with 0 &l…
求分数序列前N项和 #include <stdio.h> int main() { int i, n; double numerator, denominator, item, sum, swap; while (scanf("%d", &n) != EOF) { numerator = 2; denominator = 1; item = 0; sum = 0; for (i = 1; i <= n; i++) { item = numerator/deno…
求阶乘序列前N项和 #include <stdio.h> double fact(int n); int main() { int i, n; double item, sum; while (scanf("%d", &n) != EOF) { sum = 0; if (n <= 12) { for (i = 1; i <= n; i++) { item = fact(i); sum = sum + item; } } printf("%.0f…
求平方根序列前N项和 #include <stdio.h> #include <math.h> int main() { int i, n; double item, sum; while (scanf("%d", &n) != EOF) { sum = 0; for (i = 1; i <= n; i++) { item = sqrt(i); sum = sum+item; } printf("sum = %.2f\n", s…
求交错序列前N项和 #include <stdio.h> int main() { int numerator, denominator, flag, i, n; double item, sum; while (scanf("%d", &n) != EOF) { flag = 1; numerator = 1; denominator = 1; sum = 0; for (i = 1; i <= n; i++) { item = flag*1.0*numer…
求简单交错序列前N项和 #include <stdio.h> int main() { int denominator, flag, i, n; double item, sum; while (scanf("%d", &n) != EOF) { flag = 1; denominator = 1; sum = 0; for (i = 1; i <= n; i++) { item = flag*1.0/denominator; sum = sum+item;…
求奇数分之一序列前N项和 #include <stdio.h> int main() { int denominator, i, n; double item, sum; while (scanf("%d", &n) != EOF) { denominator = 1; sum = 0; for (i = 1; i <= n; i++) { item = 1.0/denominator; sum = sum+item; denominator = denomi…
求N分之一序列前N项和 #include <stdio.h> int main() { int i, n; double item, sum; while (scanf("%d", &n) != EOF) { sum = 0; for (i = 1; i <= n; i++) { item = 1.0/i; sum = sum+item; } printf("sum = %f\n", sum); } return 0; }…
/*====================================================================== 著名的菲波拉契(Fibonacci)数列,其第一项为0,第二项为1,从第三项开始, 其每一项都是前两项的和.编程求出该数列前N项数据. 注意: Fibonacci数列的递归是“双线”递归,可以画出类似树形结构的递归树. 它不是纯粹的“单线”递归然后再“单线”回溯. 所以,这个题目的没有办法像“输出十进制数的二进制表示”这样,在递归函数的递归阶段或者回溯…