結果

問題 No.1200 お菓子配り-3
ユーザー shauuebbit
提出日時 2022-09-05 21:39:22
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 930 bytes
コンパイル時間 2,039 ms
コンパイル使用メモリ 192,416 KB
最終ジャッジ日時 2025-02-07 02:56:19
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 29 WA * 2
権限があれば一括ダウンロードができます
コンパイルメッセージ
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);
      |         ~~~~~^~~~~~~~~~~~~~~~~~~~

ソースコード

diff #

#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;
        } 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;
}
0