結果
| 問題 | 
                            No.257 N言っちゃダメゲーム (3)
                             | 
                    
| コンテスト | |
| ユーザー | 
                             mban
                         | 
                    
| 提出日時 | 2017-01-02 05:57:15 | 
| 言語 | C#(csc)  (csc 3.9.0)  | 
                    
| 結果 | 
                             
                                AC
                                 
                             
                            
                         | 
                    
| 実行時間 | 83 ms / 2,000 ms | 
| コード長 | 1,219 bytes | 
| コンパイル時間 | 760 ms | 
| コンパイル使用メモリ | 112,392 KB | 
| 実行使用メモリ | 43,108 KB | 
| 平均クエリ数 | 3.70 | 
| 最終ジャッジ日時 | 2024-07-17 00:44:05 | 
| 合計ジャッジ時間 | 5,248 ms | 
| 
                            ジャッジサーバーID (参考情報)  | 
                        judge4 / judge3 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| other | AC * 30 | 
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc) Copyright (C) Microsoft Corporation. All rights reserved.
ソースコード
using System;
using System.Collections;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.Text;
using System.Text.RegularExpressions;
using System.Linq;
class Magatro
{
    static void Main()
    {
        int N, K;
        string[] S = Console.ReadLine().Split(' ');
        N = int.Parse(S[0]);
        K = int.Parse(S[1]);
        int T = 0;
        if (N % (K + 1) == 1)
        {
            Console.WriteLine(0);
        }
        else
        {
            int Q = N % (K + 1);
            if (Q == 0)
            {
                Console.WriteLine(K);
                T += K;
            }
            else
            {
                Console.WriteLine(Q - 1);
                T += Q - 1;
            }
        }
        while (true)
        {
            int R = int.Parse(Console.ReadLine());
            if (R >= N)
            {
                return;
            }
            T = R;
            int Q = (N-T) % (K + 1);
            if (Q == 0)
            {
                T += K;
                Console.WriteLine(T);
            }
            else
            {
                T += Q - 1;
                Console.WriteLine(T);
            }
        }
    }
}
            
            
            
        
            
mban