YOUTUBE CHANNEL: https://youtube.com/channel/UCYzdgz0Xhcb0tFp_b3gTesQ Hoop Jump Problem Code: HOOPS Question: You and...
YOUTUBE CHANNEL:
https://youtube.com/channel/UCYzdgz0Xhcb0tFp_b3gTesQ
Hoop Jump Problem Code: HOOPS
Question:
You and your friend are playing a game with hoops. There are hoops (where is odd) in a row. You jump into hoop , and your friend jumps into hoop . Then you jump into hoop , and after that, your friend jumps into hoop
, and so on.
The process ends when someone cannot make the next jump because the hoop is occupied by the other person. Find the last hoop that will be jumped into.
Input
- The first line contains an integer
- .
Output
For each testcase, output in a single line the answer to the problem.
Constraints
- is odd
Subtasks
Subtask #1 (100 points): original constraints
Sample Input
2
1
3
Sample Output
1
2
SOLUTION:
#include "bits/stdc++.h"
#include "ext/pb_ds/assoc_container.hpp"
using namespace std;
using namespace __gnu_pbds;
#define int long long
#define pi (3.141592653589)
#define mod 1000000007
#define float double
#define t() int test;cin>>test;while(test--)
#define pb push_back
#define mp make_pair
#define ii pair<int,int>
#define ff first
#define ss second
#define all(c) c.begin(), c.end()
#define fr(i, n) for(int i=n-1;i>=0;i--)
#define fo(i,n) for(int i=0;i<n;i++)
#define f(i,a,n) for(int i=a;i<=n;i++)
#define endl "\n"
#define fast ios_base::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr);
bool isPrime(int n){
if(n==1) return false;
if(n==2) return true;
for(int i=2;i*i<=n;i++){
if(n%i==0)return false;
}
return true;
}
typedef tree< int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;
#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1) {
cout << name << " : " << arg1 << endl;
//use cerr if u want to display at the bottom
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args) {
const char* comma = strchr(names + 1, ','); cout.write(names, comma - names) << " : " << arg1 << " | "; __f(comma + 1, args...);
}
#else
#define trace(...)
#endif
void init(){
#ifndef ONLINE_JUDGE
freopen("in.txt", "r", stdin);
freopen("outp.txt", "w", stdout);
#endif
}
int32_t main(){
init();
fast
t(){
int n;cin>>n;
// vector<int> v1;
// string s;
int x = n/2;
cout<<x+1<<endl;
}
return 0;
}
