Codeforces Round #584 A. Paint the Numbers】的更多相关文章

链接: https://codeforces.com/contest/1209/problem/A 题意: You are given a sequence of integers a1,a2,-,an. You need to paint elements in colors, so that: If we consider any color, all elements of this color must be divisible by the minimal element of thi…
链接: https://codeforces.com/contest/1209/problem/C 题意: You are given a sequence of n digits d1d2-dn. You need to paint all the digits in two colors so that: each digit is painted either in the color 1 or in the color 2; if you write in a row from left…
传送门 A. Paint the Numbers 签到. Code #include <bits/stdc++.h> using namespace std; typedef long long ll; const int N = 105; int n; int a[N]; bool used[N]; int main() { ios::sync_with_stdio(false); cin.tie(0); cin >> n; for(int i = 1; i <= n; i…
怎么老是垫底啊. 不高兴. 似乎 A 掉一道题总比别人慢一些. A. Paint the Numbers 贪心,从小到大枚举,如果没有被涂色,就新增一个颜色把自己和倍数都涂上. #include<bits/stdc++.h> #define fec(i, x, y) (int i = head[x], y = g[i].to; i; i = g[i].ne, y = g[i].to) #define dbg(...) fprintf(stderr, __VA_ARGS__) #define F…
题目链接: http://codeforces.com/problemset/problem/213/B B. Numbers time limit per test 2 secondsmemory limit per test 256 megabytes 问题描述 Furik loves writing all sorts of problems, especially such that he can't solve himself. You've got one of his proble…
A. Johny Likes Numbers 题目连接: http://www.codeforces.com/contest/678/problem/A Description Johny likes numbers n and k very much. Now Johny wants to find the smallest integer x greater than n, so it is divisible by the number k. Input The only line con…
C. Really Big Numbers time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Ivan likes to learn different things about numbers, but he is especially interested in really big numbers. Ivan thinks…
链接: https://codeforces.com/contest/1209/problem/E2 题意: This is a harder version of the problem. The difference is only in constraints. You are given a rectangular n×m matrix a. In one move you can choose any column and cyclically shift elements in th…
链接: https://codeforces.com/contest/1209/problem/D 题意: The legendary Farmer John is throwing a huge party, and animals from all over the world are hanging out at his house. His guests are hungry, so he instructs his cow Bessie to bring out the snacks!…
链接: https://codeforces.com/contest/1209/problem/B 题意: It is a holiday season, and Koala is decorating his house with cool lights! He owns n lights, all of which flash periodically. After taking a quick glance at them, Koala realizes that each of his…
-- A,B 先秒切,C 是个毒瘤细节题,浪费了很多时间后终于过了. D 本来是个 sb 题,然而还是想了很久,不过幸好没什么大事. E1,看了一会就会了,然而被细节坑死,好久才过. 感觉 E2 很可做,一直想 E2,结果想了大半了就最后一点没想出来. 此时 G1 更多人做了.然而我不会啊-- 没救了.掉分掉惨了. A 排个序,如果前面有它的约数就染成同色,否则开个新颜色. 下面这个代码,因为刚开始以为要输出方案,所以比较丑. #include<bits/stdc++.h> using nam…
Contest Page A sol 每次选最小的,然后把它的所有倍数都删掉. #include<bits/stdc++.h> using namespace std; int read(){ int a = 0; char c = getchar(); bool f = 0; while(!isdigit(c)){f = c == '-'; c = getchar();} while(isdigit(c)){ a = a * 10 + c - 48; c = getchar(); } ret…
题意:https://codeforc.es/problemset/problem/1209/E2 给你一个n(1-12)行m(1-2000)列的矩阵,每一列都可以上下循环移动(类似密码锁). 问你移动后,对每一行取最大值,这些最大值再加起来的MAX是多少. 思路: 1. 首先我们有一个思维上的优化,就是我们已知n很小,m会很大.我们按照每列最大的元素值为排序标准对列进行排序. 我们发现最多只会用到前n列(就是全取每列的最大值). 2. 枚举每列对行生效的数(就是该行这个数最大),也就是有2^n…
题意:https://codeforc.es/contest/1209/problem/D 有n个点心,有k个人,每个人都有喜欢的两个点心,现在给他们排个队,一个一个吃,每个人只要有自己喜欢的点心就会吃掉(不会留给后面的人). 如果有人什么都没吃就会不开心,问怎么安排使不开心的人最少. 思路: 看成一个图的问题,点心是节点,人是一条边.对于每个连通块,总会有一个人吃两个点心,其他人吃一个(其中一个是其他人也就吃掉了的). 可以保证这样是最优的,所有每个连通块的答案是连通数 x-1. #defin…
题目:https://codeforc.es/contest/1209/problem/G1 题意:给你一个序列,要你进行一些操作后把他变成一个好序列,好序列的定义是,两个相同的数中间的数都要与他相同,可以把某一种数统一变成另一个数,问最少变得个数 思路:我们可以考虑贪心,对于一个互相牵扯的区间,我肯定是用总长减掉里面出现次数最多的元素才是最划得来的,我们直接求出这些牵扯区间的长度即可,方法就是我用数组记录每个元素出现最右的位置,然后从左到右遍历,我保留当前区间往右延伸的最长位置,然后减去出现最…
#define HAVE_STRUCT_TIMESPEC#include<bits/stdc++.h>using namespace std;string s;pair<int,int>p[200007];int ans[200007];char b[200007];int main(){ int n; cin>>n; for(int i=1;i<=n;++i){ int m; cin>>m>>s; if(m==1){ cout<&l…
Codeforces Round #513 游记 A - Phone Numbers 题目大意: 电话号码是8开头的\(1\)位数字.告诉你\(n(n\le100)\)个数字,每个数字至多使用一次.问最多能凑出多少个电话号码. 思路: 统计8出现的次数,如果有多余的8不能作为开头,那么就将其放到后面去 源代码: #include<cstdio> #include<cctype> #include<algorithm> inline int getint() { regi…
题目传送门 /* 题意:n个数字转盘,刚开始每个转盘指向一个数字(0~n-1,逆时针排序),然后每一次转动,奇数的+1,偶数的-1,问多少次使第i个数字转盘指向i-1 构造:先求出使第1个指向0要多少步,按照这个次数之后的能否满足要求 题目读的好累:( */ #include <cstdio> #include <iostream> #include <algorithm> #include <cstring> #include <cmath>…
题目传送门 /* 构造:结构体排个序,写的有些啰嗦,主要想用用流,少些了判断条件WA好几次:( */ #include <cstdio> #include <algorithm> #include <cstring> #include <cmath> #include <vector> #include <map> #include <iostream> #include <string> using name…
Vus the Cossack has nn real numbers aiai. It is known that the sum of all numbers is equal to 00. He wants to choose a sequence bb the size of which is nn such that the sum of all numbers is 00 and each bibi is either ⌊ai⌋⌊ai⌋ or ⌈ai⌉⌈ai⌉. In other w…
CodeForces Round 199 Div2   完了,这次做扯了,做的时候有点发烧,居然只做出来一道题,差点被绿. My submissions     # When Who Problem Lang Verdict Time Memory 4434550 Sep 9, 2013 11:57:20 AM OIer E - Xenia and Tree GNU C++ Accepted 842 ms 4260 KB 4434547 Sep 9, 2013 11:56:11 AM OIer…
Codeforces Round #262 (Div. 2) 1004 D. Little Victor and Set time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Little Victor adores the sets theory. Let us remind you that a set is a group of…
Codeforces Round #270 1001 A. Design Tutorial: Learn from Math time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output One way to create a task is to learn from math. You can generate some random m…
Codeforces Round #346 (Div. 2)---E. New Reform E. New Reform time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Berland has n cities connected by m bidirectional roads. No road connects a city…
[Educational Codeforces Round 16]C. Magic Odd Square 试题描述 Find an n × n matrix with different numbers from 1 to n2, so the sum in each row, column and both main diagonals are odd. 输入 The only line contains odd integer n (1 ≤ n ≤ 49). 输出 Print n lines…
A. Contest time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Misha and Vasya participated in a Codeforces contest. Unfortunately, each of them solved only one problem, though successfully sub…
Codeforces Round #114 (Div. 2) 代码 Codeforces Round #114 (Div. 2) C. Wizards and Trolleybuses 思路 每条车的到达时间不会小于前一辆车,计算两者时间取最大值. D. Wizards and Huge Prize 思路 \(f(i, j, k)\)表示前\(i\)场比赛赢\(j\)场袋子与奖牌的差值为\(k\)的概率. E. Wizards and Numbers 假设\(a \le b\),那么最后会进入状…
Codeforces Round #112 (Div. 2) C. Another Problem on Strings 题意 给一个01字符串,求包含\(k\)个1的子串个数. 思路 统计字符1的位置,两端用0填充. \(k=0\)需要特判. 代码 C. Another Problem on Strings D. Beard Graph 题意 一棵\(N(N \le 10^5)\)个点的树,每条边被染成黑色或白色,初始都是黑色. \(M(M \le 3 \times 10^5)\)次操作,要么…
A. Sereja and Dima time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Sereja and Dima play a game. The rules of the game are very simple. The players have n cards in a row. Each card contains…
A. Uncowed Forces Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/604/problem/A Description Kevin Sun has just finished competing in Codeforces Round #334! The round was 120 minutes long and featured five problems with maxi…