math
2026-08-06 20:10:32
发布于:浙江
1阅读
0回复
0点赞
#include<bits/stdc++.h>//submitRecord//
using namespace std;
//const int N=1e7+10;
long long f(long long x){
if(x<=9){
return x;
}
int cnt=0;
while(x!=0){
cnt+=x%10;
x/=10;
}
return f(cnt);
}
int main(){
//freopen("","r",stdin);
//freopen("","w",stdout);
ios::sync_with_stdio();
cin.tie(nullptr);
cout.tie(nullptr);
long long n;
cin>>n;
cout<<f(n);
//fclose(stdin);
//fclose(stdout);
return 0;
}
这里空空如也







有帮助,赞一个