ITGUY20 - Editorial

Problem: https://www.codechef.com/PBK12020/problems/ITGUY20

DIFFICULTY:

EASY.

PROBLEM:

Finally, the pandemic is over in ChefLand, and the chef is visiting the school again. Chef likes to climb the stairs of his school’s floor by skipping one step, sometimes chef climbs the stairs one by one. Simply, the chef can take one or 2 steps in one upward movement. There are N stairs between ground and next floor. The chef is on the ground floor and he wants to go to the next floor with Cheffina but, Cheffina asks chef in how many ways, the chef can reach the next floor normally or any combination of skipping one step, where order doesn’t matter.

Program:

#include <bits/stdc++.h>
using namespace std;
#define ll long long

int main() {

ios_base::sync_with_stdio(false);

cin.tie(NULL);
ll int t,n;
cin>>t;
while(t--){
    cin>>n;
    cout<<(n>>1)+1<<"\n";
}
return 0;

}

1 Like

@references This code is giving TLE in my case. Can you tell me the reason for this.
https://www.codechef.com/viewsolution/40564992

Use Fast IO

@references I used that but still it shows TLE.
https://www.codechef.com/viewsolution/40567692

Don’t use endl
because endl is not efficient.
You can use “\n”

Learnt something new today. Thanks!!

Can Someone pls explain how the logic is build
I didn’t got that.