結果
問題 | No.1200 お菓子配り-3 |
ユーザー | daikisuyama |
提出日時 | 2020-08-29 09:33:48 |
言語 | C++14 (gcc 12.3.0 + boost 1.83.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 2,902 bytes |
コンパイル時間 | 1,687 ms |
コンパイル使用メモリ | 176,348 KB |
実行使用メモリ | 6,944 KB |
最終ジャッジ日時 | 2024-04-27 00:58:43 |
合計ジャッジ時間 | 7,226 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 2 ms
6,816 KB |
testcase_01 | AC | 2 ms
6,944 KB |
testcase_02 | AC | 2 ms
6,940 KB |
testcase_03 | AC | 2 ms
6,940 KB |
testcase_04 | AC | 2 ms
6,944 KB |
testcase_05 | AC | 2 ms
6,940 KB |
testcase_06 | AC | 2 ms
6,940 KB |
testcase_07 | AC | 5 ms
6,940 KB |
testcase_08 | AC | 5 ms
6,940 KB |
testcase_09 | AC | 5 ms
6,940 KB |
testcase_10 | AC | 4 ms
6,940 KB |
testcase_11 | AC | 4 ms
6,940 KB |
testcase_12 | AC | 34 ms
6,940 KB |
testcase_13 | AC | 33 ms
6,940 KB |
testcase_14 | AC | 35 ms
6,940 KB |
testcase_15 | AC | 34 ms
6,940 KB |
testcase_16 | AC | 34 ms
6,944 KB |
testcase_17 | AC | 118 ms
6,944 KB |
testcase_18 | AC | 172 ms
6,944 KB |
testcase_19 | AC | 41 ms
6,940 KB |
testcase_20 | AC | 330 ms
6,944 KB |
testcase_21 | AC | 325 ms
6,944 KB |
testcase_22 | AC | 393 ms
6,944 KB |
testcase_23 | AC | 328 ms
6,940 KB |
testcase_24 | AC | 321 ms
6,940 KB |
testcase_25 | AC | 331 ms
6,940 KB |
testcase_26 | WA | - |
testcase_27 | AC | 2 ms
6,944 KB |
testcase_28 | AC | 260 ms
6,940 KB |
testcase_29 | AC | 712 ms
6,940 KB |
testcase_30 | AC | 716 ms
6,940 KB |
testcase_31 | WA | - |
testcase_32 | WA | - |
ソースコード
//デバッグ用オプション:-fsanitize=undefined,address //コンパイラ最適化 #pragma GCC optimize("Ofast") //インクルードなど #include<bits/stdc++.h> using namespace std; typedef int ll; //マクロ //forループ //引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか //Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはループ変数は1ずつデクリメントされる //FORAは範囲for文(使いにくかったら消す) #define REP(i,n) for(ll i=0;i<ll(n);i++) #define REPD(i,n) for(ll i=n-1;i>=0;i--) #define FOR(i,a,b) for(ll i=a;i<=ll(b);i++) #define FORD(i,a,b) for(ll i=a;i>=ll(b);i--) #define FORA(i,I) for(const auto& i:I) //xにはvectorなどのコンテナ #define ALL(x) x.begin(),x.end() #define SIZE(x) ll(x.size()) //定数 #define INF 1000000000000 //10^12:∞ #define MOD 1000000007 //10^9+7:合同式の法 #define MAXR 100000 //10^5:配列の最大のrange //略記 #define PB push_back //挿入 #define MP make_pair //pairのコンストラクタ #define F first //pairの一つ目の要素 #define S second //pairの二つ目の要素 ll check_divisors(ll x,ll y){ ll n=abs(x-y); ll ret=0; FOR(i,1,sqrt(n)){ if(n%i==0){ ll a,b; if(i!=ll(n/i)){ a=i;b=ll(n/i); if((x+y)%(a+2)==0){ if(ll((x+y)/(a+2))%2==b%2){ if(b<ll((x+y)/(a+2)))ret++; //cout<<a<<" "<<b<<" "<<a+2<<" "<<ll((x+y)/(a+2))<<endl; } } a=ll(n/i);b=i; if((x+y)%(a+2)==0){ if(ll((x+y)/(a+2))%2==b%2){ if(b<ll((x+y)/(a+2)))ret++; //cout<<a<<" "<<b<<" "<<a+2<<" "<<ll((x+y)/(a+2))<<endl; } } }else{ a=i;b=i; if(ll((x+y)/(a+2))%2==b%2){ if(b<ll((x+y)/(a+2)))ret++; //cout<<a<<" "<<b<<" "<<a+2<<" "<<ll((x+y)/(a+2))<<endl; } } } } return ret; } ll check_divisors2(ll x,ll y){ ll ret=x-1; FOR(i,2,sqrt(x)){ if(x%i==0){ if(i!=ll(x/i)){ if(i!=2)ret+=2; else if(i==2 and x%2==0) ret++; else ret+=2; }else{ if(i!=2)ret++; } } } //b=1の時 if(x!=2 and x!=1)ret++; return ret; } signed main(){ //入力の高速化用のコード ios::sync_with_stdio(false); cin.tie(nullptr); ll s;cin>>s; REP(i,s){ ll x,y;cin>>x>>y; if(x==y){ cout<<check_divisors2(x,y)-1-1<<endl; }else{ cout<<check_divisors(x,y)<<endl; } } }