题意:对于正整数\(n\),每次可以选择使它变为\(n-1\)或者\(n/t\) (\(n\ mod\ t=0\)且\(t\)为奇数),当\(n=1\)时便不可以再取,问先手赢还是后手赢. 题解:首先特判\(1\)和\(2\)的情况,然后显然如果\(n\)是奇数,一定是先手赢. ​ 如果\(n\)是偶数,那么我们去找它的奇数因子. ​ 如果没有,那么先手只能减一,后手直接赢. ​ 如果有,那么我们直接将它的所有奇数因子拿走,剩下一个孤零零的偶数给后手,如果这个偶数不是\(2\)的话,先手赢,否则…
题目链接:https://codeforces.com/contest/1370/problem/C 题意 给出一个正整数 $n$,Ashishgup 和 FastestFinger 依次选择执行以下一个操作: 如果 $n > 1$,使 $n$ 除以一个奇因子 如果 $n > 1$,使 $n$ 减一 若一方不能操作,则另一方胜利. 题解 奇数根据 $n = 1$ 分为两种情况. 偶数根据是否含有奇因子分为两种情况,不含奇因子根据是否为 $2$ 分为两种情况,含有奇因子根据 $2$ 的个数和奇因…
Pythagorean Triples 题目链接: http://codeforces.com/contest/707/problem/C Description Katya studies in a fifth grade. Recently her class studied right triangles and the Pythagorean theorem. It appeared, that there are triples of positive integers such th…
Codeforces Round #622 (Div. 2) B. Different Rules 题意: 你在参加一个比赛,最终按两场分赛的排名之和排名,每场分赛中不存在名次并列,给出参赛人数 n 和你两场分赛的排名 x, y,问你最终名次最小和最大可能是多少. 思路: 以8人为例: x + y = 2,最小第一名,最大第一名:               1 2 3 4 5 6 7 8 8 7 6 5 4 3 2 1               x + y = 3,最小第一名,最大第二名.…
A. Watching a movie time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output You have decided to watch the best moments of some movie. There are two buttons on your player: Watch the current minute…
A. Maximum GCD 题意: t组输入,然后输入一个n,让你在区间[1,n]之间找出来两个不相等的数a,b.求出来gcd(a,b)(也就是a,b最大公约数).让你求出来最大的gcd(a,b)是多少. 题解: 最大gcd(a,b),那就是n/2向下取整的结果.因为如果gcd(a,b)越大,那么a/gcd(a,b)或者b/gcd(a,b)的值肯定越小,最小也就是2了,所以输出n/2就行 代码: 1 #include<stdio.h> 2 #include<algorithm>…
You've got array a[1], a[2], ..., a[n], consisting of n integers. Count the number of ways to split all the elements of the array into three contiguous parts so that the sum of elements in each part is the same. More formally, you need to find the nu…
题目链接:https://codeforces.com/contest/1370/problem/A 题意 有 $n$ 个数大小分别为 $1$ 到 $n$,找出两个数间最大的 $gcd$ . 题解 若一个 $gcd$ 存在,则至少要有 $gcd$ 本身和 $2 \times gcd$,那么 $gcd$ 最大即为 $\lfloor \frac{n}{2} \rfloor$ . 代码 #include <bits/stdc++.h> using namespace std; void solve(…
题目链接:https://codeforces.com/contest/1370/problem/B 题意 给出 $2n$ 个数,选出 $2n - 2$ 个数,使得它们的 $gcd > 1$ . 题解 大于 $1$ 最好构造的 $gcd$ 就是 $2$ 了,根据奇偶将 $2n$ 个数分类,然后两个奇数一对,两个偶数一对即可. 代码 #include <bits/stdc++.h> using namespace std; void solve() { int n; cin >>…
题目链接:https://codeforces.com/contest/1370/problem/D 题意 给出一个含有 $n$ 个数的数组 $a$,从中选出 $k$ 个数组成子序列 $s$,使得 $min(max(s_1, s_3,       s_5, \ldots), max(s_2, s_4, s_6, \ldots))$ 最小. 题解 二分最小值,分别讨论二分值在奇数下标序列和偶数下标数列中的情况. 如果可以构造某个序列使其中的数都小于等于二分值则说明该二分值可行,设为上界,否则加一设…