結果

問題 No.1200 お菓子配り-3
ユーザー shauuebbit
提出日時 2022-09-05 21:16:04
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 1,394 bytes
コンパイル時間 1,784 ms
コンパイル使用メモリ 193,652 KB
最終ジャッジ日時 2025-02-07 02:55:20
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
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) {
            if ((X + Y) % 2 == 0) {
                ans += (X + Y) / 2 - 1;

                for (long long x = 2; x * x <= (X + Y) / 2; x++) {
                    if ((X + Y) % (x * 2)) continue;

                    long long y = (X + Y) / (x * 2);

                    if (x > 2 && y > 1) {
                        ++ans;
                    }

                    if (x != y && y > 2 && x > 1) {
                        ++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;
}
0