結果

問題 No.1200 お菓子配り-3
ユーザー shauuebbitshauuebbit
提出日時 2020-08-28 22:32:25
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
WA  
(最新)
AC  
(最初)
実行時間 -
コード長 836 bytes
コンパイル時間 4,131 ms
コンパイル使用メモリ 171,344 KB
実行使用メモリ 4,508 KB
最終ジャッジ日時 2023-08-09 09:13:58
合計ジャッジ時間 11,520 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 2 ms
4,380 KB
testcase_04 AC 2 ms
4,376 KB
testcase_05 AC 3 ms
4,380 KB
testcase_06 AC 3 ms
4,380 KB
testcase_07 AC 8 ms
4,380 KB
testcase_08 AC 8 ms
4,380 KB
testcase_09 AC 8 ms
4,376 KB
testcase_10 AC 7 ms
4,384 KB
testcase_11 AC 8 ms
4,376 KB
testcase_12 AC 62 ms
4,376 KB
testcase_13 AC 62 ms
4,376 KB
testcase_14 AC 62 ms
4,380 KB
testcase_15 AC 63 ms
4,380 KB
testcase_16 AC 62 ms
4,380 KB
testcase_17 AC 219 ms
4,376 KB
testcase_18 AC 316 ms
4,380 KB
testcase_19 AC 73 ms
4,384 KB
testcase_20 AC 602 ms
4,380 KB
testcase_21 AC 609 ms
4,380 KB
testcase_22 AC 716 ms
4,376 KB
testcase_23 AC 604 ms
4,384 KB
testcase_24 AC 603 ms
4,380 KB
testcase_25 AC 601 ms
4,380 KB
testcase_26 AC 606 ms
4,380 KB
testcase_27 WA -
testcase_28 AC 947 ms
4,380 KB
testcase_29 AC 714 ms
4,380 KB
testcase_30 AC 718 ms
4,380 KB
testcase_31 WA -
testcase_32 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>

const long long INF = 1e15;

using namespace std;

int main(){
  int S;
  cin >> S;
  
  while(S--){
    int X, Y;
    cin >> X >> Y;
    
    set<int> s;
    for(int i = 1; i * i <= X + Y; i++){
      if((X + Y) % i == 0){
        s.insert(i);
        s.insert((X + Y) / i);
      }
    }
    
    long long ans = 0;
    for(int d : s){
      int A = d - 1;
      if(A == 0) continue;
      
      if(A == 1){
        if(X == Y) ans += 2;
        continue;
      }
      
      int ok = (X + Y) / d, ng = 0;
      while(ok - ng > 1){
        int mid = (ok + ng) >> 1;
        
        if(X <= A * mid + (X + Y) / d - mid) ok = mid;
        else ng = mid;
      }
      
      if(A * ok + (X + Y) / d - ok == X && A * ((X + Y) / d - ok) + ok == Y) ++ans;
    }
    
    cout << ans << endl;
  }
  
  return 0;
}
0