結果
| 問題 |
No.1200 お菓子配り-3
|
| コンテスト | |
| ユーザー |
t33f
|
| 提出日時 | 2020-08-29 21:04:51 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 3,310 ms / 4,000 ms |
| コード長 | 728 bytes |
| コンパイル時間 | 692 ms |
| コンパイル使用メモリ | 64,644 KB |
| 実行使用メモリ | 6,820 KB |
| 最終ジャッジ日時 | 2024-11-20 23:06:47 |
| 合計ジャッジ時間 | 27,278 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 31 |
ソースコード
#include <iostream>
using namespace std;
bool check(int x, int y, int d) {
if (d < 3) return false;
bool ret = (x + y) % d == 0 && (x - y) % (d - 2) == 0 &&
(x + y) / d % 2 == (x - y) / (d - 2) % 2;
if (ret) {
int sum = (x + y) / d, diff = (x - y) / (d - 2);
if (sum > diff) return true;
}
return false;
}
int main() {
int s; cin >> s;
while (s--) {
int x, y; cin >> x >> y;
if (x < y) swap(x, y);
long long ans = 0;
if (x == y) ans += x - 1;
for (int d = 1; d * d <= x + y; d++) {
if (check(x, y, d)) ans++;
if (d * d < x + y && check(x, y, (x + y) / d)) ans++;
}
cout << ans << endl;
}
}
t33f