探测描述
thedigitalrootofapositiveintegerisfoundbysummingthedigitsoftheinteger.iftheresultingvalueisasingledigitthentdigitisthed igisthed uecontainstwoormoredigits,thosedigitsaresummedandtheprocessis
repeated.thisiscontinuedaslongasnecessarytoobtainasingledigit。
For example,considerthepositiveinteger 24.adding the2and the4yieldsavalueof6. since6isasingledigit, 6 isthedigitalrootof 24.nowconsiderthepositiveinteger 39.adding the3and the9 yields 12.since 12 isnotasingledigit,the process
must be repeated.adding the1 and the2yeilds 3,asingledigitandalsothedigitalrootof 39。
the eddy‘seasyproblemisthat : giveyouthen,wantyoutofindthen ^ n‘s数字路由。
输入输出
theinputfilewillcontainalistofpositiveintegersn,oneperline.theendoftheinputwillbeindicatedbyanintegervalueofzero.notice 33
输出
outputn ^ n‘sdigitalrootonaseparatelineoftheoutput。
样本输入
2
4
0
样本输出
4
4
亚瑟
埃迪迪
/* * * * * * * * * * * * * * * *
是看到FFT头晕了,还是不知道? 然后,回头想刷水问题,寻找快感,没想到撞到了一个小炸弹。
使用九多条定理,不知道这个定理确实很难做……
九馀定理简介:一个数n的各位数字之和对9取馀,和这个数对9取馀一样。
有个洞。 请记住。 以后别忘了……
* * * * * * * *包含
#包含
用户命名空间STD;
int main () )
{
int n,I,s;
wile (扫描(' % d ',n ) n ) ) ) ) ) ) ) )。
{
s=1;
for(I=1; i=n; I ) {
s=s*n%9;
}
if(s==0) printf(9(n );
ELSEprintf('%dn ',s );
}
返回0;
}
有个洞……
译文: 3358 blog.csdn.net/u 011308691/article/details/2488559