题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=2149
Problem Description 虽然不想,但是现实总归是现实,Lele始终没有逃过退学的命运,因为他没有拿到奖学金。现在等待他的,就是像FarmJohn一样的农田生涯。 Input 本题目包含多组测试,请处理到文件结束(EOF)。每组测试占一行。 Output 对于每组数据,在一行里按递增的顺序输出Lele第一次可以加的价。两个数据之间用空格隔开。 Sample Input 4 2 3 2 3 5 Sample Output 1 none 3 4 5 |
很明显的巴什博弈,式子:n=(m+1)*k+c如果直接能卖,就买,不能买就输出多的那个c,如果c等于0,肯定买不到
ac:
#include<stdio.h>
#include<string.h>
#include<math.h>
#include<map>
//#include<set>
#include<deque>
#include<queue>
#include<stack>
#include<bitset>
#include<string>
#include<fstream>
#include<iostream>
#include<algorithm>
using namespace std;
#define ll long long
#define INF 0x3f3f3f3f
//#define mod 1e9+7
//#define max(a,b) (a)>(b)?(a):(b)
//#define min(a,b) (a)<(b)?(a):(b)
#define clean(a,b) memset(a,b,sizeof(a))// 水印
//std::ios::sync_with_stdio(false);
const int MAXN=1e5+5;
int main()
{
std::ios::sync_with_stdio(false);
int m,n;
while(cin>>m>>n)
{
if(n>=m)//先手必定能买完
{
cout<<m;
for(int i=m+1;i<=n;++i)
cout<<" "<<i;
cout<<endl;
}
else if(m%(n+1)==0)//必输
cout<<"none"<<endl;
else
cout<<m%(n+1)<<endl;
}
}