結果
問題 |
No.1200 お菓子配り-3
|
ユーザー |
![]() |
提出日時 | 2020-09-01 01:21:52 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,328 bytes |
コンパイル時間 | 746 ms |
コンパイル使用メモリ | 82,628 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-11-17 03:02:54 |
合計ジャッジ時間 | 6,371 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 29 WA * 2 |
ソースコード
#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 = 1 ans += x-1; // b = c for(int i = 3; i*i <= x; i++){ if(x%i == 0) { ans++; if(i*i != x) 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(); }