結果
問題 |
No.1203 お菓子ゲーム
|
ユーザー |
![]() |
提出日時 | 2020-07-23 17:08:07 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 725 bytes |
コンパイル時間 | 940 ms |
コンパイル使用メモリ | 79,900 KB |
実行使用メモリ | 6,824 KB |
最終ジャッジ日時 | 2024-11-07 13:26:25 |
合計ジャッジ時間 | 7,156 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 5 WA * 46 |
ソースコード
#include <iostream> #include <random> using namespace std; using ll = long long; ll gcds(ll a,ll b) { if (a%b == 0) { return(b); } else { return(gcds(b, a%b)); } } ll si(ll a,ll b){ ll r=gcds(a,b); return a/r; } ll bo(ll a,ll b){ ll r=gcds(a,b); return b/r; } int main(){ ll s; cin>>s; ll a,b; ll ans; for(ll i=0;i<s;i++){ cin>>a>>b; if(2*a>b){ a=b-a; } ans=100000000/b; ll r; for(ll i=3;i*i<=b;i=i+2){ if(b%i==0){ if((b*(i*i-1))%(2*a*i)==0&&(b*(i*i-1))/(2*a*i)>i){ ans++; } r=b/i; if(r!=i){ if((b*(r*r-1))%(2*a)==0&&(b*(r*r-1))/(2*a)>r){ ans++; } } } } cout<<ans<<endl; } }