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

题目链接: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…
二分,判断条件就是最小情况(设当前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…
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个枕头,每张床可以有多个枕头,但是相邻的床的枕头数相差不能超过1,问第k张床最多能拥有的枕头数是多少.每张床至少有一个枕头. 思路:因为每张床至少需要一个枕头,所以先将m减掉n之后来考虑剩余枕头如何分配. 我们考虑一个最优的情况,假设有5张床,9个枕头,k为3的时候,那么这样分配:1 2 3 2 1,这样其实就如同阶梯一样,要让第k个最高,然后向两边递减. 我们可以二分答案,使用等差数列…
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…
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…
上一次我们拿学校的URP做了个小小的demo.... 其实我们还可以把每个学生的证件照爬下来做成一个证件照校花校草评比 另外也可以写一个物理实验自动选课... 但是出于多种原因,,还是绕开这些敏感话题.. 今天,我们来扒一下cf的题面! PS:本代码不是我原创 1. 必要的分析 1.1 页面的获取 一般情况CF的每一个 contest 是这样的: 对应的URL是:http://codeforces.com/contest/xxx 还有一个Complete problemset页面,它是这样的:…
http://codeforces.com/contest/738/problem/D Galya is playing one-dimensional Sea Battle on a 1 × n grid. In this game a ships are placed on the grid. Each of the ships consists of bconsecutive cells. No cell can be part of two ships, however, the shi…