結果
| 問題 |
No.3048 Swing
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2025-03-07 21:40:22 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 606 bytes |
| コンパイル時間 | 2,253 ms |
| コンパイル使用メモリ | 194,044 KB |
| 実行使用メモリ | 8,608 KB |
| 最終ジャッジ日時 | 2025-03-07 21:40:34 |
| 合計ジャッジ時間 | 11,656 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 55 TLE * 3 |
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:11:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
11 | scanf("%lld%lld",&x,&n);
| ~~~~~^~~~~~~~~~~~~~~~~~
ソースコード
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int INF=0x3f3f3f3f;
const ll LLINF=0x3f3f3f3f3f3f3f3fLL;
const int MAX=2e5+10;
const int mod=998244353;
int main()
{
ll x,n,now,i,target;
scanf("%lld%lld",&x,&n);
if(x<=0) target=-x;
else target=x;
now=sqrt(2*target);
while((1+now)*now/2>=target) now--;
while((1+now)*now/2<=target) now++;
now=min(n,now-1);
if(x>=0) x-=(1+now)*now/2;
else x+=(1+now)*now/2;
if(x<=0 && now<n)
{
now++;
x+=now;
}
x+=(n-now)/2;
for(i=now+(n-now)/2*2+1;i<=n;i++)
{
if(x<=0) x+=i;
else x-=i;
}
printf("%lld\n",x);
return 0;
}