結果

問題 No.1203 お菓子ゲーム
ユーザー 259_Momone
提出日時 2020-08-28 23:06:45
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 298 ms / 2,000 ms
コード長 710 bytes
コンパイル時間 2,356 ms
コンパイル使用メモリ 191,868 KB
最終ジャッジ日時 2025-01-13 19:11:21
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 51
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:6:10: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
    6 |     scanf("%lu", &S);
      |     ~~~~~^~~~~~~~~~~
main.cpp: In lambda function:
main.cpp:8:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
    8 |         scanf("%lu%lu", &X, &Y);
      |         ~~~~~^~~~~~~~~~~~~~~~~~

ソースコード

diff #

#include <bits/stdc++.h>

int main(){
    using namespace std;
    unsigned long S;
    scanf("%lu", &S);
    for(unsigned long i{0}, X, Y; i < S; ++i)cout << [&X, &Y]() -> unsigned long {
        scanf("%lu%lu", &X, &Y);
        if(2 * X == Y)return 0;
        X = min(X, Y - X);
        unsigned long ret{0};
        ret += 100000000 / Y;
        const auto& possibleA = [&X, &Y](auto A){auto t{Y / A * (A + 1) * (A - 1) / 2}; return (A & 1) && t && t % X == 0 && t / X <= 100000000 && A < t / X;};
        for(unsigned long i{1}; i * i <= Y; ++i)if(Y % i == 0){
            ret += possibleA(i);
            if(i * i < Y)ret += possibleA(Y / i);
        }
        return ret;
    }() << endl;
    return 0;
}
0