結果

問題 No.2259 Gas Station
コンテスト
ユーザー aaa aa
提出日時 2025-12-18 11:46:57
言語 C#
(.NET 10.0.101)
結果
WA  
実行時間 -
コード長 1,693 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 9,003 ms
コンパイル使用メモリ 170,576 KB
実行使用メモリ 166,520 KB
最終ジャッジ日時 2025-12-18 11:47:12
合計ジャッジ時間 13,693 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 5 WA * 6 TLE * 1 -- * 9
権限があれば一括ダウンロードができます
コンパイルメッセージ
  復元対象のプロジェクトを決定しています...
  /home/judge/data/code/main.csproj を復元しました (137 ミリ秒)。
  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((BigInteger)l*c < 1000)
        {
            min = (int)(1000 - (BigInteger)(l*c));
        }
        else if(l*c ==1000)
        {
            Console.WriteLine(0);
            return;
        }
        else
        {
            BigInteger a = (BigInteger)l * c;
            int money = int.Parse(a.ToString().Substring(a.ToString().Length - 3));
            min = 1000 - money;
        }

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

    }
}
0