結果
問題 | No.894 二種類のバス |
ユーザー |
![]() |
提出日時 | 2019-09-27 22:46:48 |
言語 | C (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 1 ms / 1,000 ms |
コード長 | 815 bytes |
コンパイル時間 | 1,421 ms |
コンパイル使用メモリ | 28,544 KB |
実行使用メモリ | 6,944 KB |
最終ジャッジ日時 | 2024-09-25 00:03:35 |
合計ジャッジ時間 | 1,060 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 17 |
ソースコード
#include <stdio.h>unsigned long long int gcd(unsigned long long int x, unsigned long long int y){while(x != 0){unsigned long long int z = x;x = y%x;y = z;}return y;}unsigned long long int lcm(unsigned long long int x, unsigned long long int y){unsigned long long int p = gcd(x, y);unsigned long long int s = x*y/p;return s;}unsigned long long int main(){unsigned long long int t, a, b, l, c, d, e, f;scanf("%llu%llu%llu", &t, &a, &b);l = lcm(a, b);if (t%a == 0){d = t/a;}else {d = 1+t/a;}if (t%b == 0){e = t/b;}else {e = 1+t/b;}if (t%l == 0){f = t/l;}else {f = 1+t/l;}c = d+e-f;printf("%llu\n", c);return 0;}