Codeforces 923 A. Primal Sport】的更多相关文章

http://codeforces.com/contest/923/problem/A 题意: 初始有一个x0,可以选择任意一个<x0的质数p,之后得到x1为≥x0最小的p的倍数 然后再通过x1按照一样的算法得出一个x2 已知x2,问x0最小可能是多少 设f[x] 表示<x 的最大的x的质因数 那么x1 ∈ [x2-f[x2]+1,x2] 同理,可以得到x0 #include<cstdio> using namespace std; ]; #define min(x,y) ( (x…
[题目链接] 点击打开链接 [算法] 不难看出,x1的范围是[x2-P(x2)+1,x2],x0的范围是[x1-P(x1)+1,x1] 我们可以先做一遍线性筛,然后暴力就可以了 [代码] #include<bits/stdc++.h> using namespace std; const int MAXN = 1e6; int i,j,k,tmp,x,l,ans; ]; vector<int> Prime; template <typename T> inline vo…
[链接] 我是链接,点我呀:) [题意] 题意 [题解] 考虑怎么得到数字x2=N,假设是质数p的倍数 那么x1肯定在x2-p+1~x2这个范围内才行 因为p的倍数要刚好大于等于x1, 所以x1肯定是在这两个倍数之间才行 结果已经很显然了 肯定让p的值越大越好. 这样得到的x1才可能越小. 枚举x1在x2-p+1~x2之间. 用同样的方式得到x0就好. [代码] #include <bits/stdc++.h> using namespace std; const int N = 1e5; i…
Primal Sport 题意:2个人玩游戏, 每次轮到一个人选择一个比当前值小的素数, 然后在找到比素数的倍数中最小的并且不小于当前数的一个数. 现在这个游戏玩了2轮, 现在想找到最小的那个起点X0. 题解:我们可以发现样例解释中每次都是先减去最大的那个素数, 然后再从 减去后的数+1(如果不加一那么将导致通过这个素数发现最小的公倍数是减去数的本身) 到 n, 找到最小的那个值.因为要X0尽量小, 所以每一步都要能减去尽量大的数. 因为要找到最大的数, 所以我们先 素数塞跑出 当前值能找到最大…
A. Primal Sport time limit per test 1.5 seconds memory limit per test 256 megabytes input standard input output standard output Alice and Bob begin their day with a quick game. They first choose a starting number X0 ≥ 3 and try to reach one million b…
Alice and Bob begin their day with a quick game. They first choose a starting number X0 ≥ 3 and try to reach one million by the process described below. Alice goes first and then they take alternating turns. In the i-th turn, the player whose turn it…
http://codeforces.com/contest/923/problem/D 题意: A-->BC , B-->AC , C-->AB , AAA-->empty 问指定串S是否能变成目标串T 发现1:B与C等价 B-->AC-->AAB-->AAAC-->C C-->AB-->AAC-->AAAB-->B 发现2:B前面的A可以消去 AB-->AAC-->AAAB-->A 新的变换: A-->BB…
http://codeforces.com/contest/923/problem/C Trie树 #include<cstdio> #include<iostream> using namespace std; #define N 300001 #define M 30 ,tr[N*M][],sum[N*M]; int a[N]; void read(int &x) { x=; char c=getchar(); while(!isdigit(c)) c=getchar(…
http://codeforces.com/contest/923/problem/B 题意: 有n天,每天产生一堆体积为Vi的雪,每天所有雪堆体积减少Ti 当某一堆剩余体积vi<=Ti时,体积减少vi,雪堆消失 问每天所有雪堆一共减少多少体积 fhq treap 把<=Ti的分裂出来,计算和 >Ti 的 Ti*个数 #include<cstdio> #include<iostream> #include<algorithm> using namesp…
题目链接:http://codeforces.com/contest/948/problem/B 知识点: 素数 解题思路: \(f(x)\) 表示 \(x\) 的最大素因子.不难想到:\(X_1 \in [X_2 - f(X_2) + 1, X]\),对于这个范围中的每一个非素数 \(X_1\) 求出其对应的最小的 \(X_0 = X_1 - f(X_1) + 1\),找出一个最小的即为答案. 重点是要想到提前打出 \(f()\) 的表. AC代码: #include <bits/stdc++…