結果
問題 | No.1200 お菓子配り-3 |
ユーザー | cn_449 |
提出日時 | 2020-08-28 21:55:49 |
言語 | C++17 (gcc 12.3.0 + boost 1.83.0) |
結果 |
AC
|
実行時間 | 923 ms / 4,000 ms |
コード長 | 2,212 bytes |
コンパイル時間 | 1,421 ms |
コンパイル使用メモリ | 130,640 KB |
実行使用メモリ | 4,384 KB |
最終ジャッジ日時 | 2023-08-13 05:46:21 |
合計ジャッジ時間 | 9,958 ms |
ジャッジサーバーID (参考情報) |
judge12 / judge15 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 2 ms
4,380 KB |
testcase_01 | AC | 1 ms
4,384 KB |
testcase_02 | AC | 3 ms
4,380 KB |
testcase_03 | AC | 2 ms
4,384 KB |
testcase_04 | AC | 2 ms
4,384 KB |
testcase_05 | AC | 2 ms
4,384 KB |
testcase_06 | AC | 2 ms
4,384 KB |
testcase_07 | AC | 7 ms
4,380 KB |
testcase_08 | AC | 8 ms
4,384 KB |
testcase_09 | AC | 7 ms
4,384 KB |
testcase_10 | AC | 8 ms
4,380 KB |
testcase_11 | AC | 7 ms
4,380 KB |
testcase_12 | AC | 57 ms
4,380 KB |
testcase_13 | AC | 58 ms
4,380 KB |
testcase_14 | AC | 58 ms
4,380 KB |
testcase_15 | AC | 58 ms
4,380 KB |
testcase_16 | AC | 57 ms
4,384 KB |
testcase_17 | AC | 204 ms
4,380 KB |
testcase_18 | AC | 294 ms
4,380 KB |
testcase_19 | AC | 69 ms
4,380 KB |
testcase_20 | AC | 559 ms
4,380 KB |
testcase_21 | AC | 560 ms
4,380 KB |
testcase_22 | AC | 667 ms
4,384 KB |
testcase_23 | AC | 559 ms
4,380 KB |
testcase_24 | AC | 560 ms
4,384 KB |
testcase_25 | AC | 558 ms
4,384 KB |
testcase_26 | AC | 560 ms
4,384 KB |
testcase_27 | AC | 2 ms
4,384 KB |
testcase_28 | AC | 923 ms
4,380 KB |
testcase_29 | AC | 680 ms
4,384 KB |
testcase_30 | AC | 681 ms
4,380 KB |
testcase_31 | AC | 2 ms
4,380 KB |
testcase_32 | AC | 2 ms
4,384 KB |
ソースコード
#include <iostream> #include <vector> #include <algorithm> #include <cmath> #include <string> #include <queue> #include <stack> #include <set> #include <map> #include <iomanip> #include <utility> #include <tuple> #include <functional> #include <bitset> #include <cassert> #include <complex> #include <stdio.h> #include <time.h> #include <numeric> #include <random> #include <unordered_map> #include <unordered_set> #define all(a) a.begin(),a.end() #define rep(i, n) for (ll i = 0; i < (n); i++) #define pb push_back #define debug(x) cerr << __LINE__ << ' ' << #x << ':' << x << '\n' #pragma GCC optimize("O3") #pragma GCC optimize("unroll-loops") using namespace std; typedef long long ll; typedef unsigned long long ull; typedef long double ld; typedef pair<ll, ll> P; typedef complex<ld> com; constexpr int inf = 1000000010; constexpr ll INF = 1000000000000000010; constexpr ld eps = 1e-12; constexpr ld pi = 3.141592653589793238; template<class T, class U> inline bool chmax(T &a, const U &b) { if (a < b) { a = b; return true; } return false; } template<class T, class U> inline bool chmin(T &a, const U &b) { if (a > b) { a = b; return true; } return false; } int main() { cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20); int t; cin >> t; while (t--) { int x, y; cin >> x >> y; int sum = x + y; if (x == y) { int ans = x - 1; if (x % 2 == 0) ans--; vector<int> check; for (int i = 1; i * i <= x; i++) { if (x % i == 0) { check.pb(i); if (i * i != x) check.pb(x / i); } } for (int b : check) { int a = x / b - 1; if (a > 0) ans++; } cout << ans << '\n'; } else { if (x < y) swap(x, y); int ans = 0; vector<int> check; for (int i = 1; i * i <= sum; i++) { if (sum % i == 0) { check.pb(i); if (i * i != sum) check.pb(sum / i); } } for (int i : check) { if (i <= 2) continue; int a = i - 1; if ((x - y) % (a - 1) == 0) { int bpc = (x + y) / (a + 1); int bmc = (x - y) / (a - 1); if ((bpc - bmc) % 2 == 1) continue; int b = (bpc + bmc) / 2; int c = (bpc - bmc) / 2; if (b > 0 && c > 0) ans++; } } cout << ans << '\n'; } } }