Gym 100827G Number Game (博弈)】的更多相关文章

Number Game Alice and Bob are playing a game on a line of N squares. The line is initially populated with one of each of the numbers from 1 to N. Alice and Bob take turns removing a single number from the line, subject to the restriction that a numbe…
KK's Number 题目链接: http://acm.hust.edu.cn/vjudge/contest/121332#problem/K Description Our lovely KK has a funny mathematical game:This game requires two people,There are numbers,every time KK will take the numbers,first.Every time you can take any num…
UVA 1558 - Number Game 题目链接 题意:20之内的数字,每次能够选一个数字,然后它的倍数,还有其它已选数的倍数组合的数都不能再选,谁先不能选数谁就输了,问赢的方法 思路:利用dp记忆化去求解,要输出方案就枚举第一步就可以,状态转移过程中,选中一个数字,对应的变化写成一个函数,然后就是普通的博弈问题了,必胜态之后必有必败态,必败态之后全是必胜态 代码: #include <stdio.h> #include <string.h> const int N = 10…
题意:给两个数 n,m,让你把它们分成 全是1,每次操作只能分成几份相等的,求哪一个分的次数最多. 析:很明显,每次都除以最小的约数是最优的. 代码如下: #pragma comment(linker, "/STACK:1024000000,1024000000") #include <cstdio> #include <string> #include <cstdlib> #include <cmath> #include <io…
题意:对于正整数\(n\),每次可以选择使它变为\(n-1\)或者\(n/t\) (\(n\ mod\ t=0\)且\(t\)为奇数),当\(n=1\)时便不可以再取,问先手赢还是后手赢. 题解:首先特判\(1\)和\(2\)的情况,然后显然如果\(n\)是奇数,一定是先手赢. ​ 如果\(n\)是偶数,那么我们去找它的奇数因子. ​ 如果没有,那么先手只能减一,后手直接赢. ​ 如果有,那么我们直接将它的所有奇数因子拿走,剩下一个孤零零的偶数给后手,如果这个偶数不是\(2\)的话,先手赢,否则…
比赛链接:传送门 Gym 101775A Chat Group(签到:待补) Gym 101775B Scapegoat(待补) Gym 101775C Traffic Light(贪心+思维) 思路: 需要证明两个点: ① 所有的N+1个S都是必须要走的,并且可以适当安排使得红灯只用等最长的一个. ② 上面这样的安排的答案是S0+S1+…+SN+max(Bi),而答案不可能比这个小,因为总有一种走法可以等到最长的那个红绿灯,如果其他的红绿灯也要等的话就比上面的方法大了. #include <b…
A Gym 101194A Number Theory Problem 7 的二进制是111,2k-1 的二进制是 k 个 1.所以 k 能被 3 整除时 2k-1 才能被 7 整除. #include <bits/stdc++.h> using namespace std; int main() { int T; scanf("%d", &T); for(int ca = 1; ca <= T; ++ca) { int n; scanf("%d&q…
G. The jar of divisors time limit per test:2 seconds memory limit per test:64 megabytes input:standard input output:standard output Alice and Bob play the following game. They choose a number N to play with. The rules are as follows: - They write eac…
There are two seagulls playing a very peculiar game. First they line up N unit squares in a line, all originally colored white. Let L be the length of the longest continuous sub-segment of white unit squares. Let P be any prime that satisfies the con…
题目链接: http://codeforces.com/gym/101194/attachments https://icpcarchive.ecs.baylor.edu/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&problem=5919 题意: 给出正整数 $N(1 \le N \le 10^5)$,询问对于正整数 $k$,有多少个小于 $2^N$ 的 $2^k-1$ 是 $7$ 的整数倍. 题解: $…