题目1051:数字阶梯求和
#include<cstdio>
#include<iostream>
#include<cstring>
#include<algorithm>
using namespace std;
int a,n;
char ans[110];
int main() {
ans[109] = 0;
while(scanf("%d %d", &a, &n) != EOF){
int last = 108,jin = 0,tmp;
while(n){
tmp = a*n + jin;
ans[last] = tmp % 10 + '0';
jin = tmp /10;
last--;n--;}
if(jin > 0) ans[last--] = jin + '0';
printf("%s\n", ans+last+1);
}
return 0;
}
/**************************************************************
Problem: 1051
User: th是个小屁孩
Language: C++
Result: Accepted
Time:0 ms
Memory:1520 kb
****************************************************************/