結果
問題 |
No.3048 Swing
|
ユーザー |
![]() |
提出日時 | 2025-03-07 21:18:48 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 779 bytes |
コンパイル時間 | 1,532 ms |
コンパイル使用メモリ | 160,324 KB |
実行使用メモリ | 8,608 KB |
最終ジャッジ日時 | 2025-03-07 21:19:24 |
合計ジャッジ時間 | 34,760 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 48 WA * 10 |
コンパイルメッセージ
main.cpp: In function ‘int main()’: main.cpp:36:26: warning: ‘x2’ may be used uninitialized [-Wmaybe-uninitialized] 36 | cout<<x2+(n-cnt)/2<<endl; | ^ main.cpp:10:15: note: ‘x2’ was declared here 10 | long long x2; | ^~
ソースコード
#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; long long x2; if(x>0){ while(x>0){ x-=cnt; if(cnt==n){ cout<<x<<endl; return 0; } cnt++; } long long x2; x2=x+cnt; } else{ while(x<=0){ x+=cnt; if(cnt==n){ cout<<x<<endl; return 0; } cnt++; } x2=x-cnt; } if((n-cnt)%2==0){ cout<<x2+(n-cnt)/2<<endl; } else{ cout<<x-(n-cnt)/2-1<<endl; } }