http://codeforces.com/contest/450/problem/C
情况无外乎有:
1、刀数太多,-1;
2、全部切n边、全部切m边、n边切完切m边、m边切完切n边,不用想太多,直接取起最大值;
1 public class Main {
2
3 static int n, m, k;
4
5 public static void main(String[] args) {
6 IO io = new IO();
7 n = io.nextInt();
8 m = io.nextInt();
9 k = io.nextInt();
10
11 if (n-1+m-1<k)io.println(-1);
12 else {
13 long a=(n/(k+1));a*=m;
14 long b=(m/(k+1));b*=n;
15 int k1=k-(n-1);
16 long c=0;
17 if (k1+1>0) c=m/(k1+1);
18 int k2=k-(m-1);
19 long d=0;
20 if (k2+1>0) d=n/(k2+1);
21 io.println(Math.max(a,Math.max(b,Math.max(c,d))));
22 }
23 }
24
25
26 static class IO {
27
28 BufferedInputStream din;
29 final int BUFFER_SIZE = 1 << 16;
30 byte[] buffer;
31 int byteRead, bufferPoint;
32
33 StringBuilder builder;
34 PrintWriter pw;
35
36 public IO() {
37 din = new BufferedInputStream(System.in);
38 buffer = new byte[BUFFER_SIZE];
39 bufferPoint = byteRead = 0;
40
41 builder = new StringBuilder();
42 pw = new PrintWriter(new BufferedWriter(new OutputStreamWriter(
43 System.out
44 )), true);
45 }
46
47 int read() {
48 if (bufferPoint >= byteRead) {
49 try {
50 byteRead = din.read(buffer, bufferPoint = 0, BUFFER_SIZE);
51 } catch (IOException e) {
52 e.printStackTrace();
53 }
54 if (byteRead == -1) buffer[0] = -1;
55 }
56 return buffer[bufferPoint++];
57 }
58
59 int peek() {
60 if (byteRead == -1) return -1;
61 if (bufferPoint >= byteRead) {
62 try {
63 byteRead = din.read(buffer, bufferPoint = 0, BUFFER_SIZE);
64 } catch (IOException e) {
65 return -1;
66 }
67 if (byteRead <= 0) return -1;
68 }
69 return buffer[bufferPoint];
70 }
71
72 boolean hasNext() {
73 int c = peek();
74 while (c != -1 && c <= ' ') {
75 read();
76 c = peek();
77 }
78 return c != -1;
79 }
80
81 char nextChar() {
82 int c = read();
83 while (c == ' ' || c == '
' || c == '
' || c == ' ' || c == -1) {
84 c = read();
85 }
86 return (char) c;
87 }
88
89 double nextDouble() {
90 double ret = 0, div = 1;
91 int c = read();
92 while (c <= ' ')
93 c = read();
94 boolean neg = (c == '-');
95 if (neg)
96 c = read();
97 do {
98 ret = ret * 10 + c - '0';
99 }
100 while ((c = read()) >= '0' && c <= '9');
101 if (c == '.') {
102 while ((c = read()) >= '0' && c <= '9') {
103 ret += (c - '0') / (div *= 10);
104 }
105 }
106 if (neg)
107 return -ret;
108 return ret;
109 }
110
111 String nextLine() {
112 byte[] strBuf = new byte[64];
113 int cnt = 0, c;
114 while ((c = read()) != -1) {
115 if (c == '
') {
116 if (cnt == 0) {
117 continue;
118 } else {
119 break;
120 }
121 }
122 if (strBuf.length == cnt) {
123 strBuf = Arrays.copyOf(strBuf, strBuf.length * 2);
124 }
125 strBuf[cnt++] = (byte) c;
126 }
127 return new String(strBuf, 0, cnt);
128 }
129
130
131 String next() {
132 byte[] strBuf = new byte[64];
133 int cnt = 0, c;
134 while ((c = read()) != -1) {
135 if (Character.isWhitespace(c)) {
136 if (cnt == 0) {
137 continue;
138 } else {
139 break;
140 }
141 }
142 if (strBuf.length == cnt) {
143 strBuf = Arrays.copyOf(strBuf, strBuf.length * 2);
144 }
145 strBuf[cnt++] = (byte) c;
146 }
147 return new String(strBuf, 0, cnt);
148 }
149
150 int nextInt() {
151 int ans = 0;
152 int c = read();
153 while (c <= ' ') c = read();
154 boolean neg = (c == '-');
155 if (neg) c = read();
156 do {
157 ans = ans * 10 + c - '0';
158 } while ('0' <= (c = read()) && c <= '9');
159 bufferPoint--;
160 return neg ? -ans : ans;
161 }
162
163 long nextLong() {
164 long ans = 0;
165 int c = read();
166 while (c <= ' ') c = read();
167 boolean neg = (c == '-');
168 if (neg) c = read();
169 do {
170 ans = ans * 10 + c - '0';
171 } while ('0' <= (c = read()) && c <= '9');
172 bufferPoint--;
173 return neg ? -ans : ans;
174 }
175
176 void println(Object o) {
177 pw.println(o);
178 }
179
180 void print(Object o) {
181 pw.print(o);
182 }
183
184 void printf(String format, Object... objects) {
185 pw.printf(format, objects);
186 }
187
188 void close() {
189 pw.close();
190 }
191
192 void done(Object o) {
193 print(o);
194 close();
195 }
196
197 }
198 }