Codefroces 760 B. Frodo and pillows】的更多相关文章

B. Frodo and pillows time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output n hobbits are planning to spend the night at Frodo's house. Frodo has n beds standing in a row and m pillows (n ≤ m). Ea…
time limit per test1 second memory limit per test256 megabytes inputstandard input outputstandard output n hobbits are planning to spend the night at Frodo's house. Frodo has n beds standing in a row and m pillows (n ≤ m). Each hobbit needs a bed and…
题目链接:http://codeforces.com/problemset/problem/760/B 题意:n个床位,m个枕头,第k个位置最多有多少个枕头,其中相邻之间的差<=1; 第k个位置最大,那么两边只能是-1,-2,-3下走. 二分查找. #include <bits/stdc++.h> using namespace std; long long n,m,k; int Slove(long long mid) { ; if(k>=mid) { sum+=(+mid)*m…
http://codeforces.com/problemset/problem/760/B 题意:有n张床m个枕头,每张床可以有多个枕头,但是相邻的床的枕头数相差不能超过1,问第k张床最多能拥有的枕头数是多少.每张床至少有一个枕头. 思路:因为每张床至少需要一个枕头,所以先将m减掉n之后来考虑剩余枕头如何分配. 我们考虑一个最优的情况,假设有5张床,9个枕头,k为3的时候,那么这样分配:1 2 3 2 1,这样其实就如同阶梯一样,要让第k个最高,然后向两边递减. 我们可以二分答案,使用等差数列…
二分,判断条件就是最小情况(设当前k位取x)比剩余值(m-x)要小.(貌似又做麻烦了2333) #include<bits/stdc++.h> #define LL long long #define N 100005 using namespace std; inline int ra() { ,f=; char ch=getchar(); ; ch=getchar();} +ch-'; ch=getchar();} return x*f; } int n,m,k; bool check(L…
B. Frodo and pillows time limit per test:1 second memory limit per test:256 megabytes input:standard input output:standard output n hobbits are planning to spend the night at Frodo's house. Frodo has n beds standing in a row and m pillows (n ≤ m). Ea…
A. Petr and a calendar time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Petr wants to make a calendar for current month. For this purpose he draws a table in which columns correspond to wee…
A. Petr and a calendar time limit per test:2 seconds memory limit per test:256 megabytes input:standard input output:standard output Petr wants to make a calendar for current month. For this purpose he draws a table in which columns correspond to wee…
题目链接:http://codeforces.com/contest/760/problem/C 题意:一共有N个烤炉,有N个烤串,一开始正面朝上放在N个位子上.一秒之后,在位子i的串串会移动到pi位子上,并且如果bi为1,那么我们还要将烤串翻个面.现在要求每个烤串的正反两面要经历所有位置,然而现在的机制不一定能够完成任务,让你修改最少的操作,使得满足这个操作. 显然要满足只有一个环才能实现经历所有位置,而且要经历正反面所以一趟循环下来变化次数必须为奇数,不然回到原来位置时还是同样的朝向 #in…
Codefroces 1328E Tree Querie 题目 给出一棵1为根,n个节点的树,每次询问\(k_i\) 个节点,问是否存在这样一条路径: 从根出发,且每个节点在这条路径上或者距离路径的距离为1 题解 由于是从根出发的路径,所以 距离这条路径的距离为1=这个点的父亲在路径上 本身就在根出发的这条路径上,当然这个点的父亲也在路径上 这样我们就把两个条件统一了,转化问题为: 是否存在一条从根出发的路径,使所有点都在这条路径上 根据从根出发的路径的特点,我们根据深度,从小到大排序,每次看后…