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> 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; }…