Codeforces Round #425 (Div. 2) Problem A Sasha and Sticks

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

Note

In the first example Sasha crosses out 1 stick, and then there are no sticks. So Lena can‘t make a move, and Sasha wins.

In the second example Sasha crosses out 4 sticks, then Lena crosses out 4 sticks, and after that there are only 2 sticks left. Sasha can‘t make a move. The players make equal number of moves, so Sasha doesn‘t win.



  题目大意 桌面上有n根棍子,每次拿k根,两个人交换着拿,当轮到谁时,桌面上的棍子数量少于k根,谁就输。问先手能否获胜。

  一共可以拿轮,判断它的奇偶性就好了。

  在比赛时3分钟a掉这道题,还是比较满意的。

Code

 1 /**
 2  * Codeforces
 3  * Problem#832A
 4  * Accepted
 5  * Time:15ms
 6  * Memory:2000k
 7  */
 8 #include <iostream>
 9 #include <cstdio>
10 #include <ctime>
11 #include <cmath>
12 #include <cctype>
13 #include <cstring>
14 #include <cstdlib>
15 #include <fstream>
16 #include <sstream>
17 #include <algorithm>
18 #include <map>
19 #include <set>
20 #include <stack>
21 #include <queue>
22 #include <vector>
23 #include <stack>
24 #ifndef WIN32
25 #define Auto "%lld"
26 #else
27 #define Auto "%I64d"
28 #endif
29 using namespace std;
30 typedef bool boolean;
31 const signed int inf = (signed)((1u << 31) - 1);
32 const signed long long llf = (signed long long)((1ull << 61) - 1);
33 const double eps = 1e-6;
34 const int binary_limit = 128;
35 #define smin(a, b) a = min(a, b)
36 #define smax(a, b) a = max(a, b)
37 #define max3(a, b, c) max(a, max(b, c))
38 #define min3(a, b, c) min(a, min(b, c))
39 template<typename T>
40 inline boolean readInteger(T& u){
41     char x;
42     int aFlag = 1;
43     while(!isdigit((x = getchar())) && x != ‘-‘ && x != -1);
44     if(x == -1) {
45         ungetc(x, stdin);
46         return false;
47     }
48     if(x == ‘-‘){
49         x = getchar();
50         aFlag = -1;
51     }
52     for(u = x - ‘0‘; isdigit((x = getchar())); u = (u << 1) + (u << 3) + x - ‘0‘);
53     ungetc(x, stdin);
54     u *= aFlag;
55     return true;
56 }
57
58 long long n, k;
59
60 inline void init() {
61     readInteger(n);
62     readInteger(k);
63     long long c = n / k;
64     if(c & 1)    puts("YES");
65     else puts("NO");
66 }
67
68 int main() {
69     init();
70     return 0;
71 }
时间: 2024-08-06 20:05:32

Codeforces Round #425 (Div. 2) Problem A Sasha and Sticks的相关文章

Codeforces Round #425 (Div. 2) Problem D Misha, Grisha and Underground (Codeforces 832D) - 树链剖分 - 树状数组

Misha and Grisha are funny boys, so they like to use new underground. The underground has n stations connected with n - 1 routes so that each route connects two stations, and it is possible to reach every station from any other. The boys decided to h

Codeforces Round #425 (Div. 2) Problem C (Codeforces 832C) Strange Radiation - 二分答案 - 数论

n people are standing on a coordinate axis in points with positive integer coordinates strictly less than 106. For each person we know in which direction (left or right) he is facing, and his maximum speed. You can put a bomb in some point with non-n

Codeforces Round #581 (Div. 2)-E. Natasha, Sasha and the Prefix Sums-动态规划+组合数学

Codeforces Round #581 (Div. 2)-E. Natasha, Sasha and the Prefix Sums-动态规划+组合数学 [Problem Description] ? 给你\(n\)个\(1\),\(m\)个\(-1\),他们任意排列有\(\frac{(n+m)!}{n!\cdot m!}\)中排列,每种排列都有一个最大前缀和(可能为\(0\)),求所有排列的最大前缀和之和为多少. [Solution] ? 定义\(dp[i][j]\)表示有\(i\)个\(

Codeforces Round #253 (Div. 2), problem: (B)【字符串匹配】

简易字符串匹配,题意不难 1 #include <stdio.h> 2 #include <string.h> 3 #include <math.h> 4 #include <iostream> 5 #include <algorithm> 6 using namespace std; 7 8 int main(){ 9 int i, j, k, t, n; 10 int num, flag, ans; 11 char a[300]; 12 sc

Codeforces Round #425 (Div.2)

A.Sasha and Sticks 题意:有两个人,每次轮流从n个棒子中抽出k个,直到剩余不足k个棒子.Sasha先抽.如果Sasha抽取的多,则输出YES,否则输出NO. 思路:n/k为奇数时,Sasha获胜. 1 #include<iostream> 2 #include<cstdio> 3 using namespace std; 4 typedef long long LL; 5 LL n, k; 6 int main() 7 { 8 while (~scanf(&quo

Codeforces Round #466 (Div. 2) Problem A - E

从这里开始 题目列表 小结 Problem A Points on the line Problem B Our Tanya is Crying Out Loud Problem C Phone Numbers Problem D Alena And The Heater Problem E Cashback Problem F Machine Learning (Lazy Tag) 小结 这场比赛和同学一起打.本来应该是很开心的事情,结果留下好多遗憾. 第一个遗憾是没能在20分钟内消灭A.B题

Codeforces Round #427 (Div. 2) Problem C Star sky (Codeforces 835C) - 前缀和

The Cartesian coordinate system is set in the sky. There you can see n stars, the i-th has coordinates (xi, yi), a maximum brightness c, equal for all stars, and an initial brightness si (0 ≤ si ≤ c). Over time the stars twinkle. At moment 0 the i-th

Codeforces Round #327 (Div. 1), problem: (A) Median Smoothing

http://codeforces.com/problemset/problem/590/A: 在CF时没做出来,当时直接模拟,然后就超时喽. 题意是给你一个0 1串然后首位和末位固定不变,从第二项开始到倒数第二项,当前的a[i]=(a[i-1],a[i],a[i+1])三项排序后的中间项,比如连续3项为 1 0 1,那么中间的就变为1,然后题目让你输出达到稳定状态时所需的最小步数,不能的话输出-1. 无论给你啥数列,都能达到稳态.所以不可能输出-1: 还有一开始就稳定不变,或经过几次变换而稳定

Codeforces Round #425 (Div. 2) B. Petya and Exam(暴力大法好)

题目链接:http://codeforces.com/problemset/problem/832/B 题意:给定一些小写字符(定义为好字符,除这些好字符外的其他小写字符都是坏字符).和字符串S,S里面除了小写字母以外还有?字符,?可以用任何的好字符替代:*字符,*只可以用坏字符串和 空替代,然后给出n个字符串去匹配S字符,问是否能成功. 题解:QAQ,这道题写的我头发又掉了好多. 设拿来匹配S的字符串为T 字符串要匹配,长度要相同吧.*既然这么强大,可以空,那么T的长度最多比S的长度少1:然后