結果
問題 | No.1200 お菓子配り-3 |
ユーザー |
|
提出日時 | 2020-08-28 23:04:18 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
(最新)
AC
(最初)
|
実行時間 | - |
コード長 | 1,377 bytes |
コンパイル時間 | 807 ms |
コンパイル使用メモリ | 75,728 KB |
実行使用メモリ | 6,820 KB |
最終ジャッジ日時 | 2024-11-14 16:48:41 |
合計ジャッジ時間 | 9,194 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 29 WA * 2 |
ソースコード
#include <iostream>#include <vector>#include <string>#include <algorithm>using namespace std;#pragma GCC target("avx2")#pragma GCC optimize("O3")#pragma GCC optimize("unroll-loops")vector<int> divisor(int n){//nの約数列挙vector<int> res;for(int i = 1; i * i <= n; i++){if(n % i == 0){res.emplace_back(i);if(i != n / i) res.emplace_back(n / i);}}return res;}int main(){ios::sync_with_stdio(false);cin.tie(nullptr);int test;cin >> test;for(int counttest = 0; counttest < test; counttest++){int X, Y;cin >> X >> Y;int ans = 0;if(X < Y) swap(X, Y);if(X == Y){int t = X + Y;ans += t / 2 - 1;vector<int> d = divisor(t);for(int i = 0; i < (int)d.size(); i++){if(d[i] > 1 && t / d[i] > 2) ans++;}cout << ans << endl;}else{int t1 = X + Y, t2 = X - Y;vector<int> d1 = divisor(t1);for(int i = 0; i < (int)d1.size(); i++){if(d1[i] > 2){int temp = d1[i] - 2;if(t2 % temp == 0 && t1 / d1[i] > t2 / temp && (t1 / d1[i] + t2 / temp) % 2 == 0) ans++;}}cout << ans << endl;}}}