没给数据范围就乱搞了,看到WA了以后换了long long 又是WA【不返回re真是赞】
顺手试试assert好了
assert(n<=0)可以看是否爆了上限= =
#include <bits/stdc++.h>
using namespace std;
char a[500000];
int GaoGao(int i)
{
int ret=0;
while (i>=10)
{
int tem=0;
while (i!=0)
{
tem+=i%10;
i/=10;
}
i=tem;
}
cout<<i<<endl;
}
void Gao()
{
int tem=0;
for (int i=0;i<strlen(a);i++)
{
// assert(tem<=100000000000000);
tem+=a[i]-'0';
}
if (tem==0) return ;
GaoGao(tem);
}
int main()
{
//freopen("a.in","r",stdin);
while (scanf("%s",a)!=EOF)
Gao();
return 0;
}