結果

問題 No.1200 お菓子配り-3
ユーザー chocoruskchocorusk
提出日時 2020-08-28 21:40:19
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 3,434 ms / 4,000 ms
コード長 1,171 bytes
コンパイル時間 1,356 ms
コンパイル使用メモリ 126,760 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-04-30 23:42:51
合計ジャッジ時間 28,705 ms
ジャッジサーバーID
(参考情報)
judge3 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,812 KB
testcase_01 AC 2 ms
6,940 KB
testcase_02 AC 4 ms
6,940 KB
testcase_03 AC 4 ms
6,940 KB
testcase_04 AC 4 ms
6,944 KB
testcase_05 AC 4 ms
6,944 KB
testcase_06 AC 4 ms
6,940 KB
testcase_07 AC 22 ms
6,944 KB
testcase_08 AC 24 ms
6,940 KB
testcase_09 AC 22 ms
6,940 KB
testcase_10 AC 22 ms
6,944 KB
testcase_11 AC 24 ms
6,944 KB
testcase_12 AC 202 ms
6,940 KB
testcase_13 AC 202 ms
6,944 KB
testcase_14 AC 204 ms
6,940 KB
testcase_15 AC 204 ms
6,944 KB
testcase_16 AC 202 ms
6,944 KB
testcase_17 AC 736 ms
6,944 KB
testcase_18 AC 1,054 ms
6,940 KB
testcase_19 AC 243 ms
6,944 KB
testcase_20 AC 2,026 ms
6,944 KB
testcase_21 AC 2,019 ms
6,944 KB
testcase_22 AC 2,410 ms
6,944 KB
testcase_23 AC 2,045 ms
6,944 KB
testcase_24 AC 2,043 ms
6,940 KB
testcase_25 AC 2,051 ms
6,940 KB
testcase_26 AC 2,055 ms
6,940 KB
testcase_27 AC 2 ms
6,940 KB
testcase_28 AC 3,434 ms
6,940 KB
testcase_29 AC 2,485 ms
6,940 KB
testcase_30 AC 2,510 ms
6,944 KB
testcase_31 AC 2 ms
6,944 KB
testcase_32 AC 2 ms
6,940 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <cassert>
#include <fstream>
#include <utility>
#include <functional>
#include <time.h>
#include <stack>
#include <array>
#define popcount __builtin_popcount
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
ll calc(ll a, ll s, ll x, ll y){
    if(a==0) return 0;
    if(a==1){
        if(x==y) return s-1;
      else return 0;
    }
    if(x<=s) return 0;
    if((x-s)%(a-1)==0 && (x-s)/(a-1)<s) return 1;
    else return 0;
}
ll solve(ll x, ll y){
    ll ans=0;
    for(ll i=1; i*i<=x+y; i++){
        if((x+y)%i!=0) continue;
        ll z=(x+y)/i;
        if(i>1){
            ans+=calc(i-1, z, x, y);
        }
        if(i*i<x+y){
            ans+=calc(z-1, i, x, y);
        }
    }
    return ans;
}
int main()
{
    int s; cin>>s;
    while(s--){
        ll x, y; cin>>x>>y;
        cout<<solve(x, y)<<endl;
    }
    return 0;
}

0