首页 > 其他分享 >Acwing 1318. 取石子游戏(博弈论)

Acwing 1318. 取石子游戏(博弈论)

时间:2024-03-30 16:44:17浏览次数:22  
标签:typedef const cout LL 博弈论 cin long 1318 Acwing

https://www.acwing.com/problem/content/1320/

输入样例:
23 3
输出样例:
1
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef pair<int,int> PII;
const LL MAXN=1e18,MINN=-MAXN,INF=0x3f3f3f3f;
const LL N=100200,M=2020;
int main()
{
    cin.tie(0); cout.tie(0); ios::sync_with_stdio(false);
    LL T=1;
    //cin>>T;
    while(T--)
    {
        LL n,k;
        cin>>n>>k;
        if(n%(k+1)!=0) cout<<1<<endl;
        else cout<<2<<endl;
    }
    return 0;
}

标签:typedef,const,cout,LL,博弈论,cin,long,1318,Acwing
From: https://www.cnblogs.com/Vivian-0918/p/18105706

相关文章

  • Acwing 5475. 聚会 ( BFS )
    https://www.acwing.com/problem/content/5478/输入样例1:5543124321223344145输出样例1:22223输入样例2:76321233221122334255667输出样例2:1112211#pragmaGCCdiagnosticerror"-std=c++11"#pragmaGCCtarget(......
  • Acwing 1050. 鸣人的影分身
    https://www.acwing.com/problem/content/1052/输入样例:173输出样例:8#include<bits/stdc++.h>usingnamespacestd;typedeflonglongLL;typedefpair<int,int>PII;constLLMAXN=1e18,MINN=-MAXN,INF=0x3f3f3f3f;constLLN=200200,M=2020;LLn,m;LL......
  • 二十二 1388. 游戏 (区间DP|博弈论)
    388.游戏(区间DP|博弈论)思路:在最坏情况下考虑问题,每个人都选择对自己有利的情况,dp[i][j]指的是对方获得的分差,分值总和固定为sum,因此我方方差越大,对方的分值就越小。最后A+B=sum,A-B=diff。importjava.util.*;publicclassMain{privatestaticintN,sum,dif......
  • AcWing 799. 最长连续不重复子序列
    原题链接:https://www.acwing.com/problem/content/801/题目分析用数组记录每个元素出现的次数,遍历以第i个元素为结尾的[i,j]区间的最长长度显然[i-1,j]必然达到最大,所以每次重复会发生在新增添的a[i]上,j右移直到到达i和暴力做法的区别就在于指针不会回退代码细节每次先把......
  • AcWing 800. 数组元素的目标和
    原题链接:https://www.acwing.com/problem/content/802/题目分析数组是升序的,a[i]从小变大,b[j]从大变小。a代表目前可能匹配的a中最小值,若与目前b之和仍然大于k则必然j--;i从0开始从前往后遍历;j从m-1开始从后向前遍历;和纯暴力的O(n2) 算法的区别就在于:j指针不会......
  • AcWing刷题-空调
    空调差分:N=int(input())p=list(map(int,input().split()))t=list(map(int,input().split()))d,s=[0]*100010,[0]*100010foriinrange(N):d[i]=p[i]-t[i]foriinrange(N):s[i]+=d[i]s[i+1]-=d[i]ans=0foriinrange(N+1):......
  • AcWing—最短Hamilton路径
    91.最短Hamilton路径-AcWing题库所需知识:二进制状态压缩,动态规划假设现在有六个点:j/i012345002451312065312460832355805441335035312430起点为0终点为5,假设现在走到终点前一点,不妨设该点为4,即现在要确定从0到4,最少要走多远,起点为1终点为4,现有六条路可以选择:first:0–......
  • Acwing 129. 火车进栈
    https://www.acwing.com/problem/content/description/131/输入样例:3输出样例:123132213231321#include<bits/stdc++.h>usingnamespacestd;typedeflonglongLL;typedefpair<int,int>PII;constLLMAXN=1e18,MINN=-MAXN,INF=0x3f3f3f3f;constLLN=......
  • [正常题解]Acwing.5308 公路
    ​首先需要理解一个证明:​ 假设我们有三个点,前两个点价格为\(a_1,\a_2\),距离为\(v_1,\v_2\)那么就有式子:\(\frac{a_1\timesv_1}{d}+\frac{a_2\timesv_2}{d}\式①\),和式子\(\frac{a_1\timesv_1}{d}+\frac{a_1\timesv_2}{d}\式子②\)$\rightarrow\frac{1}{d}(......
  • Acwing 1111. 字母
    https://www.acwing.com/problem/content/1113/#include<bits/stdc++.h>usingnamespacestd;typedeflonglongLL;typedefpair<int,int>PII;constLLMAXN=1e18,MINN=-MAXN,INF=0x3f3f3f3f;constLLN=200200,M=2020;LLn,m,maxn=1;charc[M][M];ma......