結果

問題 No.1200 お菓子配り-3
ユーザー umezoumezo
提出日時 2020-08-28 23:15:26
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 3,199 ms / 4,000 ms
コード長 764 bytes
コンパイル時間 2,170 ms
コンパイル使用メモリ 201,648 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-08-13 06:01:03
合計ジャッジ時間 28,509 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 4 ms
4,384 KB
testcase_03 AC 4 ms
4,376 KB
testcase_04 AC 4 ms
4,380 KB
testcase_05 AC 4 ms
4,380 KB
testcase_06 AC 4 ms
4,376 KB
testcase_07 AC 21 ms
4,384 KB
testcase_08 AC 22 ms
4,376 KB
testcase_09 AC 20 ms
4,380 KB
testcase_10 AC 21 ms
4,376 KB
testcase_11 AC 22 ms
4,380 KB
testcase_12 AC 191 ms
4,380 KB
testcase_13 AC 195 ms
4,380 KB
testcase_14 AC 196 ms
4,380 KB
testcase_15 AC 196 ms
4,380 KB
testcase_16 AC 193 ms
4,380 KB
testcase_17 AC 698 ms
4,380 KB
testcase_18 AC 1,011 ms
4,376 KB
testcase_19 AC 232 ms
4,384 KB
testcase_20 AC 1,923 ms
4,376 KB
testcase_21 AC 1,894 ms
4,380 KB
testcase_22 AC 2,241 ms
4,380 KB
testcase_23 AC 1,906 ms
4,380 KB
testcase_24 AC 1,895 ms
4,376 KB
testcase_25 AC 1,884 ms
4,380 KB
testcase_26 AC 1,914 ms
4,380 KB
testcase_27 AC 1 ms
4,380 KB
testcase_28 AC 3,199 ms
4,380 KB
testcase_29 AC 2,346 ms
4,380 KB
testcase_30 AC 2,367 ms
4,380 KB
testcase_31 AC 1 ms
4,380 KB
testcase_32 AC 1 ms
4,376 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