結果

問題 No.415 ぴょん
ユーザー No
提出日時 2017-05-26 18:50:17
言語 C#(csc)
(csc 3.9.0)
結果
TLE  
実行時間 -
コード長 965 bytes
コンパイル時間 819 ms
コンパイル使用メモリ 109,120 KB
実行使用メモリ 31,156 KB
最終ジャッジ日時 2024-09-19 20:08:19
合計ジャッジ時間 3,513 ms
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 3 TLE * 1 -- * 23
権限があれば一括ダウンロードができます
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc)
Copyright (C) Microsoft Corporation. All rights reserved.

ソースコード

diff #

using System;
using System.Collections.Generic;
namespace Yuki
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] ss = Console.ReadLine().Split();
            int n = int.Parse(ss[0]);
            int d = int.Parse(ss[1]);
            var li = new List<int>() { 0 };
            int a = 0;
            int s = 0;

            while (true)
            {
                a += (n - s) / d;
                if ((n - s) % d == 0)
                {
                    a -= 1;
                    s = (-1 * (n - s) % d);
                }
                else
                {
                    s = (-1 * (n - s) % d) + d;
                }

                if (li.Contains(s))
                {
                    break;
                }
                else
                {
                    a += 1;
                    li.Add(s);
                }
            }
            Console.WriteLine(a);
        }
    }
}
0