結果
| 問題 |
No.894 二種類のバス
|
| コンテスト | |
| ユーザー |
totori_nyaa
|
| 提出日時 | 2019-09-27 21:37:00 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 687 bytes |
| コンパイル時間 | 1,524 ms |
| コンパイル使用メモリ | 167,136 KB |
| 実行使用メモリ | 6,944 KB |
| 最終ジャッジ日時 | 2024-09-24 20:57:48 |
| 合計ジャッジ時間 | 2,128 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 16 WA * 1 |
ソースコード
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
long long gcd(long long a, long long b){
if(b==0) return a;
return gcd(b,a%b);
}
bool isprime(long long int val) {
if (val <= 1)return false;
for (long long int i = 2; i*i <= val; i++) {
if (val%i == 0LL)return false;
}
return true;
}
signed main(){
ios::sync_with_stdio(false);
cin.tie(0);
cout << fixed << setprecision(20);
ll t,a,b;
cin>>t>>a>>b;
t--;
ll g = gcd(a,b);
if(isprime(a) && isprime(b) && a>1e9 && b>1e9){
cout << t/a + t/b + 1 << endl;
}
ll l = a/g * b;
ll ans = t/a + t/b -t/l;
ans++;
cout << ans << endl;
}
totori_nyaa