結果

問題 No.894 二種類のバス
ユーザー sggkshio
提出日時 2019-09-29 06:59:22
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
RE  
(最新)
AC  
(最初)
実行時間 -
コード長 704 bytes
コンパイル時間 675 ms
コンパイル使用メモリ 83,200 KB
実行使用メモリ 6,824 KB
最終ジャッジ日時 2024-10-03 04:23:33
合計ジャッジ時間 3,195 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample RE * 3
other RE * 17
権限があれば一括ダウンロードができます
コンパイルメッセージ
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