fork download
  1. #include <stdio.h>
  2. int main(void)
  3. {
  4. int m, n, i, j, sum, x;
  5. printf("1^m + 2^m + 3^m + ... + n^m を求める\n");
  6. printf("m=");scanf("%d", &m);
  7. printf("n=");scanf("%d", &n);
  8. sum = 0;
  9. for (i = 1; i <= n; i++) {
  10. for (x = j = 1; j <= m; j++) {
  11. x *= i;
  12. }
  13. sum += x;
  14. }
  15. printf("%d\n", sum);
  16. return 0;
  17. }
  18.  
Success #stdin #stdout 0s 2252KB
stdin
3
4
stdout
1^m + 2^m + 3^m + ... + n^m を求める
m=n=100