Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- Task : _example
- Author : Phumipat C. [MAGCARI]
- Language: C++
- Created : 20 February 2023 [21:36]
- */
- #include<bits/stdc++.h>
- using namespace std;
- char ans;
- void play(int l,int r,int target,int k){
- if(r-l+1 == 3){
- if(target == l) ans = 'g';
- else ans = 'a';
- return ;
- }
- int sz = (r-l+1 - (k+3)) / 2;
- if(target <= l + sz - 1) play(l,l+sz-1,target,k-1);
- else if(target <= l + sz - 1 + (k+3)){
- if(target == l + sz) ans = 'g';
- else ans = 'a';
- return ;
- }else{
- play(l + sz + (k+3),r,target,k-1);
- }
- }
- int main(){
- cin.tie(0)->sync_with_stdio(0);
- cin.exceptions(cin.failbit);
- int target;
- cin >> target;
- int n = 3,k = 0;
- while(n < target) k++,n = (2*n) + (k+3);
- play(1,n,target,k);
- cout << ans << '\n';
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment