1. 程式人生 > >Jzzhu and Chocolate 貪心

Jzzhu and Chocolate 貪心

一道貪心題,儘量橫著切或豎著切,實在不行在交叉切

#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");
            continue;
        }
        long long max=0,t;
        if(n>m){
            t=m;m=n;n=t;
        }
        long long ans;
        if(m>=(k+1)){
            ans=(n/(k+1)*m)>(m/(k+1)*n)?(n/(k+1)*m):(m/(k+1)*n);
        }
        else{
            ans=(m/(k-(n-1)+1))>(n/(k-(m-1)+1))?(m/(k-(n-1)+1)):(n/(k-(m-1)+1)) ;
        }
        cout<<ans<<endl;
    }
}

相關推薦

Jzzhu and Chocolate 貪心

一道貪心題,儘量橫著切或豎著切,實在不行在交叉切 #include<iostream> #include<stdio.h> using namespace std; int

hdu6060 RXD and dividing 貪心

iostream clu lan 並集 blank pri print mod str /** 題目:hdu6060 RXD and dividing 鏈接:http://acm.hdu.edu.cn/showproblem.php?pid=6060 題意:貪心 給定一顆

CF449D Jzzhu and Numbers (狀壓DP+容斥)

進行 狀態 位與 不能 gif using com 答案 {} 題目大意: 給出一個長度為n的序列,構造出一個序列使得它們的位與和為0,求方案數 也就是從序列裏面選出一個非空子集使這些數按位與起來為0. 看了好久才明白題解在幹嘛,我們先要表示出兩兩組合位與和為0的所有情況

[Codeforces 449B] Jzzhu and Cities

color class n) const make contest void inline lse [題目鏈接] https://codeforces.com/contest/449/problem/B [算法] 最短路

CF449C Jzzhu and Apples

用兩個 def problem type 做的 clu ons size mat 傳送門 這道題好像一開始想到了差不多的做法orz?後來都不大敢相信就是這麽做的……有點瞎搞。 後來看了CF的官方題解,感覺還是挺有道理的。首先對於1和大於n/2的質數肯定是不行的,我們直接忽略

【CodeForces - 689C】【Mike and Chocolate Thieves 】(二分)

題目: Bad news came to Mike's village, some thieves stole a bunch of chocolates from the local factory! Horrible! Aside from loving sweet things,

HDU 6438 Buy and Resell (貪心)

題意 給你 n {n} n天,一些物品,第

Codeforces 689C. Mike and Chocolate Thieves(二分)

題目連結:http://codeforces.com/contest/689/problem/C 題意:說實話,這個題的意思我愣了看了十多遍沒看懂,最後還是看的別人的題解明白的。        意思就是:有4個賊,他們共用一個容量為n的揹包,他們偷的東

1065A Vasya and Chocolate

題目 There is a special offer in Vasya’s favourite supermarket: if the customer buys a chocolate bars,he or she may take b additional bars for f

Jzzhu and Sequences題解

Jzzhu has invented a kind of sequences, they meet the following property: You are given x and y, please calculate fn&n

Codeforces Round 450 Div2 B.Jzzhu and Sequences

note meet ont out algorithm prop else if property http B. Jzzhu and Sequences time limit per test 1 second memory limit per test 256

Codeforces Round #252(Div. 2) 441B. Valera and Fruits 貪心

B. Valera and Fruits time limit per test 1 second memory limit per test 256 megabytes

hdu6188 Duizi and Shunzi(貪心)

思路來源 題意 有若干張牌,三個連續數字組成一個順子,兩個相同數字組成一個對, 求最大的順字數+對數。 題解 從最大到最小遍歷,能用兩個相同的構成對就構成對, 如果a[v]最後還剩一張,說明這張要被棄掉了; 再去看a[v-1]是不是奇數張,是的話說明

B. Jzzhu and Sequences (矩陣快速冪 + 取模)

題目連結 Jzzhu has invented a kind of sequences, they meet the following property:                       

A. Vasya and Chocolate

time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output There is a special of

Mike and Chocolate Thieves(二分 數論)

Bad news came to Mike’s village, some thieves stole a bunch of chocolates from the local factory! Horrible! Aside from loving sweet

CF 360E Levko and Game——貪心

題目:http://codeforces.com/contest/360/problem/E 官方題解與證明:http://codeforces.com/blog/entry/9529 一條可以調整的邊的邊權要麼是 l [ i ] 要麼是 r[ i ] 。 先把所有可調整邊設成 r[ i ] ,然後看看

HihoCoder 1631 Cats and Fish(貪心+模擬)

將吃魚的速度排序後,然後模擬每一秒內的吃魚情況 用一個數組來記錄每個貓是否在吃魚  #include<bits/stdc++.h> using namespace s

題解 CF450B 【Jzzhu and Sequences】

作為首A的人(?)我來發佈下這道大水題的題解了~ 首先題目給出了f[i]=f[i-1]+f[i+1],我們移下項: f[i+1]=f[i]-f[i-1],所以我們可以知道:第i項等於它前兩項之差! 即: f[i]=f[i-1]-f[i-2],同時,f[i-1]=f[i-2]-f[i-3],代入得: f[i

[CF351E]Jeff and Permutation——貪心

題目大意: 給出陣列a ,你可以改變每個數的正負,求逆序對數最少是多少 思路: 考慮一個數對\((a_i,a_j)\)的貢獻之和絕對值大的那個數字有關。 於是我們把每個數對的計算放在絕對值較大的那個數上面,不難發現這個位置產生的逆序對只和它自己本身的正負有關,直接BIT貪心就好了。 #include&