Santa Claus and Tangerines】的更多相关文章

E. Santa Claus and Tangerines time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Santa Claus has n tangerines, and the i-th of them consists of exactly ai slices. Santa Claus came to a school…
E. Santa Claus and Tangerines time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Santa Claus has n tangerines, and the i-th of them consists of exactly ai slices. Santa Claus came to a school…
Santa Claus and Tangerines 题目链接:http://codeforces.com/contest/752/problem/E 二分 显然直接求答案并不是很容易,于是我们将其转化为判定性问题:二分解x,验证是否能分成k个x. 于是要点就在于check函数: 由于奇偶的原因,每个ai分出来的并不是2的幂次(比如当ai=11,x=3时,可以将ai分成3部分5,3,3). 但是稍作思考,可以发现还是与2的幂次有关: 例如,当ai=6:48,x=3时, ai part1 part…
E. Santa Claus and Tangerines time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Santa Claus has n tangerines, and the i-th of them consists of exactly ai slices. Santa Claus came to a school…
time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Santa Claus has n tangerines, and the i-th of them consists of exactly ai slices. Santa Claus came to a school which has k pupils. Santa dec…
题目链接:http://codeforces.com/contest/752/problem/E 题意:给n个橘子,每个橘子a(i)片,要分给k个人,问每个人最多分多少片.每个橘子每次对半分,偶数的话对半,奇数的话有一半会多一片. 二分答案,拿答案去判断.判断时记录dp(i)为橘子为i片的时候,最多分给多少人.枚举的时候从二分到的答案开始,由当前i的一半相加即可. #include <bits/stdc++.h> using namespace std; ; typedef long long…
http://codeforces.com/contest/752/problem/E 首先有一个东西就是,如果我要检测5,那么14我们认为它能产生2个5. 14 = 7 + 7.但是按照平均分的话,它是不能产生5的,那就把那两个7当成是两个5,因为7比5还大,对min(b[i])是没有影响的. 可以思考下样例2. 那么二分答案mid,设dp[val][x]表示val这个数字能产生多少个x.dp[val][x] = dp[val / 2][x] + dp[(val + 1) / 2][x] 那么…
题意:将n个蛋糕分给k个人,要保证每个人都有蛋糕或蛋糕块,蛋糕可切, 1.若蛋糕值为偶数,那一次可切成对等的两块. 2.若蛋糕值为奇数,则切成的两块蛋糕其中一个比另一个蛋糕值多1. 3.若蛋糕值为1,则不可切. 问每个人拥有的蛋糕中最小蛋糕值可能的最大值是多少. 分析: 1.若每个蛋糕都分成蛋糕值为1,即n个蛋糕的蛋糕值总和<k,则输出-1. 2.验证mid是否成立,若某蛋糕值x大于mid,则可切,并将该蛋糕可切成的块数保存在vis[x]中. 3.若mid为5,而x为11,则有必要切蛋糕x,若x…
D. Santa Claus and a Palindrome time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Santa Claus likes palindromes very much. There was his birthday recently. k of his friends came to him to co…
time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Santa Claus likes palindromes very much. There was his birthday recently. k of his friends came to him to congratulate him, and each of them…
time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Santa Claus has Robot which lives on the infinite grid and can move along its lines. He can also, having a sequence of m pointsp1, p2, ..., …
time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Santa Claus decided to disassemble his keyboard to clean it. After he returned all the keys back, he suddenly realized that some pairs of ke…
time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Santa Claus is the first who came to the Christmas Olympiad, and he is going to be the first to take his place at a desk! In the classroom t…
Santa Claus and a Palindrome 题目链接:http://codeforces.com/contest/752/problem/D 贪心 很自然地,可以想到,若subS不是回文串,那么只要贪心取subS中的最大值和reverse_subS中的最大值,若他们和大于零,则加入到结果回文序列中:而当subS本身就为回文串时,需要分类讨论(可以放在结果回文序列的最中间): 为了方便理解,定义: 若subS中的最大值与次大值的和小于零(或subS中只有一个值),那么称该最大值(或该…
C. Santa Claus and Robot time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Santa Claus has Robot which lives on the infinite grid and can move along its lines. He can also, having a sequence…
题目链接:http://codeforces.com/problemset/problem/752/C time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Santa Claus has Robot which lives on the infinite grid and can move along its lines. He…
/* Santa Claus is the first who came to the Christmas Olympiad, and he is going to be the first to take his place at a desk! In the classroom there are n lanes of m desks each, and there are two working places at each of the desks. The lanes are numb…
Santa Claus and a Palindrome Time Limit: 20 Sec  Memory Limit: 512 MB Description 有k个串,串长都是n,每个串有一个ai的贡献. 选出若干个串,若它们可以通过任意组合,形成一个回文串,则可以获得它们的贡献之和. 求最大贡献. Input 第一行两个整数k,n. 之后k行,每行分别是一个串si,与贡献ai. Output 一个整数表示答案. Sample Input 7 3 abb 2 aaa -3 bba -1 z…
题目: In your childhood you most likely had to solve the riddle of the house of Santa Claus. Do you remember that the importance was on drawing the house in a stretch without lifting the pencil and not drawing a line twice? As a reminder it has to look…
题面: 传送门 B. Santa Claus and Keyboard Check Input file: standard input Output file: standard output Time limit: 2 second Memory limit: 256 megabytes   Santa Claus decided to disassemble his keyboard to clean it. After he returned all the keys back, he su…
题目链接:http://codeforces.com/contest/752/problem/D 题意:给长度为k的n个字符串,每一个字符串有权值,求构造一个大回文串.使得权值最大. 因为字符串长度都一样,所以想构成回文串,必须两两配对,在中间加或者不加一个本身就是回文的字符串. 1.考虑非回文串的配对,把所有可以构成回文的非回文串凑起来,必须两两权值和>0才有意义.那么就扔到优先队列里配对. 2.考虑回文串的配对,配对成功的话要看下是不是两个回文串都是>0,如果不是,要额外在一个vector…
http://codeforces.com/contest/752/problem/C 这题的意思其实就是叫你固定x个点,使得按顺序走这x个点后,产生的轨迹是给定的序列. 对于有若干条最短路径走到第i个点,这些情况可以忽略,就是你可以默认走的是任意一条最短路径. 对于一个序列,可以固定两个方向,只要一直都是这两个方向的,就不用设置点了. 比如一直都是RURURURURU,这些情况是不用设置点的,当另一个变量来的时候,比如需要D了,就需要设置一个点了. 有一些需要注意的地方是, 比如 RLL,这样…
http://codeforces.com/contest/752/problem/B uuu yyu xy xx 注意变化了之后,检查一次前面已经变化过的就好.因为可能前面的满足,但是变了后不满足. #include <cstdio> #include <cstdlib> #include <cstring> #include <cmath> #include <algorithm> #include <assert.h> #def…
题意:从左下方1开始,一笔画出圣诞老人的屋子(不过话说,圣诞老人的屋子是这样的吗?这算是个屋子么),输出所有可以的路径. 思路:贴代码. #include <iostream> #include <stdio.h> #include <string.h> #include <algorithm> #include <queue> using namespace std; ],tot=,val;//val:用整型值存储结果,因为最后输出是要按大小排…
雅礼集训期间我好像考完试就开始划水了啊 给出k个长度相同的字符串,每个串有一个权值,选出一些串连成一个回文串.使得选中的串的总权值最大. 如果选一个串,必须同时选一个对称的串.还有一个特殊情况是可以在最中间放一个回文的串,求一下这种情况带来的额外的收入即可. 卡自然溢出hash....需要树同构那种奇奇怪怪的hash... #include <cstdio> #include <string> #include <iostream> #include <algor…
题意:从 节点1出发,一笔画出 圣诞老人的家(所谓一笔画,就是遍访所有边且每条边仅访问一次). 思路:深度优先搜索(DFS算法) #include<iostream> #include<string> #include<cstring> using namespace std; int map[6][6]; void makemap(){ memset(map,0,sizeof(map)); for(int i=1;i<=5;i++) for(int j=1;j&…
题意:给定一个机器人的行走路线,求最少的点能使得机器人可以走这样的路线. 析:每次行走,记录一个方向向量,每次只有是相反方向时,才会增加一个点,最后再加上最后一个点即可. 代码如下: #pragma comment(linker, "/STACK:1024000000,1024000000") #include <cstdio> #include <string> #include <cstdlib> #include <cmath> #…
题意:从左下方的1开始,一笔画出圣诞老人的房子. #include <iostream> #include <cstring> using namespace std; ][]; //已画了k条边 准备将端点x加入进来 void dfs(int x,int k,string s){ s+='); ){ cout<<s<<endl; return; } ;y<=;y++){ if(edge[x][y]){ edge[x][y]=edge[y][x]=;…
题目链接:http://codeforces.com/contest/752/problem/C 题意:给出一系列机器人的行动方向(机器人会走任意一条最短路径),问最少标记几个点能让机器人按这个 路径走下去. 显然最后位置肯定要标记,然后怎么使得点最少呢.首先标记一下起点由于机器人走的是最短路一旦第i个点到 标记点的距离小于第i-1个点到标记点的距离是肯定不能这么走,于是这时就要标记一下上个点的位置,统计数 加1. #include <iostream> #include <cstrin…
原来set,priority_queue也可以映射..涨姿势2333 比较麻烦的应该就是判断自身回文的串是选2个还是选一个吧. #include<bits/stdc++.h> #define INF 0x7fffffff #define LL long long #define N 100005 #define pill pair<int ,int > using namespace std; inline int ra() { ,f=; char ch=getchar(); ;…