結果
| 問題 | No.14 最小公倍数ソート |
| コンテスト | |
| ユーザー |
k
|
| 提出日時 | 2014-10-31 13:28:37 |
| 言語 | C++11 (gcc 15.2.0 + boost 1.89.0) |
| 結果 |
CE
(最新)
TLE
(最初)
|
| 実行時間 | - |
| コード長 | 914 bytes |
| 記録 | |
| コンパイル時間 | 390 ms |
| コンパイル使用メモリ | 79,836 KB |
| 最終ジャッジ日時 | 2026-06-04 04:47:13 |
| 合計ジャッジ時間 | 1,173 ms |
|
ジャッジサーバーID (参考情報) |
judge1_0 / judge2_0 |
(要ログイン)
コンパイルエラー時のメッセージ・ソースコードは、提出者また管理者しか表示できないようにしております。(リジャッジ後のコンパイルエラーは公開されます)
ただし、clay言語の場合は開発者のデバッグのため、公開されます。
ただし、clay言語の場合は開発者のデバッグのため、公開されます。
コンパイルメッセージ
main.cpp:17:9: error: 'uint64_t' does not name a type
17 | typedef uint64_t ll;
| ^~~~~~~~
main.cpp:12:1: note: 'uint64_t' is defined in header '<cstdint>'; this is probably fixable by adding '#include <cstdint>'
11 | #include <ctime>
+++ |+#include <cstdint>
12 | #include <cctype>
main.cpp:19:1: error: 'll' does not name a type
19 | ll gcd(ll a, ll b){
| ^~
main.cpp:24:1: error: 'll' does not name a type
24 | ll lcm(ll a, ll b){
| ^~
main.cpp: In function 'int main()':
main.cpp:29:3: error: 'll' was not declared in this scope
29 | ll n;
| ^~
main.cpp:30:10: error: 'n' was not declared in this scope; did you mean 'yn'?
30 | cin >> n;
| ^
| yn
main.cpp:31:5: error: expected ';' before 'a'
31 | ll a[n];
| ^~
| ;
main.cpp:32:46: error: 'a' was not declared in this scope
32 | for (int i = 0; i < n; i++) scanf("%llu", &a[i]);
| ^
main.cpp:35:20: error: 'a' was not declared in this scope
35 | printf ("%llu ", a[0]);
| ^
main.cpp:37:7: error: expected ';' before 'mini'
37 | ll mini = 1000000000;
| ^~~~~
| ;
main.cpp:40:9: error: expected ';' before 't'
40 | ll t = lcm(a[i], a[j]);
| ^~
| ;
main.cpp:41:11: error: 'mini' was not declared in this scope
41 | if (mini > t) p = j;
| ^~~~
main.cpp:41:18: error: 't' was not declared in this scope
41 | if (mini > t) p = j;
| ^
main.cpp:42:22: error: 'mini' was not declared in this scope
42 | if (p != -1 && mini == t && a[p] > a[j]) p = j;
| ^~~~
main.cpp:42:30: error: 't' was not declared in this scope
42 | if (p != -1 && mini == t && a[p] > a[j]) p = j;
| ^
main.cpp:43:7: error: 'mini' was not declared in this scope
43 | m
ソースコード
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <algorithm>
#include <functional>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cctype>
#include <string>
using namespace std;
typedef uint64_t ll;
ll gcd(ll a, ll b){
if(b==0)return a;
else return gcd(b, a%b);
}
ll lcm(ll a, ll b){
return a / gcd(a,b) * b;
}
int main() {
ll n;
cin >> n;
ll a[n];
for (int i = 0; i < n; i++) scanf("%llu", &a[i]);
// sort(a+1, a+n);
printf ("%llu ", a[0]);
for (int i = 0; i < n-1; i++) {
ll mini = 1000000000;
int p = -1;
for (int j = i+1; j < n; j++) {
ll t = lcm(a[i], a[j]);
if (mini > t) p = j;
if (p != -1 && mini == t && a[p] > a[j]) p = j;
mini = min(mini, t);
}
printf ("%llu ", a[p]);
swap(a[p], a[i+1]);
}
}
k