求助 60分
查看原帖
求助 60分
790884
Zxxcme楼主2024/11/8 18:45
#include <bits/stdc++.h>
using namespace std;
int main()
{
    long long n,m,q,temp=0;
    vector<string> time;
    cin>>n>>m>>q;
    string sn=to_string(n);
    string sm=to_string(m);
    while(q--)
    {
        char x=sn[sn.length()-1];
        sn.erase(sn.length()-1);
        if(((x-'0')*(x-'0'))%10!=0)
        {
            sn.insert(0,to_string(((x-'0')*(x-'0'))%10));
            time.push_back(sn);
        }
        if(sn==sm)
            break;
    }
    if(time[time.size()-1]!=to_string(m))  
        cout<<"-1"<<endl;
    else
    {
        for(int i=0;i<time.size();i++)
            cout<<time[i]<<endl;
    }
    return 0;
}
2024/11/8 18:45
加载中...