#include <stdio.h> int main() { int a, b; while (scanf("%d %d", &a, &b) != EOF) { int n[200]={0},k=0,carry=0; for(int i=b;i>0;i--){ int reminder=a*i+carry; n[k++]=reminder%10; carry=reminder/10; } while(carry){ n[k++]=carry%10; carry=carry/10; } for(int i=k-1;i>=0;i--) printf("%d",n[i]); printf("\n"); } return 0; }
#include <stdio.h> #include <stdlib.h> int main() { int a,n, carry = 0, carryf = 0; scanf("%d%d",&a,&n); int *num = (int *)malloc(sizeof(int) * (n+1)); for(int i = 1; i <= n; i++){ int tmp; if(carryf) tmp = a * (n - i + 1) + carry; else tmp = a * (n - i + 1); if(tmp >= 10){ carryf = 1; num[i] = tmp % 10; carry = tmp / 10; }else{ carryf = 0; num[i] = tmp % 10; } } for(int i = n; i >= 1; i--) printf("%d", num[i]); return 0; }
#include <stdio.h> #define N 1000 int main() { int a, n; while (scanf("%d%d", &a, &n)!=EOF) { int s[N] = {0}, carry = 0, i; for (i = 0; i < n; i ++) { int t = (n-i)*a+carry; s[i] = t%10; carry = t/10; } while (carry>0) { s[i] = carry%10; carry/=10; i ++; } i --; while (i>=0) { printf("%d", s[i--]); } printf("\n"); } return 0; }