結果
問題 | No.1200 お菓子配り-3 |
ユーザー |
![]() |
提出日時 | 2020-09-01 01:36:55 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 766 ms / 4,000 ms |
コード長 | 1,366 bytes |
コンパイル時間 | 788 ms |
コンパイル使用メモリ | 83,020 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-11-20 23:11:47 |
合計ジャッジ時間 | 6,636 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 31 |
ソースコード
#include <iostream>#include <algorithm>#include <iomanip>#include <vector>#include <queue>#include <set>#include <map>using namespace std;typedef long long ll;void solve(){int x, y; cin >> x >> y;if(x < y) swap(x, y);if(x == y){int ans = 0;// a = 1ans += x-1;// b = cfor(int i = 1; i*i <= x; i++){if(x%i == 0) {if(i != 1)ans++;if(i*i != x) ans++;}}if(x%2 == 0) ans--;cout << ans << endl;return;}int ans = 0;for(int s = 1; s*s <= x-y; s++){if((x-y)%s != 0) continue;{int t_ = (x-y)/s;int a = s+1;if((x+y)%(a+1) == 0){int t = (x+y)/(a+1);if(t > t_ && t%2 == t_%2) {ans++;}}}if(s*s != x-y){int t_ = s;int a = (x-y)/t_+1;if((x+y)%(a+1) == 0){int t = (x+y)/(a+1);if(t > t_ && t%2 == t_%2) {ans++;}}}}cout << ans << endl;}int main(){ios::sync_with_stdio(false);cin.tie(0);cout << setprecision(10) << fixed;int s; cin >> s;for(int i = 0; i < s; i++) solve();}