結果

問題 No.894 二種類のバス
ユーザー sitihisitihi
提出日時 2019-09-27 22:46:48
言語 C
(gcc 12.3.0)
結果
AC  
実行時間 1 ms / 1,000 ms
コード長 815 bytes
コンパイル時間 458 ms
コンパイル使用メモリ 28,932 KB
実行使用メモリ 4,348 KB
最終ジャッジ日時 2023-10-25 04:38:47
合計ジャッジ時間 1,263 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,348 KB
testcase_01 AC 1 ms
4,348 KB
testcase_02 AC 1 ms
4,348 KB
testcase_03 AC 1 ms
4,348 KB
testcase_04 AC 1 ms
4,348 KB
testcase_05 AC 1 ms
4,348 KB
testcase_06 AC 1 ms
4,348 KB
testcase_07 AC 1 ms
4,348 KB
testcase_08 AC 1 ms
4,348 KB
testcase_09 AC 1 ms
4,348 KB
testcase_10 AC 1 ms
4,348 KB
testcase_11 AC 1 ms
4,348 KB
testcase_12 AC 1 ms
4,348 KB
testcase_13 AC 1 ms
4,348 KB
testcase_14 AC 1 ms
4,348 KB
testcase_15 AC 1 ms
4,348 KB
testcase_16 AC 1 ms
4,348 KB
testcase_17 AC 1 ms
4,348 KB
testcase_18 AC 0 ms
4,348 KB
testcase_19 AC 1 ms
4,348 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#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;
    
    
    
}
0