Sasha and Sticks (Codeforces 832A)
来源:互联网 发布:淘宝仓库中的宝贝链接 编辑:程序博客网 时间:2024/05/16 06:27
题目链接 http://codeforces.com/problemset/problem/832/A
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.
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.
If Sasha wins, print "YES" (without quotes), otherwise print "NO" (without quotes).
You can print each letter in arbitrary case (upper of lower).
1 1
YES
10 4
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;}
- Sasha and Sticks (Codeforces 832A)
- codeforces 832A Sasha and Sticks
- codeforces 832A ——Sasha and Sticks
- Codeforces Round #425 A. Sasha and Sticks
- Sasha and Sticks CodeForces
- A. Sasha and Sticks
- CodeForce 832A Sasha and Sticks
- Codeforces Round #425 (Div. 2)A. Sasha and Sticks
- Codeforces Round #425 (Div. 2) A.Sasha and Sticks
- Codeforces Round #425 (Div. 2) A. Sasha and Sticks
- Codeforces Round #425 (Div. 2) A. Sasha and Sticks
- Codeforces832A Sasha and Sticks
- cf round425A. Sasha and Sticks
- A. MUH and Sticks(Codeforces Round #269)
- codeforces 471A MUH and Sticks
- Codeforces 718C C. Sasha and Array
- codeforces 718 C.Sasha and Array
- codeforces 718C - Sasha and Array
- ACM训练日记—8月8日
- static关键字
- HDU1013(简单数论)
- android中使用DisplayMetrics获取屏幕参数
- javascript中的异步和单线程
- Sasha and Sticks (Codeforces 832A)
- hdu 6092 Rikka with Subset【01背包+思维】
- 昂贵的聘礼 (dfs)
- 通过USB转TTL串口下载stm32程序
- VR开发-陀螺仪部分研究
- 求和
- Python元祖,列表,字典,集合的比较
- 如何在JSP页面显示Oracle数据库内容
- Python学习第一章:第一次的亲密接触之初识程序(二)