My issue
include <bits/stdc++.h>
using namespace std;
int main() {
int t;
cin>>t;
while(t–){
long int n,k,x;
cin>>n>>k>>x;
vector v(k);
long int s=0;
v[0]=1;
for(int i=1;i<k;i++){
s+=v[i-1];
v[i]=s+1;
}
if(v[k-1]>x){
cout<<“NO\n”;
}
else{
cout<<“YES\n”;
}
}
}
// why isnt this code working for the following case?
//“1
//32 32 263508”
My code
#include <bits/stdc++.h>
using namespace std;
int main() {
int t;
cin>>t;
while(t--){
long int n,k,x;
cin>>n>>k>>x;
vector<int> v(k);
long int s=0;
v[0]=1;
for(int i=1;i<k;i++){
s+=v[i-1];
v[i]=s+1;
}
if(v[k-1]>x){
cout<<"NO\n";
}
else{
cout<<"YES\n";
}
}
}
Problem Link: Superincreasing Practice Coding Problem - CodeChef