結果
問題 | No.338 アンケート機能 |
ユーザー |
|
提出日時 | 2016-02-03 13:19:53 |
言語 | C++11 (gcc 13.3.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,007 bytes |
コンパイル時間 | 530 ms |
コンパイル使用メモリ | 59,612 KB |
実行使用メモリ | 5,376 KB |
最終ジャッジ日時 | 2024-09-21 20:07:48 |
合計ジャッジ時間 | 4,791 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 19 WA * 9 |
ソースコード
#include <iostream> #include <vector> #include <algorithm> #define MIN (1000) #define MIN5 (500) int gcd(int a, int b) { if (b == 0) return a; return gcd(b, a % b); } int f(int A, int B) { int rc = A + B; int a = (A * MIN) - MIN5; int b = (B * MIN) - MIN5; int aa = (A * MIN) + MIN5; int bb = (B * MIN) + MIN5; for (int n = a; n < aa; n++) { for (int m = b; m < bb; m++) { int r = gcd(n, m); if (r > 1) { int nn = n / r; int mm = m / r; int rr = nn + mm; if (rr < rc) { int nnn = ((nn * 1000 / rr) + 5) / 10; int mmm = ((mm * 1000 / rr) + 5) / 10; if (nnn == A && mmm == B) { rc = rr; } } } } } return rc; } int main() { int A, B; std::cin >> A; std::cin >> B; std::cout << f(A,B) << std::endl; return 0; }