Codeforces 450 C. Jzzhu and Chocolate】的更多相关文章

//area=(n*m)/ ((x+1)*(k-x+1)) //1: x==0; //2: x=n-1 //3: x=m-1 # include <stdio.h> long long max(long long x,long long y) { return x>y? x:y; } int main() { long long n,m,k,sum,t,ans; scanf("%lld%lld%lld",&n,&m,&k); sum=n+m-2…
C. Jzzhu and Chocolate time limit per test: 1 seconds memory limit per test: 256 megabytes input: standard input output: standard output Jzzhu has a big rectangular chocolate bar that consists of \(n × m\) unit squares. He wants to cut this bar exact…
题意:给出f1=x,f2=y,f(i)=f(i-1)+f(i+1),求f(n)模上10e9+7 因为 可以求出通项公式:f(i)=f(i-1)-f(i-2) 然后 f1=x; f2=y; f3=y-x; f4=-x; f5=-y; f6=-y+x; f7=x; 发现是以6为循环的 还有注意下余数为正,就每次加上一个mod再模上mod #include<iostream> #include<cstdio> #include<cstring> #include <cm…
[链接] 我是链接,点我呀:) [题意] 题意 [题解] 设最后行分成了x行,列分成了y列. 那么答案就是floor(n/x)floor(n/y) 然后x+y-2=k //即平均分配x行.y列 我们可以枚举floor(n/x)的值 这个值其实就是n整除x 我们现在证明n/x的结果最多只可能有2sqrt(n)个 证明: 当x小于\(\sqrt{n}\)时,n/x的值有\(\sqrt{n}\)个. 当x大于\(\sqrt{n}\)时,n/x的结果肯定小于\(\sqrt{n}\),因此也只可能有\(\…
主题链接:http://codeforces.com/problemset/problem/449/A ---------------------------------------------------------------------------------------------------------------------------------------------------------- 欢迎光临天资小屋:http://user.qzone.qq.com/593830943…
C. Jzzhu and Chocolate time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Jzzhu has a big rectangular chocolate bar that consists of n × m unit squares. He wants to cut this bar exactly k time…
A - Jzzhu and Children Time Limit:1000MS     Memory Limit:262144KB     64bit IO Format:%I64d & %I64u Description There are n children in Jzzhu's school. Jzzhu is going to give some candies to them. Let's number all the children from 1 to n. The i-th…
Jzzhu and Chocolate time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Jzzhu has a big rectangular chocolate bar that consists of n × m unit squares. He wants to cut this bar exactly k times.…
题目链接:http://codeforces.com/contest/450/problem/C 题目意思:给出一个 n * m 大小的chocolate bar,你需要在这个bar上切 k 刀,使得最小的部分面积尽可能大,求出这个被划分后的最小部分面积最大可以为多少.如果这个chocolate bar 不能切成 k 部分,则输出-1.注意,每一刀需要符合3个条件:1.打横切或者打竖切: 2.每一刀只能经过unit square(即1*1的单元bar)的边,也就是说不能把一个单元bar损坏,要完…
http://codeforces.com/contest/450/problem/C 题意:一个n×m的矩形,然后可以通过横着切竖着切,求切完k次之后最小矩形面积的最大值. 思路:设k1为横着切的次数,k2为竖着切的次数,最后的面积的大小为s=n/(k1+1)*(m/(k2+1)); 只有(k1+1)*(k2+1)的最小时,s最大. #include <cstdio> #include <iostream> #include <cstring> #include &l…
职务地址:http://codeforces.com/contest/450/problem/C 这次CF的时候绝壁脑残了. ..A题和C题都出现了脑残失误... 唯一一个AC的B题还是被HACK了...分数也不多了...简直sad. . ..... . 这题我的思路是分类讨论.分四种情况. 首先让n>=m,假设不是的话,能够交换.主要是考虑切横的多少刀,竖的多少刀. 1:当k>n+m-2,此时,切不了那么多刀.输出-1. 2:当k>=n,此时.把长的那一段全切了,剩下的切短的. 3:当…
题目链接:http://codeforces.com/contest/450/problem/B 解题报告:f1 = x,f2 = y,另外有当(i >= 2) fi = fi+1 + fi-1,现在给出x和y,k,让你输出fn % (1e9+7) 对于这题我真想说细节决定一切,f的值一共只有6个,只要把f的值全部打表打出来了就可以直接得出任何一个fk的值. 但是注意x和y的范围都是小于10^9,所以当(x+y) % MOD的时候就会可能出现还是负数的情况,所以说交题之前最好测下极端的情况,因为…
CF#257 div2 C:http://codeforces.com/contest/450/problem/C 题意:n*m的方格,每次可以横着或者纵向的切一刀,问切k之后,最小的最大是多少. 题解:比赛的时候没有想到怎么处理,看了别人的题解,才恍然大悟.有一定的数学知识.最终块的大小平均来算是n(k1+1)*m/(k2+1),k1,k2分别表示横向切和纵向切的刀数,由于k1+k2==k,所以,要使得上述值最大,必须是(k1+1)*(k2+1)最小,就是让k1和k2 的差值越大即可.所以,我…
\(>Codeforces \space 555 C. Case of Chocolate<\) 题目大意 : 有一块 \(n \times n\) 的倒三角的巧克力,有一个人要吃 \(q\) 次,每一次从一个在对角线上的点出发,向左或者向上吃若干块,直到吃到已经被吃掉的格子为止,对于每一次吃巧克力的操作,输出这一次被吃掉了多少巧克力.(文字表达不够清晰,可以配合图片理解) \(1 ≤ n ≤ 10^9\ 1 ≤ q ≤ 2 \times 10^5\) 解题思路 : 询问可以转化为找到某一行或…
题目链接: C. Joty and Chocolate time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Little Joty has got a task to do. She has a line of n tiles indexed from 1 to n. She has to paint them in a stran…
C. Jzzhu and Apples time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Jzzhu has picked n apples from his big apple tree. All the apples are numbered from 1 to n. Now he wants to sell them to…
题目链接: B. Jzzhu and Sequences time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Jzzhu has invented a kind of sequences, they meet the following property: You are given x and y, please calculat…
题目链接: C. Mike and Chocolate Thieves time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Bad news came to Mike's village, some thieves stole a bunch of chocolates from the local factory! Horrib…
堆优化dijkstra,假设哪条铁路能够被更新,就把相应铁路删除. B. Jzzhu and Cities time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Jzzhu is the president of country A. There are n cities numbered from 1 to n in his co…
E. Jzzhu and Apples time limit per test: 1 seconds memory limit per test: 256 megabytes input: standard input output: standard output Jzzhu has picked \(n\) apples from his big apple tree. All the apples are numbered from \(1\) to \(n\). Now he wants…
D. Jzzhu and Cities time limit per test: 2 seconds memory limit per test: 256 megabytes input: standard input output: standard output Jzzhu is the president of country A. There are \(n\) cities numbered from \(1\) to \(n\) in his country. City \(1\)…
CF挂0了,简直碉堡了.两道题都是正确的思路但是写残了.写个解题报告记录一下心路历程. A题问的是 一个n*m的方块的矩形上切k刀,最小的那一块最大可以是多少.不难发现如果纵向切k1刀,横向切k2刀,那么答案应该是 (n/(k1+1)) * (m/(k2+1)),除法是取整的.虽然是取整,但是不难发现其实就是要(k1+1)*(k2+1)最小,根据均值不等式,k1+k2=k(定值) k1==k2的时候(k1+1)*(k2+1)=k1*k2+k1+k2+1=k1*k2+k+1应该是取最大值,所以当k…
Time Limit:2000MS     Memory Limit:262144KB     64bit IO Format:%I64d & %I64u   Description Bad news came to Mike's village, some thieves stole a bunch of chocolates from the local factory! Horrible! Aside from loving sweet things, thieves from this…
一道贪心题,尽量横着切或竖着切,实在不行在交叉切 #include<iostream> #include<stdio.h> using namespace std; int main(){ // freopen("in.txt","r",stdin); long long n,m,k; while(cin>>n>>m>>k){ if((n+m-2)<k){ printf("-1\n"…
今天老师(orz sansirowaltz)让我们做了很久之前的一场Codeforces Round #257 (Div. 1),这里给出A~C的题解,对应DIV2的C~E. A.Jzzhu and Chocolate time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Jzzhu has a big rectangular cho…
A - Jzzhu and Children 找到最大的ceil(ai/m)即可 #include <iostream> #include <cmath> using namespace std; int main(){ int n,m; cin >> n >> m; ; ; ; i < n; ++ i){ cin >> a; if(maxv <= ceil(a/m)){ maxv = ceil(a/m); maxIdx = i+;…
codeforces 627 D. Preorder Test 二分 + 树dp 做logn次树dp codeforces 578D.LCS Again 给出一个字符串str,长度n<=10^6,由m种字符组成,问有多少个长度为n,与str的LCS 为 n-1的字符串t 这道题可以用dp套dp,但是我不会阿 可以找规律统计,考虑: 1.取哪个位置 2.放在哪个位置 3.放什么字符 可以知道,如果str分成了block份,每一份的字符相同,则 ans = block * n * (m - 1) 但…
Problem A A. Jzzhu and Children time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output There are n children in Jzzhu's school. Jzzhu is going to give some candies to them. Let's number all the chi…
A .Jzzhu and Chocolate pro:现在给定一个大小为N*M的巧克力,让你横着或者竖着切K刀,都是切的整数大小,而且不能切在相同的地方,求最大化其中最小的块. (N,M,K<1e9) sol:如果横着切X刀,竖着切Y刀,那么最小的面积=(N/(X+1))*(M/(Y+1)):一看这个公式知道是整数分块了,相同的部分合并. 需要保证X<N,Y<M: #include<bits/stdc++.h> #define ll long long using names…
题目链接:http://codeforces.com/problemset/problem/450/A ---------------------------------------------------------------------------------------------------------------------------------------------------------- 欢迎光临天资小屋:http://user.qzone.qq.com/593830943…