Sasha and Sticks (Codeforces 832A)

来源:互联网 发布:淘宝仓库中的宝贝链接 编辑:程序博客网 时间:2024/05/16 06:27

题目链接  http://codeforces.com/problemset/problem/832/A

A. Sasha and Sticks
time limit per test
2 seconds
memory limit per test
256 megabytes
input
standard input
output
standard output

It's one more school day now. Sasha doesn't like classes and is always bored at them. So, each day he invents some game and plays in it alone or with friends.

Today he invented one simple game to play with Lena, with whom he shares a desk. The rules are simple. Sasha draws n sticks in a row. After that the players take turns crossing out exactly k sticks from left or right in each turn. Sasha moves first, because he is the inventor of the game. If there are less than k sticks on the paper before some turn, the game ends. Sasha wins if he makes strictly more moves than Lena. Sasha wants to know the result of the game before playing, you are to help him.

Input

The first line contains two integers n and k (1 ≤ n, k ≤ 1018k ≤ n) — the number of sticks drawn by Sasha and the number k — the number of sticks to be crossed out on each turn.

Output

If Sasha wins, print "YES" (without quotes), otherwise print "NO" (without quotes).

You can print each letter in arbitrary case (upper of lower).

Examples
input
1 1
output
YES
input
10 4
output
NO
题目大意:

两个人玩游戏,一共有n跟木棒,没人一次拿k跟,问谁拿的时候不够k跟,谁就输。题目已经说明:Sasha先拿木棒,如果Sasha赢,输出“YES”,否则输出“NO”。

解题思路:

int s =n/k ,顾名思义s表示比赛的局数。因为是Sasha先拿的,所以若果s是奇数,Sasha赢,偶数Sasha输。

代码:

#include<iostream>using namespace std;int main(){    long long int n,k,s;    while(cin>>n>>k)    {        s=n/k;        if(s%2==0)            cout<<"NO"<<endl;        else            cout<<"YES"<<endl;    }    return 0;}


原创粉丝点击