結果
問題 |
No.894 二種類のバス
|
ユーザー |
![]() |
提出日時 | 2020-09-06 20:48:34 |
言語 | C#(csc) (csc 3.9.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 751 bytes |
コンパイル時間 | 2,635 ms |
コンパイル使用メモリ | 107,816 KB |
実行使用メモリ | 26,136 KB |
最終ジャッジ日時 | 2024-11-29 07:34:24 |
合計ジャッジ時間 | 2,997 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 15 WA * 2 |
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc) Copyright (C) Microsoft Corporation. All rights reserved.
ソースコード
using System; public class Hello { static void Main() { string[] line = Console.ReadLine().Trim().Split(' '); var t = long.Parse(line[0]); var a = long.Parse(line[1]); var b = long.Parse(line[2]); var gcd = Gcd(a, b); var tpa = t / a; if (t % a == 0) tpa--; var tpb = t / b; if (t % b == 0) tpb--; var tpLcm = t * gcd / a / b; if (t * gcd / a % b == 0) tpLcm--; var ans = tpa + tpb + 1 - tpLcm; Console.WriteLine(ans); } static long Gcd(long a, long b) { if (a < b) return Gcd(b, a); while (b != 0) { var w = a % b; a = b; b = w; } return a; } }