結果
問題 | No.1200 お菓子配り-3 |
ユーザー |
![]() |
提出日時 | 2020-08-28 23:00:58 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
(最新)
AC
(最初)
|
実行時間 | - |
コード長 | 699 bytes |
コンパイル時間 | 677 ms |
コンパイル使用メモリ | 64,896 KB |
実行使用メモリ | 6,824 KB |
最終ジャッジ日時 | 2024-11-14 16:40:55 |
合計ジャッジ時間 | 16,888 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 29 WA * 2 |
ソースコード
#include <iostream>using namespace std;bool check(int x, int y, int d) {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 = 3; 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;}}