結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,812 KB
testcase_01 AC 2 ms
6,940 KB
testcase_02 AC 3 ms
6,940 KB
testcase_03 AC 5 ms
6,944 KB
testcase_04 AC 4 ms
6,940 KB
testcase_05 AC 3 ms
6,940 KB
testcase_06 AC 4 ms
6,940 KB
testcase_07 AC 16 ms
6,940 KB
testcase_08 AC 14 ms
6,940 KB
testcase_09 AC 11 ms
6,944 KB
testcase_10 AC 16 ms
6,940 KB
testcase_11 AC 8 ms
6,944 KB
testcase_12 AC 113 ms
6,940 KB
testcase_13 AC 107 ms
6,940 KB
testcase_14 AC 103 ms
6,940 KB
testcase_15 AC 106 ms
6,940 KB
testcase_16 AC 104 ms
6,944 KB
testcase_17 AC 403 ms
6,944 KB
testcase_18 AC 487 ms
6,940 KB
testcase_19 AC 132 ms
6,944 KB
testcase_20 AC 1,171 ms
6,944 KB
testcase_21 AC 1,193 ms
6,944 KB
testcase_22 AC 1,362 ms
6,940 KB
testcase_23 AC 1,167 ms
6,948 KB
testcase_24 AC 1,166 ms
6,944 KB
testcase_25 AC 1,167 ms
6,940 KB
testcase_26 AC 1,160 ms
6,944 KB
testcase_27 AC 3 ms
6,944 KB
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
testcase_31 -- -
testcase_32 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
using namespace std;
#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
vector<int> divisor(int n){//nの約数列挙
    vector<int> res;
    for(int i = 1; i * i <= n; i++){
        if(n % i == 0){
            res.emplace_back(i);
            if(i != n / i) res.emplace_back(n / i);
        }
    }
    return res;
}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    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