[PAT]数列求和(20)

#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 ;
}
void calc(int num,int N,long *data)
{
long i=;
long val=;
long dif;
int j;
if(num<=||N<=)
{
printf("");
return;
}
for(i=;i<N||val>;i++)
{
val=val+num*(N-i);
dif=val%;
data[i]=dif;
val=(val-dif)/;
}
for(j=i-;j>=;j--)
{
printf("%ld",data[j]);
}
}
上一篇:POJ3687 Labeling Balls(拓扑)


下一篇:Net线程池设计