結果
問題 |
No.14 最小公倍数ソート
|
ユーザー |
|
提出日時 | 2015-01-11 21:53:44 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
TLE
|
実行時間 | - |
コード長 | 1,021 bytes |
コンパイル時間 | 809 ms |
コンパイル使用メモリ | 95,472 KB |
実行使用メモリ | 10,140 KB |
最終ジャッジ日時 | 2024-06-13 03:48:23 |
合計ジャッジ時間 | 7,716 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 4 TLE * 1 -- * 15 |
ソースコード
#include <cstdio> #include <iostream> #include <sstream> #include <fstream> #include <iomanip> #include <algorithm> #include <cmath> #include <string> #include <vector> #include <list> #include <queue> #include <stack> #include <set> #include <map> #include <bitset> #include <numeric> #include <limits> #include <climits> #include <cfloat> #include <functional> using namespace std; long long gcd(long long a, long long b){ while(b != 0){ long long tmp = a % b; a = b; b = tmp; } return a; } long long lcm(long long a, long long b){ return a / gcd(a, b) * b; } int main() { int n; cin >> n; vector<pair<int, int> > a(n); for(int i=0; i<n; ++i) cin >> a[i].second; for(int i=0; i<n; ++i){ for(int j=i+1; j<n; ++j) a[j].first = lcm(a[i].second, a[j].second); sort(a.begin() + i + 1, a.end()); } cout << a[0].second; for(int i=1; i<n; ++i) cout << ' ' << a[i].second; cout << endl; return 0; }