Description
There are N apples. Two people take turns to either: 1. Divide the apple into two piles with different numbers. 2. The other people selects a pile of apples as the beginning of the next turn. If someone can not meet the requirements, he is lost. Will the first one win the game if both use the best strategy?ios
Input
There are multiple test cases. The first line of each case contains a integer N. ( 1 <= N <= 1000000000 )
Output
If the first person will win, output 「Yes」. Otherwise, output 「No」.
Sample Input
2 3 4
Sample Output
No Yes No
題解:題意是把一個數分兩半,數字不能相同,一我的不能分就輸了;挺好找的規律,一下就找到了,從開始找,兩個必敗對應必勝;不然必敗;
代碼:
#include<iostream> #include<cstdio> #include<cstring> #include<cmath> #include<algorithm> using namespace std; const int INF = 0x3f3f3f3f; typedef long long LL; int main(){ LL N; while(~scanf("%lld",&N)){ if(N == 1 || N == 2){ puts("No"); } else if(N == 3){ puts("Yes"); } else{ if((N - 1) % 3 == 0){ puts("No"); } else puts("Yes"); } } return 0; }