日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

Jzzhu and Chocolate(CF-449A)

發布時間:2025/3/17 编程问答 23 豆豆
生活随笔 收集整理的這篇文章主要介紹了 Jzzhu and Chocolate(CF-449A) 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

Problem Description

Jzzhu has a big rectangular chocolate bar that consists of n?×?m unit squares. He wants to cut this bar exactly k times. Each cut must meet the following requirements:

each cut should be straight (horizontal or vertical);
each cut should go along edges of unit squares (it is prohibited to divide any unit chocolate square with cut);
each cut should go inside the whole chocolate bar, and all cuts must be distinct.
The picture below shows a possible way to cut a 5?×?6 chocolate for 5 times.

Imagine Jzzhu have made k cuts and the big chocolate is splitted into several pieces. Consider the smallest (by area) piece of the chocolate, Jzzhu wants this piece to be as large as possible. What is the maximum possible area of smallest piece he can get with exactly k cuts? The area of a chocolate piece is the number of unit squares in it.

Input

A single line contains three integers n, m, k (1 ≤ n, m ≤ 109; 1 ≤ k ≤ 2·109).

Output

Output a single integer representing the answer. If it is impossible to cut the big chocolate k times, print -1.

Examples

Input

3 4 1

Output

6

Input

6 4 2

Output

8

Input

2 3 4

Output

-1

Note

In the first sample, Jzzhu can cut the chocolate following the picture below:

In the second sample the optimal division looks like this:

In the third sample, it's impossible to cut a?2?×?3?chocolate?4?times.

題意:輸入 n,m,k,代表一個 n*m 的矩陣要切 k 次,問切完后最小的單元格的最大值

思路:

假設橫向切了 x-1 次,縱向切了 y-1 次,那么橫著就分為 x 份,縱著就分為 y 份

于是結果即為:res=(n/x)*(m/y),而題目所給范圍為:1<=x<=n,1<=y<=m,(x-1)+(y-1)=k

顯然:(n+m-2)<k 時無解,(n+m-2)=k 時值為 1

可以考慮先枚舉 n/x 的值,那么對于固定的取值,可以選出最大的 x,使得此時 m/y 最大;然后再枚舉? n/y?的值,那么對于固定的取值,可以選出最大的 y,使得此時 n/x?最大,最后取兩者最大值即可

我們將 y=k+2-x 代入?res=(n/x)*(m/y) 中可得到分母是一個二元函數:-y^2+2*y+ky,那么要讓原式最大,就要讓分母最小,因此不需枚舉 x、y 的值,直接令 x、y 分別最小即可

Source Program

#include<iostream> #include<cstdio> #include<cstdlib> #include<string> #include<cstring> #include<cmath> #include<ctime> #include<algorithm> #include<utility> #include<stack> #include<queue> #include<vector> #include<set> #include<map> #define PI acos(-1.0) #define E 1e-9 #define INF 0x3f3f3f3f #define LL long long const int MOD=1e9+7; const int N=10+5; const int dx[]= {-1,1,0,0}; const int dy[]= {0,0,-1,1}; using namespace std; int main(){int n,m,k;cin>>n>>m>>k;LL res=0;if( (n-1)+(m-1)<k )//刀數多于切口數res=-1;else if( (n-1)+(m-1)==k )//刀數等于切口數res=1;else{LL x=min(n-1,k);//令x最小res=max( res, (n/(x+1))*(m/(k+1-x)) );LL y=min(m-1,k);//令y最小res=max( res, (m/(y+1))*(n/(k+1-y)) );}cout<<res<<endl;return 0; }

?

新人創作打卡挑戰賽發博客就能抽獎!定制產品紅包拿不停!

總結

以上是生活随笔為你收集整理的Jzzhu and Chocolate(CF-449A)的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。

主站蜘蛛池模板: 哺乳援交吃奶在线播放 | 久久婷婷激情 | 精品人妻无码在线 | 亚洲一区视频在线播放 | 在线视频黄 | 亚洲欧美国产另类 | 欧美日韩中 | 午夜av网站 | 动漫一区二区三区 | 蜜桃av免费在线观看 | a级黄色在线观看 | 在线观看香蕉视频 | 精国产人伦一区二区三区 | 国产女厕一区二区三区在线视 | 国产精品欧美综合亚洲 | 成人亚洲天堂 | 日日麻批免费视频播放 | 特黄aaaaaaa片免费视频 | www.色图| 香蕉视频在线观看网站 | 91视频区 | 花房姑娘免费全集 | 一区二区三区人妻 | 日本xxx高清 | 亚洲欧洲在线播放 | 能在线观看的av网站 | 欧美在线一区二区三区 | www.蜜臀| 亚洲我射 | 久久国产精品精品国产 | 苍井空张开腿实干12次 | 国产美女作爱视频 | 欧美日韩中文在线视频 | 激情偷乱人成视频在线观看 | 亚洲精品中文字幕成人片 | 永久免费在线看片 | 黄色片免费在线播放 | 精品乱子伦 | 国产免费av片在线观看 | 非洲黑寡妇性猛交视频 | 真实乱视频国产免费观看 | 成人a在线观看 | 超碰免费观看 | 51自拍视频 | 欧美 日韩 国产 高清 | 九九超碰 | 91大神小宝寻花在线观看 | 天天综合人人 | 蜜臀av免费一区二区三区水牛 | 色91视频 | 99精品久久久久久久婷婷 | 天天天天干 | 日本综合久久 | 久草精品视频 | 黑丝国产一区 | 久久精品成人一区二区三区蜜臀 | 大肉大捧一进一出视频 | 青青草国产精品 | 美女的隐私免费看 | 亚洲人人干 | 国产精品v日韩精品v在线观看 | av福利在线看| 国产乡下妇女三片 | 久久噜噜 | 国产综合一区二区 | 欧洲精品久久久久毛片完整版 | 韩国久久久久 | 亚洲国产精品天堂 | 麻豆蜜桃在线观看 | 天天爽夜夜爽一区二区三区 | 久久免费国产视频 | 日韩欧美中文字幕一区二区三区 | 亚洲三级国产 | 涩涩亚洲| 超碰超碰超碰超碰超碰 | 在线免费观看 | 婷婷视频在线观看 | 美乳人妻一区二区三区 | 欧美老肥妇做爰bbww | 一区二区三区啪啪啪 | 国产18在线观看 | 国产乱色精品成人免费视频 | 国产v片在线观看 | 精品国产精品三级精品av网址 | 激情久久五月天 | 黄色网址在线看 | 亚洲永久av | 国产尤物在线视频 | 日韩一区二区不卡视频 | 国产粉嫩在线观看 | 汗汗视频 | 午夜啪啪福利 | 精品人伦一区二区 | 亚洲天堂成人网 | 天天干狠狠干 | 亚洲三级免费观看 | 韩国成人在线 | 欧美亚洲色综久久精品国产 | 另类在线视频 |