#include<stdio.h>
int main () {
int n; long long a[50000] = {0},b[50000] = {0};
a[1] = 1; b[1] = 1;
while(scanf("%d",&n) != EOF){
for(int i = 1; i <= n; i++) {
if(i == 1) {
a[i] = 1,b[i] = 1;
} else {
a[i] = 0,b[i] =0;
}
if(n == 1) {
printf("%lli %lli\n",a[n],b[n]);
break;
}
for(int j = 1; j <= i; j++) {
a[i] += j;
}
if(i > 1) {
b[i] = a[i] + b[i-1];
}
}
if(n != 1)
printf("%lli %lli\n",a[n],b[n]);
}
return 0;
}
使用long long 注意印出是用%lli
注意n=1時直接印出
a[i]就是1+2+3+4....i