結果
問題 | No.356 円周上を回る3つの動点の一致 |
ユーザー |
![]() |
提出日時 | 2016-04-02 00:37:11 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 1,949 ms / 5,000 ms |
コード長 | 1,691 bytes |
コンパイル時間 | 821 ms |
コンパイル使用メモリ | 92,724 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-10-13 21:05:23 |
合計ジャッジ時間 | 13,901 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 48 |
ソースコード
#include <iostream> #include <vector> #include <cstdio> #include <sstream> #include <map> #include <string> #include <algorithm> #include <queue> #include <cmath> #include <functional> #include <set> #include <ctime> #include <random> #include <chrono> #include <cassert> using namespace std; template<class T> istream& operator >> (istream& is, vector<T>& vec){for(T& val: vec) is >> val; return is;} template<class T> istream& operator , (istream& is, T& val){ return is >> val;} template<class T> ostream& operator << (ostream& os, const vector<T>& vec){for(int i=0; i<vec.size(); i++) os << vec[i] << (i==vec.size()-1?"":" "); return os;} template<class T> ostream& operator , (ostream& os, const T& val){ return os << " " << val;} template<class T> ostream& operator >> (ostream& os, const T& val){ return os << " " << val;} long long gcd(long long a, long long b){ if(b==0) return a; return gcd(b, a%b); } template<class ... T> long long gcd(long long a, long long b, T ... c){ return gcd(gcd(a,b), c...); } long long lcm(long long a, long long b){ if(a<b) swap(a,b); if(b==1) return a; return a * (b/gcd(a,b)); } template<class ... T> long long lcm(long long a, long long b, T ... c){ return lcm(lcm(a,b), c...); } int main(){ vector<long long> t(3); cin >> t; long long l = lcm(t[0], t[1], t[2]); vector<long long> unko = {l/t[0], l/t[1], l/t[2]}; long long x = 1; for(long long k=2, m = *min_element(unko.begin(), unko.end()); k<=m; k++){ long long a = unko[0] % k; long long b = unko[1] % k; long long c = unko[2] % k; if(a == b && b == c){ x = k; } } long long g = gcd(l, x); l /= g; x /= g; cout << l << "/" << x << endl; return 0; }