90pts求助

P1898 缘分计算

```cpp //楼主没有去零 #include<bits/stdc++.h> using namespace std; string s,d; int st,x; int a,b; char cc[10]; int main(){ cin>>s>>st; for(int i=0;i<s.size();i++){ x=s[i]-'A'+st; sprintf(cc,"%d",x); d+=cc; } while(d.size()>2&&d!="100"){ for(int i=0;i<d.size()-1;i++){ a=d[i]-'0',b=d[i+1]-'0'; a=(a+b)%10; d[i]=a+'0'; } d.erase(d.size()-1,1); } int i=0; for(;i<d.size()-1;i++){//去零 if(d[i]!='0')break; } for(;i<d.size();i++){ cout<<d[i]; } return 0; } ```
by BGM114514 @ 2023-09-10 12:08:45


|