結果
問題 |
No.3048 Swing
|
ユーザー |
![]() |
提出日時 | 2025-03-07 22:06:23 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 434 bytes |
コンパイル時間 | 2,266 ms |
コンパイル使用メモリ | 192,632 KB |
実行使用メモリ | 8,612 KB |
最終ジャッジ日時 | 2025-03-07 22:06:28 |
合計ジャッジ時間 | 4,115 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 29 WA * 29 |
ソースコード
#include <bits/stdc++.h> using namespace std; #define int long long signed main(){ int x,n; cin>>x>>n; if(n <= 2e9 && n*(n+1)/2 <= x){ cout<<x-n*(n+1)/2<<endl; return 0; } int r = min((int)(2e9),n), l = 1; while(r-l > 1){ int d = (l+r)/2; if(d*(d+1)/2 > x) r = d; else l = d; } int ans = x-(r*(r+1)/2); ans -= (n-r)/2; if((n-r)%2 == 1) ans += n; cout<<ans<<endl; }