結果
| 問題 | No.14 最小公倍数ソート |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2019-02-21 17:50:57 |
| 言語 | C++14 (gcc 15.2.0 + boost 1.89.0) |
| 結果 |
AC
|
| 実行時間 | 1,199 ms / 5,000 ms |
| コード長 | 726 bytes |
| 記録 | |
| コンパイル時間 | 600 ms |
| コンパイル使用メモリ | 90,964 KB |
| 実行使用メモリ | 6,400 KB |
| 最終ジャッジ日時 | 2026-05-13 13:34:18 |
| 合計ジャッジ時間 | 15,566 ms |
|
ジャッジサーバーID (参考情報) |
judge1_1 / judge3_1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 20 |
コンパイルメッセージ
In file included from /home/linuxbrew/.linuxbrew/Cellar/gcc/15.2.0_1/include/c++/15/x86_64-pc-linux-gnu/bits/c++allocator.h:33,
from /home/linuxbrew/.linuxbrew/Cellar/gcc/15.2.0_1/include/c++/15/bits/allocator.h:46,
from /home/linuxbrew/.linuxbrew/Cellar/gcc/15.2.0_1/include/c++/15/string:45,
from /home/linuxbrew/.linuxbrew/Cellar/gcc/15.2.0_1/include/c++/15/bits/locale_classes.h:42,
from /home/linuxbrew/.linuxbrew/Cellar/gcc/15.2.0_1/include/c++/15/bits/ios_base.h:43,
from /home/linuxbrew/.linuxbrew/Cellar/gcc/15.2.0_1/include/c++/15/ios:46,
from /home/linuxbrew/.linuxbrew/Cellar/gcc/15.2.0_1/include/c++/15/bits/ostream.h:43,
from /home/linuxbrew/.linuxbrew/Cellar/gcc/15.2.0_1/include/c++/15/ostream:42,
from /home/linuxbrew/.linuxbrew/Cellar/gcc/15.2.0_1/include/c++/15/iostream:43,
from main.cpp:1:
In member function 'void std::__new_allocator<_Tp>::construct(_Up*, _Args&& ...) [with _Up = int; _Args = {const int&}; _Tp = int]',
inlined from 'static void std::allocator_traits<std::allocator<_CharT> >::construct(allocator_type&, _Up*, _Args&& ...) [with _Up = int; _Args = {const int&}; _Tp = int]' at /home/linuxbrew/.linuxbrew/Cellar/gcc/15.2.0_1/include/c++/15/bits/alloc_traits.h:674:17,
inlined from 'void std::vector<_Tp, _Alloc>::_M_realloc_append(_Args&& ...) [with _Args = {const int&}; _Tp = int; _Alloc = std::allocator<int>]' at /home/linuxbrew/.linuxbrew/Cellar/gcc/15.2.0_1/include/c++/15/bits/vector.tcc:586:26,
inlined from 'void std::vector<_Tp, _Alloc>::push_back(const value_type&) [with _Tp = int; _Alloc = std::allocator<int>]' at /home/linuxbrew/.linuxbrew/Cellar/gcc/15.2.0_1/include/c++/15/bits/stl_vector.h:1427:21,
inlined from 'int main()' at main.cpp:28:20:
/home/linuxbrew/.linuxbrew/Cellar/gcc/15.2.0_1/include/c++/15/bits/new_allocator.h:191:11: warning: 'take' may be used uninitiali
ソースコード
#include<iostream>
#include<set>
#include<vector>
using namespace std;
int gcd(int a, int b){
return b == 0 ? a : gcd(b, a%b);
}
int main(){
int n;
cin >> n;
int now;
cin >> now;
vector<int> v(1, now);
multiset<int> s; int x;
for(int i = 1; i < n; i++) cin >> x, s.insert(x);
while(!s.empty()){
int tmp = 1<<30, take;
for(int x : s){
if(x > tmp) break;
int lcm = now*x/gcd(now,x);
if(tmp > lcm){
tmp = lcm;
take = x;
}
}
v.push_back(take);
s.erase(s.find(take));
now = take;
}
for(int i = 0; i < n; i++) cout << v[i] << " \n"[i==n-1];
return 0;
}