結果

問題 No.1200 お菓子配り-3
ユーザー nawawannawawan
提出日時 2020-08-28 23:06:59
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
(最新)
AC  
(最初)
実行時間 -
コード長 1,225 bytes
コンパイル時間 688 ms
コンパイル使用メモリ 73,604 KB
実行使用メモリ 6,948 KB
最終ジャッジ日時 2024-04-27 00:37:59
合計ジャッジ時間 8,176 ms
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
6,816 KB
testcase_01 AC 2 ms
6,940 KB
testcase_02 AC 2 ms
6,944 KB
testcase_03 AC 2 ms
6,940 KB
testcase_04 AC 2 ms
6,944 KB
testcase_05 AC 2 ms
6,940 KB
testcase_06 AC 2 ms
6,940 KB
testcase_07 AC 6 ms
6,940 KB
testcase_08 AC 7 ms
6,940 KB
testcase_09 AC 6 ms
6,940 KB
testcase_10 AC 7 ms
6,940 KB
testcase_11 AC 7 ms
6,940 KB
testcase_12 AC 52 ms
6,940 KB
testcase_13 AC 54 ms
6,940 KB
testcase_14 AC 53 ms
6,944 KB
testcase_15 AC 54 ms
6,940 KB
testcase_16 AC 54 ms
6,940 KB
testcase_17 AC 195 ms
6,948 KB
testcase_18 AC 279 ms
6,940 KB
testcase_19 AC 65 ms
6,944 KB
testcase_20 AC 523 ms
6,940 KB
testcase_21 AC 511 ms
6,944 KB
testcase_22 AC 611 ms
6,940 KB
testcase_23 AC 516 ms
6,940 KB
testcase_24 AC 514 ms
6,940 KB
testcase_25 AC 501 ms
6,944 KB
testcase_26 AC 516 ms
6,940 KB
testcase_27 AC 1 ms
6,944 KB
testcase_28 AC 852 ms
6,944 KB
testcase_29 AC 615 ms
6,940 KB
testcase_30 AC 609 ms
6,940 KB
testcase_31 WA -
testcase_32 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
using namespace std;
vector<int> divisor(int n){//nの約数列挙
    vector<int> res;
    for(int i = 1; i * i <= n; i++){
        if(n % i == 0){
            res.push_back(i);
            if(i != n / i) res.push_back(n / i);
        }
    }
    return res;
}

int main(){
    int test;
    cin >> test;
    for(int counttest = 0; counttest < test; counttest++){
        int X, Y;
        cin >> X >> Y;
        int ans = 0;
        if(X < Y) swap(X, Y);
        if(X == Y){
            int t = X + Y;
            ans += t / 2 - 1;
            vector<int> d = divisor(t);
            for(int i = 0; i < (int)d.size(); i++){
                if(d[i] > 1 && t / d[i] > 2) ans++;
            }
            cout << ans << endl;
        }
        else{
            int t1 = X + Y, t2 = X - Y;
            vector<int> d1 = divisor(t1);
            for(int i = 0; i < (int)d1.size(); i++){
                if(d1[i] > 2){
                    int temp = d1[i] - 2;
                    if(t2 % temp == 0 && t1 / d1[i] > t2 / temp && (t1 / d1[i] + t2 / temp) % 2 == 0) ans++;
                }
            }
            cout << ans << endl;
        }
    }
}
0