結果

問題 No.1200 お菓子配り-3
ユーザー umezoumezo
提出日時 2020-08-28 23:29:53
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 852 ms / 4,000 ms
コード長 850 bytes
コンパイル時間 783 ms
コンパイル使用メモリ 76,256 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-05-01 00:00:58
合計ジャッジ時間 8,232 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,816 KB
testcase_01 AC 2 ms
6,944 KB
testcase_02 AC 2 ms
6,940 KB
testcase_03 AC 2 ms
6,944 KB
testcase_04 AC 3 ms
6,940 KB
testcase_05 AC 2 ms
6,940 KB
testcase_06 AC 2 ms
6,944 KB
testcase_07 AC 7 ms
6,940 KB
testcase_08 AC 8 ms
6,944 KB
testcase_09 AC 6 ms
6,944 KB
testcase_10 AC 7 ms
6,940 KB
testcase_11 AC 7 ms
6,940 KB
testcase_12 AC 51 ms
6,940 KB
testcase_13 AC 54 ms
6,940 KB
testcase_14 AC 53 ms
6,944 KB
testcase_15 AC 52 ms
6,944 KB
testcase_16 AC 52 ms
6,940 KB
testcase_17 AC 184 ms
6,944 KB
testcase_18 AC 282 ms
6,940 KB
testcase_19 AC 61 ms
6,940 KB
testcase_20 AC 514 ms
6,944 KB
testcase_21 AC 505 ms
6,940 KB
testcase_22 AC 610 ms
6,944 KB
testcase_23 AC 510 ms
6,940 KB
testcase_24 AC 510 ms
6,940 KB
testcase_25 AC 516 ms
6,940 KB
testcase_26 AC 510 ms
6,940 KB
testcase_27 AC 1 ms
6,940 KB
testcase_28 AC 852 ms
6,944 KB
testcase_29 AC 615 ms
6,944 KB
testcase_30 AC 628 ms
6,944 KB
testcase_31 AC 2 ms
6,940 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 <iostream>
#include <vector>
using namespace std;

int main(){
  ios::sync_with_stdio(false);
  std::cin.tie(nullptr);
  
  int T;
  cin>>T;
  
  int x,y;
  while(T--){
    cin>>x>>y;
    
    if(x<y) swap(x,y);
    
    int s=x+y;
    int 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.emplace_back(s/i);
      }
    }
    
    int cnt=0;
    for(auto c:A){
      if(c==2){
        if(x!=y) continue;
        cnt+=x-1;
        continue;
      }
      if(t%(c-2)!=0) continue;
      int d=s/c;
      int 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