2 solutions

  • 0
    @ 2026-9-11 19:40:58
    #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;
    }
    
    
    
    • 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;
      }
      
      
      • 1

      Information

      ID
      2534
      Time
      2000ms
      Memory
      256MiB
      Difficulty
      3
      Tags
      (None)
      # Submissions
      45
      Accepted
      10
      Uploaded By