結果
| 問題 | No.894 二種類のバス |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2026-02-08 13:53:51 |
| 言語 | C# (.NET 10.0.102) |
| 結果 |
AC
|
| 実行時間 | 53 ms / 1,000 ms |
| コード長 | 901 bytes |
| 記録 | |
| コンパイル時間 | 10,889 ms |
| コンパイル使用メモリ | 169,624 KB |
| 実行使用メモリ | 191,736 KB |
| 最終ジャッジ日時 | 2026-02-08 13:54:05 |
| 合計ジャッジ時間 | 12,867 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 17 |
コンパイルメッセージ
復元対象のプロジェクトを決定しています... /home/judge/data/code/main.csproj を復元しました (138 ミリ秒)。 main -> /home/judge/data/code/bin/Release/net10.0/main.dll main -> /home/judge/data/code/bin/Release/net10.0/publish/
ソースコード
using System;
using static System.Console;
using System.Linq;
using System.Collections.Generic;
class Program
{
static int NN => int.Parse(ReadLine());
static long[] NList => ReadLine().Split().Select(long.Parse).ToArray();
public static void Main()
{
Solve();
}
static void Solve()
{
var c = NList;
var (t, a, b) = (c[0], c[1], c[2]);
WriteLine(Bus(t, a, b));
}
static long Bus(long t, long a, long b)
{
var ans = (t + a - 1) / a + (t + b - 1) / b;
var gcd = GCD(a, b);
var lcm = a / gcd * b;
if (lcm % b == 0 && lcm / b == a / gcd) ans -= (t + lcm - 1) / lcm;
else --ans;
return ans;
}
static long GCD(long a, long b)
{
if (a < b) return GCD(b, a);
if (a % b == 0) return b;
return GCD(b, a % b);
}
}