結果
問題 |
No.1200 お菓子配り-3
|
ユーザー |
![]() |
提出日時 | 2020-08-29 16:16:35 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 841 ms / 4,000 ms |
コード長 | 791 bytes |
コンパイル時間 | 2,822 ms |
コンパイル使用メモリ | 191,168 KB |
最終ジャッジ日時 | 2025-01-13 20:23:17 |
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 31 |
コンパイルメッセージ
main.cpp: In function ‘int main()’: main.cpp:5:21: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 5 | int s; scanf("%d", &s); | ~~~~~^~~~~~~~~~ main.cpp:7:32: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 7 | int x, y; scanf("%d%d", &x, &y); | ~~~~~^~~~~~~~~~~~~~~~
ソースコード
#include <bits/stdc++.h> using namespace std; int main() { int s; scanf("%d", &s); for (int z = 0; z < s; ++z) { int x, y; scanf("%d%d", &x, &y); if (x == y) { int ans = x-1; for (int i = 1; i*i <= x; ++i) { if (x%i != 0) continue; if (i > 2) ans++; if (i*i < x and x/i > 2) ans++; } printf("%d\n", ans); continue; } if (x < y) swap(x, y); int ans = 0; for (int i = 1; i*i <= x-y; ++i) { if ((x-y) % i != 0) continue; if ((x+y) % (i+2) == 0) { int p = (x-y) / i; int q = (x+y) / (i+2); if (p < q and p%2 == q%2) ans++; } if (i*i == x-y) continue; int j = (x-y)/i; if ((x+y) % (j+2) == 0) { int p = (x-y) / j; int q = (x+y) / (j+2); if (p < q and p%2 == q%2) ans++; } } printf("%d\n", ans); } return 0; }