2 solutions

  • 2
    @ 2025-5-26 16:48:51
    #include <iostream>
    using namespace std;
    
    int main() {
      	int n,x;
      	cin>>n>>x;
      	for(int i=1;;i++)
      	{
      		int st=true;
      		int t=i; //枚举最后一只猫的雨的数量 
      		for(int j=2;j<=n;j++)
      		{
      			if((t*n+x)%(n-1)!=0) //前面的猫拿完以后不能够分成n-1份 
      			{
      				st=false;	
    			}
      			t=(t*n+x)/(n-1);//上一只猫得到的鱼的数量 
    		}
    		if(st)
    		{
    			cout<<t*n+x<<endl;
    			break;
    		}
    	}
        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
      9
      Tags
      (None)
      # Submissions
      14
      Accepted
      5
      Uploaded By