結果

問題 No.2259 Gas Station
コンテスト
ユーザー aaa aa
提出日時 2025-12-18 11:38:50
言語 C#
(.NET 10.0.101)
結果
WA  
実行時間 -
コード長 1,601 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 8,903 ms
コンパイル使用メモリ 171,300 KB
実行使用メモリ 64,808 KB
最終ジャッジ日時 2025-12-18 11:39:05
合計ジャッジ時間 14,641 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 1 WA * 10 TLE * 1 -- * 9
権限があれば一括ダウンロードができます
コンパイルメッセージ
  復元対象のプロジェクトを決定しています...
  /home/judge/data/code/main.csproj を復元しました (110 ミリ秒)。
  main -> /home/judge/data/code/bin/Release/net8.0/main.dll
  main -> /home/judge/data/code/bin/Release/net8.0/publish/

ソースコード

diff #
raw source code

using System.Numerics;

public class Program
{
    public static void Main()
    {

        //BigInteger num = BigInteger.Parse(Console.ReadLine() ?? string.Empty);
        //int num = int.Parse(Console.ReadLine() ?? string.Empty);
        string[] moji = (Console.ReadLine() ?? string.Empty).Trim().Split(' ');
        //string str = Console.ReadLine() ?? string.Empty;

        
        int l = int.Parse(moji[0]); //下限
        int r = int.Parse(moji[1]); //上限
        int c = int.Parse(moji[2]); //1Lあたりの値段

        int min = 0;
        if(l*c < 1000)
        {
            min = 1000-(l*c);
        }
        else if(l*c ==1000)
        {
            Console.WriteLine(0);
            return;
        }
        else
        {
            BigInteger a = l * c;
            int money = int.Parse(a.ToString().Substring(a.ToString().Length - 3));
            min = 1000 - money;
        }

        for(int i = l+1; i<=r; i++)
        {
            if(i *c < 1000)
            {
                if(min > 1000-(i*c))
                {
                    min=1000-(i*c);
                    
                }
            }
            else if(i *c ==1000)
            {
                Console.WriteLine(0);
                return;
            }
            else
            {
                BigInteger a = i * c;
                int money = int.Parse(a.ToString().Substring(a.ToString().Length - 3));
                if(min > 1000-money)
                {
                    min = 1000 - money;
                }
            }
        }
        Console.WriteLine(min);

    }
}
0