結果

問題 No.3048 Swing
ユーザー ゼリトキ
提出日時 2025-03-07 21:14:38
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 498 bytes
コンパイル時間 1,845 ms
コンパイル使用メモリ 161,304 KB
実行使用メモリ 8,612 KB
最終ジャッジ日時 2025-03-07 21:15:05
合計ジャッジ時間 25,650 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 32 WA * 26
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int main(){
    cin.tie(0)->sync_with_stdio(0);
    cout.tie(0);
    long long x,n;
    cin>>x>>n;
    long long cnt=1;
    while(x>0){
        x-=cnt;
        if(cnt==n){
            cout<<x<<endl;
            return 0;
        }
        cnt++;
    }
    long long x2;
    x2=x+cnt;
    if((n-cnt)%2==0){
        cout<<x2+(n-cnt)/2<<endl;
    }
    else{
        cout<<x-(n-cnt)/2-1<<endl;
    }
}
0