日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

Sasha and Sticks

發布時間:2024/10/5 编程问答 28 豆豆
生活随笔 收集整理的這篇文章主要介紹了 Sasha and Sticks 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

Description
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?≤?1018, k?≤?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.

C語言版本一

#include <stdio.h> #include <stdlib.h>/* run this program using the console pauser or add your own getch, system("pause") or input loop */int main(int argc, char *argv[]) {long long n,m;scanf("%lld%lld",&n,&m);int flag=1;long long a=n/m;if(a%2!=0) flag=-1;n%=m;while(n>=0){flag=-flag;n-=m;}if(flag==1)printf("YES\n");else printf("NO\n");return 0; }

C++版本一

#include<cstdio> #include<algorithm> #include<cstring> #include<cstdlib> #include<iostream> using namespace std;int main() {long long int n,k;scanf("%I64d %I64d",&n,&k);if((n/k)%2!=0){printf("YES\n");}else{printf("NO\n");}return 0; }

C++版本二

#include <bits/stdc++.h>using namespace std;int main(int argc, char const *argv[]) {long long n, k;while (~scanf("%I64d %I64d", &n, &k)){long long cnt;cnt = n / k;if(cnt & 1) printf("YES\n");else printf("NO\n");}return 0; }

JAVA版本一

總結

以上是生活随笔為你收集整理的Sasha and Sticks的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。