-1

Over the past 2 days i was practising on codeforces . I am new to programming and currently doing implementation problems.

This question is 1337B ( KANA AND DRAGON QUEST) https://codeforces.com/problemset/problem/1337/B

I cannot figure out my mistake in this code. Please help me out

#include <iostream>
#include <string>

using namespace std;

int main()
{
    int t;
    cin>>t;

for (int i=0;i<t;i++)
{
    long long int x,n,m;
    cin>>x>>n>>m;


        for( int j=0;j<n&&x>0&&x>20;j++)
        {


            x=x/2+10 ;


        }






          x=x-m*10;


     if (x>>0)
     {
        cout<<"NO"<<endl;
     }
     else
     {
        cout<<"YES"<<endl;
     }


}

    return 0;

}
Space 007
  • 3
  • 2
  • Please include your test input, expected output, and actual output. Nobody is going to go to codeforces to look up this problem. that being said, `if (x>>0)` looks like a typo. Use meaningful variable names and use spaces between binary operators. Also decrease the excessive vertical whitespace when posting code. It will make your code easier to debug and easier to read by third parties. – JohnFilleau Apr 26 '20 at 14:17
  • `x>0&&x>20` can also be reduced t o`x > 20` – JohnFilleau Apr 26 '20 at 14:19
  • 1
    Although the entire purpose of those silly programming challenge/hacking/coding web sites has always been completely unclear to me, one thing here appears to be pretty clear: `if (x>>0)` doesn't do what you think it does. – Sam Varshavchik Apr 26 '20 at 14:21

1 Answers1

2

Your code is correct but you made a small error at the end. You do x>>0 instead of x > 0. ">>" is a bitwise shift operator and not a greater than operator. After checking with codeforces test input it does seem to work. Here is the version with no error

if (x>0)
  {
    cout<<"NO"<<endl;
  }
else
  {
    cout<<"YES"<<endl;
  }
Oleks G
  • 94
  • 5