4 条题解

  • 1
    #include <bits/stdc++.h>
    using namespace std;
    int main()
    {
        int q;
        cin>>q;
        int cnt=0;
        for(int i=1;;i++)
        {
            int x=i;
            while(x%5==0)//只数 5 的数量
            {
                cnt++;
                x/=5;
            }
            if(cnt==q)
            {
                cout<<i;
                return 0;
            }
            if(cnt>q) break;
        }
        cout<<"No solution";
        return 0;
    }
    
    
  • 1
    #include <bits/stdc++.h>
    using namespace  std;
    int q,cnt,i; 
    int  main( )     
    {   
        cin>>q;
        for (i=1;;i++)
        {
            int it=i;
            while (it%5==0)
            {
                it/=5;
                cnt++;
            }
            if (cnt>q)
            {
                cout<<"No solution";
                return 0;
            } 
            if (cnt==q)
            {
                cout<<i;
                return 0; 
            }   
        }
        return 0;
    }//这个包对,思路不懂的话去看讨论
    
  • 0
    @ 2025-04-06 14:13:34

    #include <bits/stdc++.h>
    #define int long long
    using namespace std;

    signed main()
    {
    ios::sync_with_stdio(false);
    int n,count=0,i=0,t;
    cin>>n;
    if(!n)
    {
    cout<<1;
    return 0;
    }
    while(count!=n)
    {
    i+=5;
    t=i;
    while(t%5==0)
    {
    count++;
    t=t/5;
    }
    }
    if(count==n)
    {
    cout<<i;
    }
    else
    {
    cout<<"No solution";
    }
    return 0;
    }

  • -4
    #include <bits/stdc++.h>
    #define int long long
    using namespace std;
    
    signed main()
    {
        ios::sync_with_stdio(false);
        int n,count=0,i=0,t;
        cin>>n;
        if(!n)
        {
            cout<<1;
            return 0;
        }
        while(count!=n)
        {
            i+=5;
            t=i;
            while(t%5==0)
            {
                count++;
                t=t/5;
            }
        }
        if(count==n)
        {
            cout<<i;
        }
        else
        {
            cout<<"No solution";
        }
        return 0;
    }
    
    • @ 2024-08-23 13:32:55

      额,如果输入无解的数(比如5)就陷入死循环了

  • 1

信息

ID
1009
难度
5
分类
(无)
标签
递交数
155
已通过
48
通过率
31%
被复制
7
上传者