結果

問題 No.257 N言っちゃダメゲーム (3)
ユーザー kpinkcatkpinkcat
提出日時 2023-11-10 16:44:31
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 722 bytes
コンパイル時間 1,023 ms
コンパイル使用メモリ 103,956 KB
実行使用メモリ 24,000 KB
平均クエリ数 8.90
最終ジャッジ日時 2023-11-10 16:44:36
合計ジャッジ時間 4,890 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 AC 54 ms
24,000 KB
testcase_06 AC 54 ms
24,000 KB
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function 'int main()':
main.cpp:31:14: warning: 's' may be used uninitialized [-Wmaybe-uninitialized]
   31 |     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;
        s = 0;
        return 0;
    } else if (n == 1) {
        cout << 0 << endl;
        s = 0;
        return 0;
    }
    
    while (s < n){
        s += k;
        int opp;
        cin >> opp;
        if (opp >= n) return 0;
        if (s == opp) s += k;
        cout << s << endl;
    }
}
0