結果
| 問題 | No.14 最小公倍数ソート |
| コンテスト | |
| ユーザー |
k
|
| 提出日時 | 2014-10-31 13:47:25 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
CE
(最新)
AC
(最初)
|
| 実行時間 | - |
| コード長 | 975 bytes |
| コンパイル時間 | 500 ms |
| コンパイル使用メモリ | 67,164 KB |
| 最終ジャッジ日時 | 2025-11-17 12:32:07 |
| 合計ジャッジ時間 | 803 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
コンパイルエラー時のメッセージ・ソースコードは、提出者また管理者しか表示できないようにしております。(リジャッジ後のコンパイルエラーは公開されます)
ただし、clay言語の場合は開発者のデバッグのため、公開されます。
ただし、clay言語の場合は開発者のデバッグのため、公開されます。
コンパイルメッセージ
main.cpp:17:9: error: ‘uint64_t’ does not name a type
17 | typedef uint64_t ll;
| ^~~~~~~~
main.cpp:13:1: note: ‘uint64_t’ is defined in header ‘<cstdint>’; did you forget to ‘#include <cstdint>’?
12 | #include <cctype>
+++ |+#include <cstdint>
13 | #include <string>
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:33:8: error: ‘a’ was not declared in this scope
33 | sort(a+1, a+n);
| ^
main.cpp:37:7: error: expected ‘;’ before ‘mini’
37 | ll mini = 1000000000;
| ^~~~~
| ;
main.cpp:40:22: error: ‘mini’ was not declared in this scope
40 | if (p != -1 && mini < a[j]) break;
| ^~~~
main.cpp:41:9: error: expected ‘;’ before ‘t’
41 | ll t = lcm(a[i], a[j]);
| ^~
| ;
main.cpp:42:11: error: ‘mini’ was not declared in this scope
42 | if (mini > t) p = j;
| ^~~~
main.cpp:42:18: error: ‘t’ was not declared in this scope
42 | if (mini > t) p = j;
| ^
main.cpp:43:22: error: ‘mini’ was not declared in this scope
43 | if (p != -1 && mini == t && a[p] > a[j]) p = j;
| ^~~~
main.cpp:43:30: error: ‘t’ was not
ソースコード
#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++) {
if (p != -1 && mini < a[j]) break;
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]);
sort(a+i+2, a+n);
}
}
k