結果
| 問題 |
No.3048 Swing
|
| コンテスト | |
| ユーザー |
Andrew8128
|
| 提出日時 | 2025-03-07 21:17:23 |
| 言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,246 bytes |
| コンパイル時間 | 11,282 ms |
| コンパイル使用メモリ | 374,416 KB |
| 実行使用メモリ | 8,608 KB |
| 最終ジャッジ日時 | 2025-03-07 21:17:49 |
| 合計ジャッジ時間 | 11,965 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 55 WA * 3 |
ソースコード
#include <iostream>
using namespace std;
#include <boost/multiprecision/cpp_int.hpp>
typedef boost::multiprecision::cpp_int bint;
const long long linf = 4610000000000000000;
int main()
{
bint x, n;
cin >> x >> n;
if (0 <= x)
{
bint l = 0, r = (bint)linf * linf;
while (abs(l - r) > 1)
{
bint c = (l + r) / 2;
if (c * (c+1) / 2 < x)
{
l = c;
}
else
{
r = c;
}
}
if (n <= l)
{
cout << x - n * (n+1) / 2 << '\n';
}
else
{
bint ans = x - l * (l+1) / 2;
ans += (n - l) / 2;
if ((n - l) % 2 == 1)
{
ans -= n;
}
cout << ans << '\n';
}
}
else
{
bint l = 0, r = (bint)linf * linf;
while (abs(l - r) > 1)
{
bint c = (l + r) / 2;
if (c * (c+1) / 2 <= -x)
{
l = c;
}
else
{
r = c;
}
}
if (n <= l)
{
cout << x + n * (n+1) / 2 << '\n';
}
else
{
bint ans = x + l * (l+1) / 2;
ans -= (n - l) / 2;
if ((n - l) % 2 == 1)
{
ans += n;
}
cout << ans << '\n';
}
}
return 0;
}
/*
File : ~/yukicoder/526/A.cpp
Date : 2025/03/07
Time : 21:02:05
*/
Andrew8128