#include <stdio.h>
#include <stdlib.h>
int a,d;
int main(){
int i, n, s=0;
scanf("%d %d %d",&a, &d, &n);
for(i=1; i<=n; i++)
s+=a+(i-1)*d;
printf("s=%d\n",s);
return(0);
} |
|
#include <stdio.h>
#include <stdlib.h>
int a,d; //办┦跑计兜 a,そ畉 d
int sum(int n){
if(n==1)
return(a);
else
return(a+(n-1)*d+sum(n-1));
}
int main(){
int s, n;
scanf("%d %d %d",&a, &d, &n);
s=sum(n);
printf("s=%d\n", s);
return(0);
} |