結果

問題 No.1200 お菓子配り-3
ユーザー chocoruskchocorusk
提出日時 2020-08-28 21:40:19
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 3,423 ms / 4,000 ms
コード長 1,171 bytes
コンパイル時間 1,238 ms
コンパイル使用メモリ 124,948 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-08-13 05:42:02
合計ジャッジ時間 29,123 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,384 KB
testcase_01 AC 2 ms
4,384 KB
testcase_02 AC 3 ms
4,380 KB
testcase_03 AC 3 ms
4,380 KB
testcase_04 AC 4 ms
4,380 KB
testcase_05 AC 4 ms
4,384 KB
testcase_06 AC 4 ms
4,384 KB
testcase_07 AC 23 ms
4,380 KB
testcase_08 AC 23 ms
4,380 KB
testcase_09 AC 22 ms
4,380 KB
testcase_10 AC 22 ms
4,380 KB
testcase_11 AC 23 ms
4,384 KB
testcase_12 AC 204 ms
4,380 KB
testcase_13 AC 208 ms
4,384 KB
testcase_14 AC 208 ms
4,380 KB
testcase_15 AC 209 ms
4,384 KB
testcase_16 AC 206 ms
4,380 KB
testcase_17 AC 745 ms
4,384 KB
testcase_18 AC 1,077 ms
4,380 KB
testcase_19 AC 249 ms
4,380 KB
testcase_20 AC 2,063 ms
4,380 KB
testcase_21 AC 2,068 ms
4,384 KB
testcase_22 AC 2,446 ms
4,380 KB
testcase_23 AC 2,060 ms
4,384 KB
testcase_24 AC 2,063 ms
4,380 KB
testcase_25 AC 2,055 ms
4,384 KB
testcase_26 AC 2,064 ms
4,384 KB
testcase_27 AC 1 ms
4,384 KB
testcase_28 AC 3,423 ms
4,384 KB
testcase_29 AC 2,513 ms
4,384 KB
testcase_30 AC 2,514 ms
4,384 KB
testcase_31 AC 1 ms
4,380 KB
testcase_32 AC 2 ms
4,380 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