結果

問題 No.3048 Swing
コンテスト
ユーザー tokitsukaze
提出日時 2025-03-07 21:28:48
言語 C++17
(gcc 15.2.0 + boost 1.90.0)
コンパイル:
g++-15 -O2 -lm -std=c++17 -Wuninitialized -DONLINE_JUDGE -o a.out _filename_
実行:
./a.out
結果
TLE  
実行時間 -
コード長 459 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 1,043 ms
コンパイル使用メモリ 209,644 KB
実行使用メモリ 9,288 KB
最終ジャッジ日時 2026-07-06 22:52:44
合計ジャッジ時間 69,991 ms
ジャッジサーバーID
(参考情報)
judge1_0 / judge3_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 29 WA * 14 TLE * 19
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

#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,sq,cnt,i;
	scanf("%lld%lld",&x,&n);
	sq=sqrt(2*x);
	while((1+sq)*sq/2>=x) sq--;
	while((1+sq)*sq/2<=x) sq++;
	sq=min(sq-1,n);
	x-=(1+sq)*sq/2;
	x+=(n-sq)/2;
	for(i=sq+(n-sq)/2*2+1;i<=n;i++)
	{
		if(x<=0) x+=i;
		else x-=i;
	}
	printf("%lld\n",x);
	return 0;
}
0