結果
問題 | No.1203 お菓子ゲーム |
ユーザー | chocorusk |
提出日時 | 2020-08-29 04:27:25 |
言語 | C++17 (gcc 12.3.0 + boost 1.83.0) |
結果 |
AC
|
実行時間 | 305 ms / 2,000 ms |
コード長 | 1,500 bytes |
コンパイル時間 | 1,439 ms |
コンパイル使用メモリ | 139,936 KB |
実行使用メモリ | 42,752 KB |
最終ジャッジ日時 | 2024-04-26 15:58:10 |
合計ジャッジ時間 | 16,781 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 261 ms
42,752 KB |
testcase_01 | AC | 273 ms
42,624 KB |
testcase_02 | AC | 250 ms
42,624 KB |
testcase_03 | AC | 278 ms
42,624 KB |
testcase_04 | AC | 259 ms
42,624 KB |
testcase_05 | AC | 286 ms
42,624 KB |
testcase_06 | AC | 262 ms
42,624 KB |
testcase_07 | AC | 284 ms
42,496 KB |
testcase_08 | AC | 241 ms
42,624 KB |
testcase_09 | AC | 229 ms
42,624 KB |
testcase_10 | AC | 252 ms
42,752 KB |
testcase_11 | AC | 246 ms
42,496 KB |
testcase_12 | AC | 253 ms
42,496 KB |
testcase_13 | AC | 240 ms
42,624 KB |
testcase_14 | AC | 249 ms
42,496 KB |
testcase_15 | AC | 255 ms
42,496 KB |
testcase_16 | AC | 251 ms
42,624 KB |
testcase_17 | AC | 248 ms
42,624 KB |
testcase_18 | AC | 228 ms
42,752 KB |
testcase_19 | AC | 239 ms
42,496 KB |
testcase_20 | AC | 234 ms
42,624 KB |
testcase_21 | AC | 235 ms
42,624 KB |
testcase_22 | AC | 264 ms
42,496 KB |
testcase_23 | AC | 259 ms
42,496 KB |
testcase_24 | AC | 230 ms
42,624 KB |
testcase_25 | AC | 232 ms
42,496 KB |
testcase_26 | AC | 257 ms
42,496 KB |
testcase_27 | AC | 256 ms
42,624 KB |
testcase_28 | AC | 238 ms
42,752 KB |
testcase_29 | AC | 257 ms
42,624 KB |
testcase_30 | AC | 304 ms
42,496 KB |
testcase_31 | AC | 302 ms
42,624 KB |
testcase_32 | AC | 280 ms
42,496 KB |
testcase_33 | AC | 294 ms
42,496 KB |
testcase_34 | AC | 305 ms
42,496 KB |
testcase_35 | AC | 272 ms
42,496 KB |
testcase_36 | AC | 272 ms
42,624 KB |
testcase_37 | AC | 256 ms
42,496 KB |
testcase_38 | AC | 279 ms
42,496 KB |
testcase_39 | AC | 273 ms
42,624 KB |
testcase_40 | AC | 279 ms
42,624 KB |
testcase_41 | AC | 270 ms
42,624 KB |
testcase_42 | AC | 284 ms
42,624 KB |
testcase_43 | AC | 273 ms
42,624 KB |
testcase_44 | AC | 268 ms
42,752 KB |
testcase_45 | AC | 261 ms
42,624 KB |
testcase_46 | AC | 262 ms
42,496 KB |
testcase_47 | AC | 275 ms
42,496 KB |
testcase_48 | AC | 262 ms
42,624 KB |
testcase_49 | AC | 268 ms
42,752 KB |
testcase_50 | AC | 231 ms
42,624 KB |
ソースコード
#include <cstdio> #include <cstring> #include <iostream> #include <string> #include <cmath> #include <bitset> #include <vector> #include <map> #include <set> #include <queue> #include <deque> #include <algorithm> #include <complex> #include <unordered_map> #include <unordered_set> #include <random> #include <cassert> #include <fstream> #include <utility> #include <functional> #include <time.h> #include <stack> #include <array> #define popcount __builtin_popcount #define popcountll __builtin_popcountll using namespace std; typedef long long int ll; typedef pair<int, int> P; const int MAX=10000010; int p[MAX]; void sieve(){ for(int i=2; i<MAX; i++){ if(p[i]==0){ for(int j=(i<<1); j<MAX; j+=i) p[j]=i; } } } void dfs(int k, int x, int y, vector<P> v, vector<ll> &w){ if(k==v.size()){ if(x>1 && x%2==1){ w.push_back(x); } return; } ll q=1; for(int i=0; i<=v[k].second; i++){ dfs(k+1, x*q, y, v, w); q*=v[k].first; } } vector<ll> divisor(ll y){ vector<ll> w; ll y1=y; map<int, int> f; while(p[y]>0){ f[p[y]]++; y/=p[y]; } f[y]++; vector<P> v; for(auto p:f) v.push_back(p); dfs(0, 1, y1, v, w); return w; } const ll M=1e8; ll solve(ll x, ll y){ if(x*2==y) return 0; if(x*2>y) x=y-x; ll ans=M/y; auto v=divisor(y); for(auto b:v){ ll a1=(b-1)*((b+1)/2)*(y/b); if(a1%x==0 && a1/x>b && a1/x<=M) ans++; } return ans; } int main() { int s; cin>>s; sieve(); while(s--){ ll x, y; cin>>x>>y; cout<<solve(x, y)<<endl; } return 0; }