結果

問題 No.894 二種類のバス
ユーザー sggkshiosggkshio
提出日時 2019-09-29 06:59:22
言語 C++11
(gcc 11.4.0)
結果
RE  
(最新)
AC  
(最初)
実行時間 -
コード長 704 bytes
コンパイル時間 1,116 ms
コンパイル使用メモリ 84,492 KB
実行使用メモリ 6,948 KB
最終ジャッジ日時 2024-04-14 07:10:54
合計ジャッジ時間 4,203 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 RE -
testcase_01 RE -
testcase_02 RE -
testcase_03 RE -
testcase_04 RE -
testcase_05 RE -
testcase_06 RE -
testcase_07 RE -
testcase_08 RE -
testcase_09 RE -
testcase_10 RE -
testcase_11 RE -
testcase_12 RE -
testcase_13 RE -
testcase_14 RE -
testcase_15 RE -
testcase_16 RE -
testcase_17 RE -
testcase_18 RE -
testcase_19 RE -
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function ‘long long int gcd(long long int, long long int)’:
main.cpp:29:12: warning: control reaches end of non-void function [-Wreturn-type]
   29 |         gcd(b%a, a);
      |         ~~~^~~~~~~~

ソースコード

diff #



#define _USE_MATH_DEFINES
#include  <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <string>
#include<math.h>
#include<iomanip>
#include<stdio.h>
#include <stdlib.h>
#include<stdio.h>
#include <queue>
#include<map>
#include <sstream>
#include<set>
#include<stack>

//#include<bits/stdc++.h>


using namespace std;

long long int gcd(long long int a, long long int b) {
	if (a == 0)return b;
	gcd(b%a, a);
}

int main() {

	
	long long int t, a, b;
	cin >> t >> a >> b;
	if (a > b)swap(a, b);

	long long int m = gcd(a, b);

	long long int x = (t-1) / a , y = (t-1) / b ;
	long long int z = x / (b/m);

	cout << x + y - z + 1 << endl;

	


	return 0;




}
0