#include "stdio.h" #include "malloc.h" #include "math.h" void calc(int num,int N,long *data); int main() { int N,num; long *result; scanf("%d",&num); scanf("%d",&N); result=(long *)malloc(N*sizeof(long)); calc(num,N,result); return 0; } void calc(int num,int N,long *data) { long i=0; long val=0; long dif; int j; if(num<=0||N<=0) { printf("0"); return; } for(i=0;i<N||val>0;i++) { val=val+num*(N-i); dif=val%10; data[i]=dif; val=(val-dif)/10; } for(j=i-1;j>=0;j--) { printf("%ld",data[j]); } }
时间: 2024-10-12 11:05:27