結果

問題 No.1200 お菓子配り-3
ユーザー KKT89KKT89
提出日時 2020-08-28 21:54:57
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
WA  
(最新)
AC  
(最初)
実行時間 -
コード長 845 bytes
コンパイル時間 1,695 ms
コンパイル使用メモリ 97,452 KB
実行使用メモリ 4,388 KB
最終ジャッジ日時 2023-08-09 08:11:28
合計ジャッジ時間 10,160 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,384 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 2 ms
4,384 KB
testcase_03 AC 2 ms
4,384 KB
testcase_04 AC 3 ms
4,380 KB
testcase_05 AC 2 ms
4,380 KB
testcase_06 AC 2 ms
4,384 KB
testcase_07 AC 8 ms
4,380 KB
testcase_08 AC 9 ms
4,384 KB
testcase_09 AC 8 ms
4,380 KB
testcase_10 AC 7 ms
4,384 KB
testcase_11 AC 8 ms
4,384 KB
testcase_12 AC 62 ms
4,380 KB
testcase_13 AC 62 ms
4,380 KB
testcase_14 AC 64 ms
4,384 KB
testcase_15 AC 65 ms
4,384 KB
testcase_16 AC 64 ms
4,384 KB
testcase_17 AC 228 ms
4,380 KB
testcase_18 AC 328 ms
4,384 KB
testcase_19 AC 77 ms
4,388 KB
testcase_20 AC 624 ms
4,380 KB
testcase_21 AC 626 ms
4,380 KB
testcase_22 AC 744 ms
4,380 KB
testcase_23 AC 628 ms
4,384 KB
testcase_24 AC 631 ms
4,384 KB
testcase_25 AC 625 ms
4,384 KB
testcase_26 AC 629 ms
4,384 KB
testcase_27 AC 1 ms
4,380 KB
testcase_28 AC 1,032 ms
4,384 KB
testcase_29 AC 769 ms
4,384 KB
testcase_30 AC 759 ms
4,384 KB
testcase_31 WA -
testcase_32 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <math.h>
#include <map>
using namespace std;
typedef long long int ll;

ll X,Y;

ll count_res(ll i,ll j){
    if(j<2)return 0;
    ll a=i-1;
    if(a==1){
        if(X-j!=0||Y-j!=0)return 0;
        return j-2;
    }
    else{
        if((X-j)%(a-1))return 0;
        if((Y-j)%(a-1))return 0;
        ll b=(X-j)/(a-1);
        ll c=(Y-j)/(a-1);
        return b>=1&&c>=1&&b+c==j;
    }
}


int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int q; cin >> q;
    while(q--){
        cin >> X >> Y;
        int x=X+Y;
        ll res=0;
        for(int i=2;i*i<=x;i++){
            if(x%i==0){
                res+=count_res(i,x/i);
                if(x/i!=i)res+=count_res(x/i,i);
            }
        }
        cout << res << "\n";
    }
}
0