結果
| 問題 |
No.1200 お菓子配り-3
|
| コンテスト | |
| ユーザー |
Kude
|
| 提出日時 | 2020-10-02 18:54:33 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 743 ms / 4,000 ms |
| コード長 | 1,257 bytes |
| コンパイル時間 | 1,973 ms |
| コンパイル使用メモリ | 195,460 KB |
| 最終ジャッジ日時 | 2025-01-14 23:58:08 |
|
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 31 |
ソースコード
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define chmax(a, b) a = max(a, b)
#define chmin(a, b) a = min(a, b)
#define all(x) (x).begin(), (x).end()
using namespace std;
using ll = long long;
using P = pair<int,int>;
using VI = vector<int>;
using VVI = vector<VI>;
vector<int> divs(int x) {
vector<int> res;
for(int i = 1; i * i <= x; ++i) {
if (x % i == 0) {
res.push_back(i);
if (i * i < x) {
res.push_back(x / i);
}
}
}
return res;
}
int main() {
int tt;
cin >> tt;
while(tt--) {
int x, y;
cin >> x >> y;
if (x == y) {
int ans = x - 1;
for(int d: divs(x)) {
if (d <= 2) continue;
++ans;
}
cout << ans << endl;
} else {
if (x < y) swap(x, y);
int p = x + y, q = x - y;
int ans = 0;
for(int d: divs(q)) {
int a = d + 1;
if (p % (a + 1) == 0) {
int s = p / (a + 1), t = q / (a - 1);
ans += s > t && s % 2 == t % 2;
}
}
cout << ans << endl;
}
}
}
Kude