結果
| 問題 |
No.14 最小公倍数ソート
|
| コンテスト | |
| ユーザー |
どらら
|
| 提出日時 | 2015-06-02 21:38:46 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 1,067 bytes |
| コンパイル時間 | 672 ms |
| コンパイル使用メモリ | 85,376 KB |
| 実行使用メモリ | 5,376 KB |
| 最終ジャッジ日時 | 2024-07-06 13:47:23 |
| 合計ジャッジ時間 | 59,372 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 15 TLE * 5 |
ソースコード
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cctype>
#include <cmath>
#include <iostream>
#include <queue>
#include <list>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <string>
#include <vector>
using namespace std;
#define REP(i,a,n) for(int i=(a); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define FOR(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); ++it)
#define ALLOF(c) (c).begin(), (c).end()
typedef long long ll;
int gcd(int a, int b){return (b==0?a:gcd(b,a%b));}
int lcm(int a, int b){return a/gcd(a,b)*b;}
struct ST {
int a, b;
};
bool operator<(const ST& a, const ST& b){
if(a.b==b.b) return a.a<b.a;
return a.b<b.b;
}
int main(){
ios::sync_with_stdio(false);
int N, a;
vector<ST> A;
cin >> N;
rep(i,N){
cin >> a;
A.push_back((ST){a,a});
}
rep(i,N){
REP(j,i+1,N){
A[j].b = lcm(A[i].a, A[j].a);
}
sort(A.begin()+i+1,A.end());
}
rep(i,A.size()){
if(i!=0) cout << " ";
cout << A[i].a;
}
cout << endl;
return 0;
}
どらら