Submission #57437


ソースコード

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
vector< LL > Div(LL n) {
vector< LL > div;
for( LL i = 1; i * i <= n; ++i ) {
if( n % i == 0 ) {
div.push_back(i);
if( i * i != n ) {
div.push_back(n / i);
}
}
}
sort(div.begin(), div.end());
return div;
}
int main() {
LL h, w;
cin >> h >> w;
LL n;
cin >> n;
LL s = h * w;
if( s == n ) {
cout << 0 << endl;
return 0;
}
if( s < n ) {
cout << -1 << endl;
return 0;
}
if( (h == 1 && w > n) || (h > n && w == 1) ) {
cout << 1 << endl;
return 0;
}
if( n == h || n == w ) {
cout << 1 << endl;
return 0;
}
vector< LL > div = Div(n);
int l = 0, r = div.size() - 1;
while( l <= r ) {
if( (div[l] <= h && div[r] <= w) ) {
if( div[l] == h || div[r] == w ) {
cout << 1;
} else {
cout << 2;
}
cout << endl;
return 0;
} else if( div[l] <= w && div[r] <= h ) {
if( div[l] == w || div[r] == h ) {
cout << 1;
} else {
cout << 2;
}
cout << endl;
return 0;
}
++l; --r;
}
cout << -1 << endl;
return 0;
}

ステータス

項目 データ
問題 1228 - Chocolate
ユーザー名 ei1903
投稿日時 2019-12-16 15:49:47
言語 C++14
状態 Accepted
得点 100
ソースコード長 1497 Byte
最大実行時間 28 ms
最大メモリ使用量 848 KB

セット

セット 得点 Cases
1 task1 30 / 30 in01*
2 task2 70 / 70 in*

テストケース

ファイル名 状態 実行時間 メモリ使用量 #
in01-01.txt AC 28 ms 604 KB
1
2
in01-02.txt AC 21 ms 576 KB
1
2
in01-03.txt AC 24 ms 416 KB
1
2
in01-04.txt AC 21 ms 512 KB
1
2
in01-05.txt AC 21 ms 364 KB
1
2
in01-06.txt AC 27 ms 336 KB
1
2
in01-07.txt AC 17 ms 432 KB
1
2
in01-08.txt AC 21 ms 524 KB
1
2
in01-09.txt AC 27 ms 500 KB
1
2
in01-10.txt AC 20 ms 464 KB
1
2
in01-11.txt AC 25 ms 440 KB
1
2
in01-12.txt AC 24 ms 416 KB
1
2
in01-13.txt AC 20 ms 648 KB
1
2
in01-14.txt AC 19 ms 616 KB
1
2
in02-01.txt AC 28 ms 588 KB
2
in02-02.txt AC 22 ms 556 KB
2
in02-03.txt AC 23 ms 656 KB
2
in02-04.txt AC 15 ms 628 KB
2
in02-05.txt AC 21 ms 728 KB
2
in02-06.txt AC 25 ms 572 KB
2
in02-07.txt AC 28 ms 548 KB
2
in02-08.txt AC 25 ms 516 KB
2
in02-09.txt AC 26 ms 612 KB
2
in02-10.txt AC 25 ms 584 KB
2
in02-11.txt AC 20 ms 684 KB
2
in02-12.txt AC 22 ms 528 KB
2
in02-13.txt AC 15 ms 504 KB
2
in02-14.txt AC 19 ms 476 KB
2
in02-15.txt AC 20 ms 448 KB
2
in02-16.txt AC 23 ms 552 KB
2
in02-17.txt AC 22 ms 652 KB
2
in02-18.txt AC 18 ms 620 KB
2
in02-19.txt AC 22 ms 848 KB
2
in02-20.txt AC 25 ms 692 KB
2
sample01.txt AC 20 ms 528 KB
sample02.txt AC 21 ms 500 KB
sample03.txt AC 17 ms 728 KB