The main problem is to find the law, the first time to find out! ~~
The topic is to ask for a number of digital root, this so-called digital root is a number of the sum of the numbers, if the number of double digits, repeat the digital root, until the number is a number.
This problem is to seek n^n 's digital root.
The rules are as follows:
The result of N-n multiplication is assumed to be the multiplication of the digital root of s,s, which is equal to the number of n digital root.
The following is the AC code, very simple:
#include <iostream>using namespace Std;int main () {int I, J, N;while (Cin >> N, N) {j = n;int M;while (J >= 10) //For digital root{m of n for input = 0;while (j) {m + = j% 10;j/= 10;} j = m;} m = j;for (i = 1; i < n; i++) //Cyclic n-1 Solution {j = J * M;int K;while (J >=) {k = 0;while (j) {k + = j% 10;j/= 10;} j = k;}} cout << J << Endl;} return 0;}
Hangzhou Electric Acm1163--eddy ' s digital Roots