原题链接:http://www.acm.uestc.edu.cn/problem.php?pid=1735
考试松松过
1 #include<cstdio> 2 using namespace std; 3 int main() 4 { 5 long long n,product;int ans[20]; 6 while(scanf("%lld",&n)!=EOF) 7 { 8 product=(n+1)*(3*n+2)/2; 9 int i=0; 10 while(product) 11 { 12 ans[i++]=product%10; 13 product/=10; 14 } 15 for(int j=i-1;j>=0;j--) 16 printf("%d",ans[j]); 17 printf("\n"); 18 } 19 return 0; 20 } 21