結果
| 問題 |
No.2610 Decreasing LCMs
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2024-01-19 22:29:33 |
| 言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 2 ms / 1,000 ms |
| コード長 | 1,074 bytes |
| コンパイル時間 | 3,340 ms |
| コンパイル使用メモリ | 255,604 KB |
| 実行使用メモリ | 5,376 KB |
| 最終ジャッジ日時 | 2024-09-28 04:46:35 |
| 合計ジャッジ時間 | 3,906 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | AC * 22 |
ソースコード
#include <bits/stdc++.h>
// #include <x86intrin.h>
using namespace std;
#if __cplusplus >= 202002L
using namespace numbers;
#endif
int main(){
cin.tie(0)->sync_with_stdio(0);
cin.exceptions(ios::badbit | ios::failbit);
int n;
cin >> n;
vector<int> a(n);
a[n - 1] = 1 << __lg(100'000'000);
a[n - 2] = a[n - 1] / 2;
vector<array<int, 2>> dif(n - 1);
dif[n - 2] = {1, 2};
for(auto i = n - 3; i >= 0; -- i){
int num = dif[i + 1][1];
while(gcd(a[i + 1], num) != 1 || 1LL * num * a[i + 1] <= lcm<long long>(a[i + 1], a[i + 2])){
++ num;
}
int den = num + 1;
while(a[i + 1] % den){
++ den;
}
dif[i] = {num, den};
a[i] = a[i + 1] / den * num;
}
ranges::copy(a, ostream_iterator<int>(cout, " "));
cout << endl;
assert(ranges::max(a) <= 100'000'000);
for(auto i = 0; i < n - 1; ++ i){
assert(a[i] < a[i + 1]);
}
for(auto i = 1; i < n - 1; ++ i){
assert(lcm<long long>(a[i - 1], a[i]) > lcm<long long>(a[i], a[i + 1]));
}
return 0;
}
/*
19 17 13 11 7 5 3
1 2 4 8 16 32 64
a<b<c
g h
ab/g > bc/h
a/g > c/h
13 11 9 7 5
1 2 4 8 16
*/