結果

問題 No.1200 お菓子配り-3
ユーザー nawawannawawan
提出日時 2020-08-28 23:04:18
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
WA  
(最新)
AC  
(最初)
実行時間 -
コード長 1,377 bytes
コンパイル時間 887 ms
コンパイル使用メモリ 75,960 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-08-09 09:52:17
合計ジャッジ時間 9,379 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,384 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 3 ms
4,376 KB
testcase_03 AC 2 ms
4,380 KB
testcase_04 AC 2 ms
4,376 KB
testcase_05 AC 2 ms
4,376 KB
testcase_06 AC 2 ms
4,380 KB
testcase_07 AC 7 ms
4,380 KB
testcase_08 AC 8 ms
4,376 KB
testcase_09 AC 8 ms
4,380 KB
testcase_10 AC 8 ms
4,380 KB
testcase_11 AC 8 ms
4,376 KB
testcase_12 AC 58 ms
4,380 KB
testcase_13 AC 59 ms
4,380 KB
testcase_14 AC 58 ms
4,380 KB
testcase_15 AC 58 ms
4,380 KB
testcase_16 AC 58 ms
4,376 KB
testcase_17 AC 202 ms
4,380 KB
testcase_18 AC 294 ms
4,380 KB
testcase_19 AC 68 ms
4,380 KB
testcase_20 AC 567 ms
4,380 KB
testcase_21 AC 566 ms
4,376 KB
testcase_22 AC 672 ms
4,384 KB
testcase_23 AC 565 ms
4,380 KB
testcase_24 AC 555 ms
4,380 KB
testcase_25 AC 567 ms
4,376 KB
testcase_26 AC 562 ms
4,380 KB
testcase_27 AC 2 ms
4,380 KB
testcase_28 AC 920 ms
4,376 KB
testcase_29 AC 684 ms
4,380 KB
testcase_30 AC 692 ms
4,376 KB
testcase_31 WA -
testcase_32 WA -
権限があれば一括ダウンロードができます

ソースコード

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