CodeForces 128D Numbers 构造】的更多相关文章

D. Numbers time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output One day Anna got the following task at school: to arrange several numbers in a circle so that any two neighboring numbers differs…
Codeforces 1041 E 构造题. 给出一种操作,对于一棵树,去掉它的一条边.那么这颗树被分成两个部分,两个部分的分别的最大值就是这次操作的答案. 现在给出一棵树所有操作的结果,问能不能构造这样一颗树,可以的话输出它. 反正就是看每个数出现了几次,然后形成一条链,从这个数开始,依次减小,链向N. 这样处理每个数,就行了. 中间一旦有冲突(不能形成链了),直接NO. #include <bits/stdc++.h> using namespace std; map<int,int…
C. Team time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Now it's time of Olympiads. Vanya and Egor decided to make his own team to take part in a programming Olympiad. They've been best fri…
Polycarp invited all his friends to the tea party to celebrate the holiday. He has ncups, one for each of his n friends, with volumes a1, a2, ..., an. His teapot stores wmilliliters of tea (w ≤ a1 + a2 + ... + an). Polycarp wants to pour tea in cups…
D. Beautiful numbers time limit per test 4 seconds memory limit per test 256 megabytes input standard input output standard output Volodya is an odd boy and his taste is strange as well. It seems to him that a positive integer number is beautiful if…
https://codeforces.com/problemset/problem/474/D 这道题挺好的,思路是这样. 我们要找一个01串,其中0的段要被划分为若干个连续k的0. 我们设想一个长度为n的合法串是怎么被构造出来的,要么是上一个合法串后面直接连接1,要么是上一个合法串后面连接k个连续的0,那么每个0一一对应于一段连续的0. 所以dp[i]=dp[i-1]+dp[i-k]. 想出来就觉得不难了. #include<bits/stdc++.h> using namespace st…
Every person likes prime numbers. Alice is a person, thus she also shares the love for them. Bob wanted to give her an affectionate gift but couldn't think of anything inventive. Hence, he will be giving her a graph. How original, Bob! Alice will sur…
来源:http://codeforces.com/problemset/problem/1265/B   B. Beautiful Numbers   You are given a permutation p=[p1,p2,…,pn]p=[p1,p2,…,pn] of integers from 11 to nn . Let's call the number mm (1≤m≤n1≤m≤n ) beautiful, if there exists two indices l,rl,r (1≤l…
题目链接:https://codeforces.com/contest/1368/problem/B 题意 构造最短的至少含有 $k$ 个 $codeforces$ 子序列的字符串. 题解 如下表:   c o d e f o r c e s 子序列个数 个数 1 1 1 1 1 1 1 1 1 1 $1^{10}$   2 2 2 2 2 2 2 2 2 2 $2^{10}$   3 3 3 3 3 3 3 3 3 3 $3^{10}$ 依次构造每个字符的个数即可. 证明   c o d e…
/* CF傻逼构造题 某人要经过n回合游戏,初始分值是2,等级为1. 每次有两种操作 1.无条件,分值加上自己的等级数. 2.当目前的数字是完全平方数并且该数字开方以后是等级数加1的整数倍,那么可以将分值开方,等价加一. 问:每个等级需要执行多少次第一种操作. 思路: 很显然每次要加到的那个数可以是相邻两个数的平方的积..但是考虑到最后这样刚好会超long long... 但是我们最终也不要求求这个数是多少,我们需要知道它除以i是多少... */ #include<bits/stdc++.h>…