結果

問題 No.1200 お菓子配り-3
ユーザー umezoumezo
提出日時 2020-08-28 23:15:26
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 3,179 ms / 4,000 ms
コード長 764 bytes
コンパイル時間 2,012 ms
コンパイル使用メモリ 204,560 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-04-30 23:59:53
合計ジャッジ時間 27,741 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
6,812 KB
testcase_01 AC 2 ms
6,944 KB
testcase_02 AC 4 ms
6,940 KB
testcase_03 AC 3 ms
6,940 KB
testcase_04 AC 4 ms
6,944 KB
testcase_05 AC 4 ms
6,940 KB
testcase_06 AC 4 ms
6,944 KB
testcase_07 AC 21 ms
6,944 KB
testcase_08 AC 22 ms
6,944 KB
testcase_09 AC 21 ms
6,940 KB
testcase_10 AC 21 ms
6,940 KB
testcase_11 AC 22 ms
6,940 KB
testcase_12 AC 195 ms
6,940 KB
testcase_13 AC 198 ms
6,940 KB
testcase_14 AC 196 ms
6,940 KB
testcase_15 AC 200 ms
6,940 KB
testcase_16 AC 203 ms
6,940 KB
testcase_17 AC 688 ms
6,940 KB
testcase_18 AC 1,007 ms
6,940 KB
testcase_19 AC 232 ms
6,940 KB
testcase_20 AC 1,928 ms
6,940 KB
testcase_21 AC 1,937 ms
6,944 KB
testcase_22 AC 2,277 ms
6,940 KB
testcase_23 AC 1,919 ms
6,940 KB
testcase_24 AC 1,929 ms
6,944 KB
testcase_25 AC 1,921 ms
6,940 KB
testcase_26 AC 1,926 ms
6,944 KB
testcase_27 AC 1 ms
6,944 KB
testcase_28 AC 3,179 ms
6,940 KB
testcase_29 AC 2,359 ms
6,944 KB
testcase_30 AC 2,326 ms
6,944 KB
testcase_31 AC 2 ms
6,944 KB
testcase_32 AC 2 ms
6,940 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ALL(v) v.begin(), v.end()
typedef long long ll;

#include <bits/stdc++.h>
using namespace std;

int main(){
  int T;
  cin>>T;
  
  ll x,y;
  while(T--){
    cin>>x>>y;
    
    if(x<y) swap(x,y);
    
    ll s=x+y;
    ll t=x-y;

    vector<ll> A;
    for(int i=2;i*i<=s;i++){
      if(s%i==0){
        A.push_back(i);
        if(i*i!=s) A.push_back(s/i);
      }
    }
    
    ll cnt=0;
    for(auto c:A){
      if(c==2){
        if(x!=y) continue;
        cnt+=x-1;
        continue;
      }
      if(t%(c-2)!=0) continue;
      ll d=s/c;
      ll e=t/(c-2);
      if(d%2 != e%2) continue;
      if(d+e<2 || d-e<2) continue;
      cnt++;
    }
    cout<<cnt<<endl;
    A.clear();

  }

  return 0;
}
0