結果

問題 No.1200 お菓子配り-3
ユーザー 👑 hos.lyrichos.lyric
提出日時 2020-08-29 00:57:49
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 2,071 bytes
コンパイル時間 807 ms
コンパイル使用メモリ 100,232 KB
実行使用メモリ 6,948 KB
最終ジャッジ日時 2024-04-27 00:57:42
合計ジャッジ時間 16,933 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,812 KB
testcase_01 AC 2 ms
6,944 KB
testcase_02 AC 3 ms
6,944 KB
testcase_03 AC 4 ms
6,940 KB
testcase_04 AC 3 ms
6,940 KB
testcase_05 AC 4 ms
6,940 KB
testcase_06 AC 3 ms
6,940 KB
testcase_07 AC 14 ms
6,944 KB
testcase_08 AC 15 ms
6,940 KB
testcase_09 AC 13 ms
6,940 KB
testcase_10 AC 13 ms
6,944 KB
testcase_11 AC 12 ms
6,944 KB
testcase_12 AC 107 ms
6,940 KB
testcase_13 AC 110 ms
6,940 KB
testcase_14 AC 109 ms
6,940 KB
testcase_15 AC 111 ms
6,940 KB
testcase_16 AC 109 ms
6,940 KB
testcase_17 AC 393 ms
6,940 KB
testcase_18 AC 563 ms
6,944 KB
testcase_19 AC 130 ms
6,940 KB
testcase_20 AC 1,088 ms
6,944 KB
testcase_21 AC 1,085 ms
6,944 KB
testcase_22 AC 1,282 ms
6,944 KB
testcase_23 AC 1,089 ms
6,944 KB
testcase_24 AC 1,072 ms
6,940 KB
testcase_25 AC 1,076 ms
6,944 KB
testcase_26 AC 1,081 ms
6,944 KB
testcase_27 AC 2 ms
6,940 KB
testcase_28 AC 852 ms
6,940 KB
testcase_29 AC 2,394 ms
6,940 KB
testcase_30 AC 2,399 ms
6,944 KB
testcase_31 WA -
testcase_32 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <cassert>
#include <cmath>
#include <cstdint>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

using namespace std;

using Int = long long;

template <class T1, class T2> ostream &operator<<(ostream &os, const pair<T1, T2> &a) { return os << "(" << a.first << ", " << a.second << ")"; };
template <class T> void pv(T a, T b) { for (T i = a; i != b; ++i) cerr << *i << " "; cerr << endl; }
template <class T> bool chmin(T &t, const T &f) { if (t > f) { t = f; return true; } return false; }
template <class T> bool chmax(T &t, const T &f) { if (t < f) { t = f; return true; } return false; }



int main() {
  int numCases;
  for (; ~scanf("%d", &numCases); ) {
    for (int caseId = 0; caseId < numCases; ++caseId) {
      Int X, Y;
      scanf("%lld%lld", &X, &Y);
      if (X > Y) {
        swap(X, Y);
      }
      
      Int ans = 0;
      if (X == Y) {
        auto check0 = [&](Int d) {
          if (d > 1) {
            ++ans;
          }
        };
        for (Int d = 1; d * d <= X; ++d) {
          if (X % d == 0) {
            check0(d);
            if (d != X / d) {
              check0(X / d);
            }
          }
        }
      } else {
        auto check = [&](Int d) {
          const Int a = d + 1;
          const Int denom = a * a - 1;
          const Int numerB = a * X - Y;
          const Int numerC = a * Y - X;
          if (numerB > 0 && numerC > 0 && numerB % denom == 0 && numerC % denom == 0) {
            ++ans;
          }
        };
        for (Int d = 1; d * d <= Y - X; ++d) {
          if ((Y - X) % d == 0) {
            check(d);
            if (d != (Y - X) / d) {
              check((Y - X) / d);
            }
          }
        }
      }
      printf("%lld\n", ans);
    }
  }
  return 0;
}
0