結果
| 問題 |
No.1200 お菓子配り-3
|
| コンテスト | |
| ユーザー |
shauuebbit
|
| 提出日時 | 2022-09-05 21:45:47 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 3,325 ms / 4,000 ms |
| コード長 | 1,152 bytes |
| コンパイル時間 | 2,199 ms |
| コンパイル使用メモリ | 193,256 KB |
| 最終ジャッジ日時 | 2025-02-07 02:57:19 |
|
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 31 |
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:7:10: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
7 | scanf("%d", &S);
| ~~~~~^~~~~~~~~~
main.cpp:11:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
11 | scanf("%lld%lld", &X, &Y);
| ~~~~~^~~~~~~~~~~~~~~~~~~~
ソースコード
#include <bits/stdc++.h>
using namespace std;
int main() {
int S;
scanf("%d", &S);
while (S--) {
long long X, Y;
scanf("%lld%lld", &X, &Y);
if (X < Y) swap(X, Y);
long long ans = 0;
if (X == Y) {
ans += X - 1;
for (long long x = 1; x * x <= X; x++) {
if (X % x) continue;
long long y = X / x;
if (x > 2) ++ans;
if (x != y && y > 2) ++ans;
}
} else {
for (long long x = 2; x * x <= X + Y; x++) {
if ((X + Y) % x) continue;
long long y = (X + Y) / x;
if (x > 2 && (X - Y) % (x - 2) == 0) {
long long b = (X + Y) / x, c = (X - Y) / (x - 2);
if (b > c && b % 2 == c % 2) ++ans;
}
if (x != y && y > 2 && (X - Y) % (y - 2) == 0) {
long long b = (X + Y) / y, c = (X - Y) / (y - 2);
if (b > c && b % 2 == c % 2) ++ans;
}
}
}
printf("%lld\n", ans);
}
return 0;
}
shauuebbit