結果
問題 | No.894 二種類のバス |
ユーザー |
![]() |
提出日時 | 2019-09-27 23:15:12 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 2 ms / 1,000 ms |
コード長 | 549 bytes |
コンパイル時間 | 1,311 ms |
コンパイル使用メモリ | 159,304 KB |
実行使用メモリ | 6,944 KB |
最終ジャッジ日時 | 2024-09-25 01:43:27 |
合計ジャッジ時間 | 1,895 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 17 |
ソースコード
#include <bits/stdc++.h>using namespace std;long long int gcd(long long int,long long int);int main(){long long int T,A,B,C,a=0,b=0,t=0,temp,ans=0;cin >> T >> A >> B;ans+=(T+A-1)/A;ans+=(T+B-1)/B;temp=A;while(A>=10){A/=10;a++;}A=temp;temp=B;while(B>=10){B/=10;b++;}B=temp;temp=T;while(T>=10){T/=10;t++;}T=temp;if(a+b<=t){C=(A*B/(gcd(A,B)));ans-=(T+C-1)/C;}else{ans--;}cout << ans << endl;return 0;}long long int gcd(long long int a,long long int b){if(b==0){return a;}return gcd(b,a%b);}