题意:对于任意两个正整数a,b(0<=a,b<10000)计算ab各位数字的和的各位数字的和的各位数字的和的各位数字的和。,数论mod 9的应用,求一个数各个位数的和
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
using namespace std;
const int MAXN = 10005;
int a,b;
int main(){
while (scanf("%d%d",&a,&b) != EOF && a+b){
int ans = 1;
for (int i = 0; i < b; i++)
ans = (ans * a) % 9;
if (ans == 0)
printf("9\n");
else printf("%d\n",ans);
}
return 0;
}