rated

Educational Codeforces Round 74 (Rated for Div. 2) B. Kill 'Em All

你说的曾经没有我的故事 提交于 2019-12-01 12:35:11
链接: https://codeforces.com/contest/1238/problem/B 题意: Ivan plays an old action game called Heretic. He's stuck on one of the final levels of this game, so he needs some help with killing the monsters. The main part of the level is a large corridor (so large and narrow that it can be represented as an infinite coordinate line). The corridor is divided into two parts; let's assume that the point x=0 is where these parts meet. The right part of the corridor is filled with n monsters — for each monster, its initial coordinate xi is given (and since all monsters are in the right part, every xi is

Educational Codeforces Round 74 (Rated for Div. 2) C. Standard Free2play

大憨熊 提交于 2019-12-01 12:34:46
链接: https://codeforces.com/contest/1238/problem/C 题意: You are playing a game where your character should overcome different obstacles. The current problem is to come down from a cliff. The cliff has height h, and there is a moving platform on each height x from 1 to h. Each platform is either hidden inside the cliff or moved out. At first, there are n moved out platforms on heights p1,p2,…,pn. The platform on height h is moved out (and the character is initially standing there). If you character is standing on some moved out platform on height x, then he can pull a special lever, which

Educational Codeforces Round 74 (Rated for Div. 2) A. Prime Subtraction

心不动则不痛 提交于 2019-12-01 12:34:05
链接: https://codeforces.com/contest/1238/problem/A 题意: You are given two integers x and y (it is guaranteed that x>y). You may choose any prime integer p and subtract it any number of times from x. Is it possible to make x equal to y? Recall that a prime number is a positive integer that has exactly two positive divisors: 1 and this integer itself. The sequence of prime numbers starts with 2, 3, 5, 7, 11. Your program should solve t independent test cases. 思路: 考虑大于1的素数可以用素数补充, 合数都是素数的倍数也可以. 代码: #include<bits/stdc++.h> using namespace std; typedef long long LL; LL x, y; int main() { int t; cin >

Educational Codeforces Round 74 (Rated for Div. 2)补题

感情迁移 提交于 2019-12-01 06:14:23
慢慢来。 题目册 题目 A B C D E F G 状态 √ √ √ √ × ∅ ∅ //√,×,∅ 想法 A. Prime Subtraction res tp A 题意:给定 \(x,y(x>y)\) ,问能否将 \(x-y\) 拆成任意多个质数之和 1.任意大于 \(1\) 的整数 \(k\) 都可以用 \(2\) 与 \(3\) 的线性表示 证: 若 \(k\) 是偶数,显然; 若 \(k\) 是奇数,则 \(k\) 可以表示成 \(k = 3 + 2*k'\) ,显然; 毕。 #include<bits/stdc++.h> #define rep(i,a,b) for(int i=(a);i<=(b);++i) #define per(i,a,b) for(int i = (a);i>=(b);--i) #define fo(i,a,b) for(int i =(a);i<(b);++i) #define de(x) cout<<#x<<" = "<<x<<endl; #define endl '\n' #define mem(a,b) memset(a,b,sizeof(a)); #define ls(p) ((p)<<1) #define rs(p) (((p)<<1)|1) using namespace std; typedef long long ll;

Codeforces Round #414, rated, Div. 1 + Div. 2 B. Cutting Carrot+【等腰三角形等比例缩小】

独自空忆成欢 提交于 2019-12-01 03:45:43
Codeforces Round #414, rated, Div. 1 + Div. 2 B. Cutting Carrot B. Cutting Carrot time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Igor the analyst has adopted n little bunnies. As we all know, bunnies love carrots. Thus, Igor has bought a carrot to be shared between his bunnies. Igor wants to treat all the bunnies equally, and thus he wants to cut the carrot into n pieces of equal area. Formally, the carrot can be viewed as an isosceles triangle with base length equal to 1 and height equal to h . Igor wants to make n  - 1 cuts

Educational Codeforces Round 74 (Rated for Div. 2)

拟墨画扇 提交于 2019-11-30 23:36:42
传送门 A. Prime Subtraction 判断一下是否相差为 \(1\) 即可。 B. Kill 'Em All 随便搞搞。 C. Standard Free2play 题意: 现在有一个高度为 \(h\) 的悬崖,每一层有平台,但可能是隐藏状态。 高度为 \(h\) 的那层平台一定是在外面的,假设当前高度为 \(x\) ,那么每次可以改变 \(x\) 和 \(x-1\) 层平台的状态。 规定一个人若从 \(x\) 掉到 \(x-1\) 或者 \(x-2\) 都没事,否则就出事了。 问最少改变多少平台的状态,能够使在 \(h\) 高度的人顺利到达地面(高度为 \(0\) )。 思路: 我大概模拟了一下这个过程,然后发现对于连续的 \(x,x-1,\cdots,x-k\) ,最终答案是否加一与 \(x\) 和 \(x-k\) 的奇偶性相关。 并且从 \(h_i\) 到 \(h_{i+1}\) ,假设中间有空平台,其实最后到达的是 \(h_{i+1}-1\) ,然后就这样模拟一下这个过程就行了。 注意一下细节:最后到地面的时候记得判断一下高度是否大于 \(2\) ,否则答案会加一。 代码如下: Code #include <bits/stdc++.h> #define MP make_pair #define fi first #define se second #define

Educational Codeforces Round 74 (Rated for Div. 2)【A,B,C【贪心】,D【正难则反的思想】】

久未见 提交于 2019-11-30 21:25:16
A. Prime Subtraction time limit per test2 seconds memory limit per test256 megabytes inputstandard input outputstandard output You are given two integers x and y (it is guaranteed that x>y). You may choose any prime integer p and subtract it any number of times from x. Is it possible to make x equal to y? Recall that a prime number is a positive integer that has exactly two positive divisors: 1 and this integer itself. The sequence of prime numbers starts with 2, 3, 5, 7, 11. Your program should solve t independent test cases. Input The first line contains one integer t (1≤t≤1000) — the number

Educational Codeforces Round 71 (Rated for Div. 2)

杀马特。学长 韩版系。学妹 提交于 2019-11-30 13:30:02
Educational Codeforces Round 71 (Rated for Div. 2) 比赛链接 C. Gas Pipeline 这道题目贪心边界比较多,所以我直接写了 \(DP\) ,设 \(dp[i][0/1]\) 表示当前修到第 \(i\) 段管道, \(0\) 是低高度, \(1\) 是高高度的最小花费。 转移非常简单,不过需要注意的是从高处往低处转移的时候,这次加的花费是高的高度的花费,因为这次加的是上一个支柱的高度,然后最后只能是低高度的答案。 #include<bits/stdc++.h> #define ll long long using namespace std; const int N=2e5+100; const ll INF=1e15; ll t,n,a,b; char s[N]; ll dp[N][2]; inline void work() { for (int i=0;i<=n;i++) dp[i][0]=dp[i][1]=INF; dp[0][0]=0; for (int i=1;i<=n;i++) if (s[i]=='0') { dp[i][0]=min(dp[i-1][0]+a+b,dp[i-1][1]+a*2+b*2); dp[i][1]=min(dp[i-1][0]+a*2+b*2,dp[i-1][1]+a+b*2); }

Educational Codeforces Round 73 (Rated for Div. 2) D. Make The Fence Great Again

狂风中的少年 提交于 2019-11-30 06:32:30
题目链接: http://codeforces.com/contest/1221/problem/D 题意:给一个序列,要求修改某些位置的数字,使得这个序列的相邻的数不相等,每次修改,只能使得某个数字加一,每次修改的代价为b【i】,求最小所需的代价。 解题思路:经过简单分析,我们可以知道,每个数字最多只需要修改两次,那么我们定义dp【i】【j】使得前j个数字相邻数字不等的最小代价,且最后一个数字修改了i次。那么答案即为min{dp【0】【n】,dp【1】【n】,dp【2】【n】}。 #include<bits/stdc++.h> using namespace std; typedef long long ll; const int maxn=3e5+5; const ll inf=1e18; ll dp[3][maxn]; int a[maxn],b[maxn]; int main(){ int q; scanf("%d",&q); while(q--){ int n; scanf("%d",&n); for(int i=0;i<n;i++){ scanf("%d%d",&a[i],&b[i]); dp[0][i]=inf; dp[1][i]=inf; dp[2][i]=inf; } dp[0][0]=0; dp[1][0]=b[0]*1ll; dp[2][0]=b[0]*2;

Educational Codeforces Round 73 (Rated for Div. 2)D(DP,思维)

半世苍凉 提交于 2019-11-30 06:14:05
#define HAVE_STRUCT_TIMESPEC #include<bits/stdc++.h> using namespace std; long long a[300007],b[300007]; long long dp[300007][5]; long long ans; int main(){ ios::sync_with_stdio(false);//多组数据输入cin,cout容易超时 cin.tie(NULL); cout.tie(NULL); int q; cin>>q; while(q--){ int n; ans=2e18; cin>>n; dp[1][0]=0;//第二维表示第一维增加的高度,0即不增加,花费也是0 dp[1][1]=b[1];//增加1高度花费为b[1] dp[1][2]=2e18;//第一个点最多只需要增加1高度就可以与a[2]不同,所以花费初始化为最大值 for(int i=2;i<=n;++i){//初始化 dp[i][0]=2e18; dp[i][1]=2e18; dp[i][2]=2e18; } for(int i=1;i<=n;++i) cin>>a[i]>>b[i]; for(int i=2;i<=n;++i){ for(int j=0;j<3;++j){ for(int k=0;k<3;++k){ if(k+a[i]