Codeforces Round #534 (Div. 2) Solution】的更多相关文章

A. Splitting into digits Solved. #include <bits/stdc++.h> using namespace std; int n; void solve() { printf("%d\n", n); ; i <= n; ++i) printf(, " \n"[i == n]); } int main() { while (scanf("%d", &n) != EOF) solve(…
从这里开始 题目列表 小结 Problem A Points on the line Problem B Our Tanya is Crying Out Loud Problem C Phone Numbers Problem D Alena And The Heater Problem E Cashback Problem F Machine Learning 小结 这场比赛和同学一起打.本来应该是很开心的事情,结果留下好多遗憾. 第一个遗憾是没能在20分钟内消灭A.B题.然后分数就不是很可观…
对没错下面的代码全部是python 3(除了E的那个multiset) 题目链接:https://codeforces.com/contest/1157 A. Reachable Numbers 按位算贡献,一位数的贡献直接算即可 n=int(input()) ans=0 while (n>=10): tmp=n%10 tmp=10-tmp ans+=tmp n+=tmp while (n>0) and (n%10==0): n//=10 ans+=9 print(ans) B. Long N…
人生第一场Div. 1 结果因为想D想太久不晓得Floyd判环法.C不会拆点.E想了个奇奇怪怪的set+堆+一堆乱七八糟的标记的贼难写的做法滚粗了qwq靠手速上分qwqqq A. Skyscrapers 将行列各自离散化并记录下每一个值在行离散化时和列离散化时得到的值以及每一行.每一列出现的最大离散化值 对于每一行和每一列考虑其相交格子的两个离散化值,如果它们的差为\(\Delta\),就把它对应行列最大离散化值中较小的+\(\Delta\),最后两者取Max #include<iostream…
D. Game with modulo time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output This is an interactive problem. Vasya and Petya are going to play the following game: Petya has some positive integer num…
从这里开始 题目地址 瞎扯 Problem A Piles With Stones Problem B And Problem C Photo of The Sky Problem D Chemical table Problem E Hills Problem F AB-Strings 瞎扯 打比赛,发现自己越来越菜. 差点C题都不会了,怀疑人生... 发现自己C的贪心挂了两次然后D题不会怀疑不应来打这场比赛. 然后看到E.出题人的仁慈啊..终于不考智商了.提高组的送分dp(好吧,应该是省选里…
A. Splitting into digits Vasya has his favourite number n. He wants to split it to some non-zero digits. It means, that he wants to choose some digits d1,d2,…,dk, such that 1≤di≤9 for all i and d1+d2+…+dk=n. Vasya likes beauty in everything, so he wa…
D. Game with modulo time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output This is an interactive problem. Vasya and Petya are going to play the following game: Petya has some positive integer num…
D. Game with modulo 题目链接:https://codeforces.com/contest/1104/problem/D 题意: 这题是一个交互题,首先一开始会有一个数a,你最终的目的是要将它猜出来. 每次询问会输出"? x y",然后有: "x" (without quotes), if (x % a)≥(y % a). "y" (without quotes), if (x % a)<(y % a). 最多给你60次…
从这里开始 比赛目录 我又不太会 div 1 A? 我菜爆了... Problem A Cut and Paste 暴力模拟一下. Code #include <bits/stdc++.h> using namespace std; typedef bool boolean; const int N = 1e6 + 5; const int Mod = 1e9 + 7; int T; int x; int len; char s[N]; int paste(int s1, int t1, in…
Problem A Hotelier 直接模拟即可~~ 复杂度是$O(10 \times n)$ # include<bits/stdc++.h> using namespace std; ; char s[N]; ]; int main() { int n; scanf("%d",&n); scanf("%s",s); ;i<n;i++) { if (s[i]=='L') { ;j<=;j++) if (!a[j]) { a[j]=…
题目传送门 https://codeforces.com/contest/1103/problem/D 题解 失去信仰的低水平选手的看题解的心路历程. 一开始看题目以为是选出一些数,每个数可以除掉一个不超过 \(k\) 的因数,使得被选出这些数的 \(\gcd\) 为 \(1\). 错的有点离谱.然后想了半天,想了一个奇怪的思路结果没有任何优化空间(因为选择的数不固定无法直接确定所有的质因子). 然后就开始看题解(事实上就算我没看错题目肯定也不会做). 以下为搬运题解内容. 我们可以先求出初始的…
题目传送门 https://codeforces.com/contest/1103/problem/C 题解 这个题还算一个有难度的不错的题目吧. 题目给出了两种回答方式: 找出一条长度 \(\geq \frac nk\) 的路径: 找出 \(k\) 个简单环,满足长度不是 \(3\) 的倍数,并且每个环至少存在一个点不在别的环中. 很显然题目并不是要你随便挑一种回答方式开始单独研究.最有可能的情况是两种回答方式可以替补. 如果我们随便作出原图的一棵生成树,如果最长的路径长度 \(\geq \f…
A 构造题 有一个44的方格 每次放入一个横向12或竖向2*1的方格 满了一行或一列就会消掉 求方案 不放最后一行 这样竖行就不会消 然后竖着的放前两行 横着的放第三行 循环放就可以啦 #include <cstdlib> #include <cstdio> #include <algorithm> #include <cmath> #include <cstring> const int N = 1e3 + 5; using namespace…
A. Ehab and another construction problem Water. #include <bits/stdc++.h> using namespace std; int x; int main() { while (scanf("%d", &x) != EOF) { , b = -; ; i <= x && a == - && b == -; ++i) { for (int j = i; j <=…
B. Game with string 题意: 给出一个字符串s只包括小写字母.当轮到一个玩家的时候,他可以选择两个连续且相等的字母并且删除它.当一个玩家没得删的时候他就输了. 题解: 乍一看有点懵,像dp,但是观察一下就发现输赢和顺序无关,只跟能组成相同的对数量有关,这个数量是一定的.那么我们用栈扫一遍就好了. #include <cstdio> #include <cstring> #include <algorithm> #include <iostream…
A. A Prank Solved. 题意: 给出一串数字,每个数字的范围是$[1, 1000]$,并且这个序列是递增的,求最多擦除掉多少个数字,使得别人一看就知道缺的数字是什么. 思路: 显然,如果缺的这块数字的个数刚好等于右界 - 左界 + 1 那么就可以知道 还需要考虑数据范围,因为是$<= 1000  和 >= 1$ 那么对于两边的边界需要特殊考虑. #include <bits/stdc++.h> using namespace std; #define N 110 in…
A. Coins Water. #include <bits/stdc++.h> using namespace std; int n, s; int main() { while (scanf("%d%d", &n, &s) != EOF) { ; ; --i) while (s >= i) { ++res; s -= i; } printf("%d\n", res); } ; } B. Views Matter Solved.…
A. Petya and Origami Water. #include <bits/stdc++.h> using namespace std; #define ll long long ll n, k; ll Get(ll x) { ? (x * n) / k : (x * n) / k + ; } int main() { while (scanf("%lld%lld", &n, &k) != EOF) { ll res = Get() + Get()…
A. The Fair Nut and Elevator Solved. 签. #include <bits/stdc++.h> using namespace std; #define N 110 int n, a[N]; int main() { while (scanf("%d", &n) != EOF) { ; i <= n; ++i) scanf("%d", a + i); int res = 1e9; , tmp = ; x &…
A. Snowball 签. #include <bits/stdc++.h> using namespace std; ], d[]; int main() { while (scanf("%d%d", &w, &h) != EOF) { ; i < ; ++i) scanf("%d%d", u + i, d + i); ; --i) { w += i; ; j < ; ++j) if (i == d[j]) { w -=…
A. Roman and Browser 签到. #include <bits/stdc++.h> using namespace std; ]; int get(int b) { ]; memset(vis, , sizeof vis); int c = b; while (c <= n) { vis[c] = ; c += k; } c = b - k; ) { vis[c] = ; c -= k; } , r = ; ; i <= n; ++i) if (!vis[i]) {…
A. Salem and Sticks 签. #include <bits/stdc++.h> using namespace std; #define N 1010 int n, a[N]; int work(int x) { ; ; i <= n; ++i) res += max(, abs(x - a[i]) - ); return res; } int main() { while (scanf("%d", &n) != EOF) { ; i <…
传送门 A.The Doors 看懂题目就会写的题 给一个 $01$ 序列,找到最早的位置使得 $0$ 或 $1$ 已经全部出现 #include<iostream> #include<cstdio> #include<algorithm> #include<cstring> #include<cmath> using namespace std; typedef long long ll; inline int read() { ,f=; ch…
先二分一个区间,再在区间里面二分即可: 可以仔细想想,想明白很有意思的: #include<iostream> #include<cstdio> #include<algorithm> #include<cstdlib> #include<cstring> #include<string> #include<cmath> #include<map> #include<set> #include<…
菜是原罪. 英语不好更是原罪. \(\mathrm{A - Grid game}\) 题解 \(4 \times 4\) 的格子,两种放法. 发现这两种在一起时候很讨厌,于是强行拆分这个格子 上面 \(2 \times 4\) 给横的,下面给竖的. \(\mathrm{Code}\) #include<bits/stdc++.h> using namespace std; template <typename Tp> void read(Tp &x){ x=0;char c…
从这里开始 比赛目录 我菜爆了. Problem A As Simple as One and Two 我会 AC 自动机上 dp. one 和 two 删掉中间的字符,twone 删掉中间的 o. Code #include <bits/stdc++.h> using namespace std; typedef bool boolean; const int N = 2e5 + 5; template <typename T> boolean vmin(T& a, T…
标签(空格分隔): 经验 题解 时量 : 2h 概括 : \[\text{2min t1 }\\ \text{10min t2 (hacked)}\\ \text{30min t3 }\\ \text{over 1h t4(false) }\\ \text{rating down : 30pts}\\ \] t1.t2.t3.t4都是一眼题 最大的收获是在cf不要随意使用memset(t2 hack) t4 错在想当然的把第一个质因子当作最多的了... A 求一个排列\(p_i\),使 \(p_…
A. Extreme Subtraction 把这个数组差分一下,发现操作一的作用是把 \(d_1\) 的大小分给 \(d_i\),而操作二的作用是把 \(d_i\) 减去任意值,目标是把 \(d\) 的值都变为 \(0\).对于 \(d\) 中大于 \(0\) 的值,就直接用操作二就行了:对于小于 \(0\) 的值,那它只能用 \(d_1\) 补偿:所以就比较一下 \(b_1\) 和 \(- \sum\limits_{i=2}^n[b_i<0]\times b_i\)的大小就行了. B. Id…
A. Knapsack 猜个结论--先把所有的东西加起来,如果小于 \(\frac{1}{2}m\) 就输出不合法:如果在 \([\frac{1}{2}m, m]\)之间直接全部输出:若大于 \(m\),那就想办法把他减到 \(m\) 以下并且大于等于 \(\frac{1}{2}m\),那么问题就转化为了求序列减完以后大于等于 \(\frac{1}{2}m\) 的情况下的最小值.那我们排个序,从大到小循环,把当前能减的都减掉就是了. for (int i = n; i; i--) { //fou…