2 solutions

  • 0
    @ 2026-4-20 15:54:14
    #include<bits/stdc++.h>
    using namespace std;
    int main()
    {
    	int n,x;
    	cin>>n>>x;
    	for(int i=1;;i++)
    	{
    		int t=i;
    		bool st=true;
    		for(int j=1;j<=n;j++)
    		{
    			t=(t-x)*(n-1);
    			if(t%n!=0||t/n==0)
    			{
    				st=false;
    			}
    			t=t/n;
    		}
    		if(st)
    		{
    			cout<<i;
    			return 0;
    		}
    	}
    	return 0;
    }
    
    

    Information

    ID
    2534
    Time
    2000ms
    Memory
    256MiB
    Difficulty
    9
    Tags
    (None)
    # Submissions
    14
    Accepted
    5
    Uploaded By