Result: Accepted
Time: 7ms
Memory: 2148kB
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<cstring>
#include<cstdlib>
#include<cmath>
using namespace std;
int T,s,n,m,i,a[100010],f;
int main(){
scanf("%d",&T);
while(T--){
scanf("%d %d %d",&s,&n,&m);
f=0;
while(n!=m){
if(m>n){
if(m%2==1){
a[f]=1;
f++;m++;
}
else{
a[f]=2;
f++;m/=2;
}
}
else{
a[f]=1;
f++;m++;
}
}
if(f<=s){
for(i=f-1;i>=0;i--){
if(a[i]==1) printf("yeah! ");
else printf("oh! ");
}
}
else printf("OMG!");
printf("\n");
}
}