Message on Whatsapp 8879355057 for DSA(OA + Interview) + Fullstack Dev Training + 1-1 Personalized Mentoring to get 10+LPA Job
0 like 0 dislike
1,168 views
For proper oa or interview experiences list of all top tech companies visit :

https://oa.desiqna.in

https://interview.desiqna.in
in Online Assessments by Expert (46,090 points) | 1,168 views

1 Answer

0 like 0 dislike

Images of ques

imageimage

 

by Expert (46,090 points)
0 0
#include<bits/stdc++.h>
using namespace std;


int main(){

    int n;
    cin >> n;
    int t;
    cin >> t;
    int temp = n-1;
    int div = t/temp;
    int f = 0;
    int mod = t%temp;
    if(div % 2 == 0 || (div%2 && t%temp==0)){
        f = 0;
    }
    else{
        f = 1;
    }
    if(f == 0){
        if(mod != 0){
            cout << mod << " " << mod+1<<endl;
        }
        else{
            cout << temp << " " << temp+1 << endl;
        }
    }
    else{
        if(mod != 0){
            cout << n-mod+1 << " " << n -mod<<endl;
        }
        else{
            cout << 2 << " " << 1 << endl;
        }
    }

    return 0;
}



//I think this code should work for hidden cases as well.