結果

問題 No.257 N言っちゃダメゲーム (3)
ユーザー kpinkcat
提出日時 2023-11-10 16:33:40
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 598 bytes
コンパイル時間 850 ms
コンパイル使用メモリ 102,436 KB
最終ジャッジ日時 2025-02-17 20:16:27
ジャッジサーバーID
(参考情報)
judge1 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 2 WA * 28
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:24:14: warning: ‘s’ may be used uninitialized [-Wmaybe-uninitialized]
   24 |     while (s < n){
      |            ~~^~~
main.cpp:15:15: note: ‘s’ was declared here
   15 |     int n, k, s;
      |               ^

ソースコード

diff #

#include<iostream>
#include<iomanip>
#include<string>
#include<algorithm>
#include<vector>
#include<set>
#include<list>
#include<queue>
#include<math.h>
#include<bitset>
using ll = long long;
using namespace std;

int main(){
    int n, k, s;
    cin >> n >> k;
    if (n >= 3) {
        s = (n-2)%k;
        if (s == 1) cout << 0 << endl;
        else cout << s << endl;
    } else if (n == 2) cout << 1 << endl;
    else if (n == 1) cout << 0 << endl;
    
    while (s < n){
        s += k;
        int opp;
        cin >> opp;
        if (opp >= n) return 0;
        cout << s << endl;
    }
}
0