1 solutions

  • 0
    @ 2024-12-5 18:19:39

    C++ :

    #include<iostream>
    using namespace std;
    int main(){
    	int n,k,l,j,i;//3*3+1=10  10*3/2+1=16 16*3/2=25 
    	cin>>n>>i;
    	for(k=1;true;k++){
    		bool pi=true;
    		j=k*n+i;
    		for(l=2;l<=n;l++){
    			if(j%(n-1)==0){
    				j=j/(n-1)*n+i;
    			}else{
    				pi=false;
    				break;
    			}
    		}
    		if(pi==true){
    			cout<<j<<endl;
    			break;
    		}
    	} 
    
    }
    
    
    • 1

    Information

    ID
    9158
    Time
    1000ms
    Memory
    256MiB
    Difficulty
    (None)
    Tags
    # Submissions
    0
    Accepted
    0
    Uploaded By