[1085]a+aa+aaa+aa...a

Description
输入一个正整数 repeat (0<’repeat<10),做repeat 次下列运算:
输入 2 个正整数a (0<’a<10)和n(0<’n<10), 求a+aa+aaa+aa⋯a(n 个a)之和。
Input
见sample

Output
见sample

Sample Input
1
2 3
Sample Output
246

#include
int main()
{
    int repeat;
    int aa,a,b,ib,i;
    long long ret=0,tep;
    char ch;
    scanf("%d",&repeat);
    getchar();
    for(int aa=0;aascanf("%d%d",&a,&b);
        for(ib=1;ib1;ib++)
        {
            tep=0;
            for(i=0;i10*tep+a;
            }
            ret=ret+tep;
        }
        printf("%lld\n",ret);
        ret=0;
    }
    return 0;
} 

这题用了数学里一个很神的方法:拼接数位a,b:c=10a+b.这样求得a,aa…a,相加用long long接受并输出

你可能感兴趣的:([1085]a+aa+aaa+aa...a)