結果

問題 No.1200 お菓子配り-3
ユーザー chielo
提出日時 2020-08-28 22:50:31
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
(最新)
AC  
(最初)
実行時間 -
コード長 1,195 bytes
コンパイル時間 2,337 ms
コンパイル使用メモリ 191,312 KB
最終ジャッジ日時 2025-01-13 18:52:34
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 29 WA * 2
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function ‘void solve()’:
main.cpp:23:10: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   23 |     scanf("%lld%lld", &x, &y);
      |     ~~~~~^~~~~~~~~~~~~~~~~~~~
main.cpp: In function ‘int main()’:
main.cpp:53:10: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   53 |     scanf("%d", &t);
      |     ~~~~~^~~~~~~~~~

ソースコード

diff #
プレゼンテーションモードにする

#include <bits/stdc++.h>
using ll = long long;
ll x, y;
void subsolve() {
ll ans = 0;
for(int i = 1; i * i <= x; ++i) {
if(i * i > x)
break;
if(x % i)
continue;
if(x / i > 1)
ans += 1;
if(x != i * i && x / (x / i) > 1)
ans += 1;
}
ans += x;
printf("%lld\n", ans);
}
void solve() {
scanf("%lld%lld", &x, &y);
if(x == y) {
subsolve();
return;
}
if(x < y)
std::swap(x, y);
ll ans = 0;
auto check = [&](ll a) {
if(a >= 2 && (x + y) % (a + 1) == 0 && (x - y) % (a - 1) == 0) {
ll bpc = (x + y) / (a + 1);
ll bmc = (x - y) / (a - 1);
ll b = (bpc + bmc) / 2;
ll c = x - a * b;
if(b > 0 && c > 0 && a * c + b == y)
ans += 1;
}
};
for(ll u = 1; u * u <= x - y; ++u) {
if((x - y) % u)
continue;
check(u + 1);
if((x - y) != u * u)
check((x - y) / u + 1);
}
printf("%lld\n", ans);
}
int main() {
int t;
scanf("%d", &t);
for(int i = 0; i < t; ++i) {
solve();
}
return 0;
}
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
0