結果
| 問題 | No.2259 Gas Station |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2025-12-18 11:49:44 |
| 言語 | C# (.NET 10.0.101) |
| 結果 |
AC
|
| 実行時間 | 61 ms / 2,000 ms |
| コード長 | 1,708 bytes |
| 記録 | |
| コンパイル時間 | 8,989 ms |
| コンパイル使用メモリ | 172,068 KB |
| 実行使用メモリ | 190,196 KB |
| 最終ジャッジ日時 | 2025-12-18 11:49:56 |
| 合計ジャッジ時間 | 11,993 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 21 |
コンパイルメッセージ
復元対象のプロジェクトを決定しています... /home/judge/data/code/main.csproj を復元しました (116 ミリ秒)。 main -> /home/judge/data/code/bin/Release/net8.0/main.dll main -> /home/judge/data/code/bin/Release/net8.0/publish/
ソースコード
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((BigInteger)l * c % 1000==0)
{
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(b%1000==0)
{
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);
}
}