結果
| 問題 |
No.2609 Decreasing GCDs
|
| コンテスト | |
| ユーザー |
planes
|
| 提出日時 | 2024-01-19 22:06:11 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 11 ms / 1,000 ms |
| コード長 | 843 bytes |
| コンパイル時間 | 1,599 ms |
| コンパイル使用メモリ | 171,864 KB |
| 実行使用メモリ | 5,376 KB |
| 最終ジャッジ日時 | 2024-09-28 04:30:37 |
| 合計ジャッジ時間 | 2,733 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | AC * 22 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
using ll =long long;
#define all(v) v.begin(),v.end()
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
ll INF=2e18;
long long GCD(long long a, long long b) {
if (b == 0) return a;
else return GCD(b, a % b);
}
int main() {
ios::sync_with_stdio(false);
cin.tie(0);
ll M=1000000;
vector<bool> note(M);
vector<ll> p(0);
for(ll i=2;i<M;i++) {
if(note[i]) continue;
for(ll j=1;j*i<M;j++) note[j*i]=true;
p.push_back(i);
}
ll N;cin>>N;
vector<ll> ans(N,1);
ll ind=0;
for(ll i=N-1;i>=1;i--) {
ans[i]*=p[ind];
ans[i-1]*=p[ind];
ind++;
}
for(ll i=1;i<N;i++) {
if(ans[i]<=ans[i-1]) {
while(ans[i]*p[ind]<=ans[i-1]) {
ind++;
}
ans[i]*=p[ind];
ind++;
}
}
for(auto x:ans) cout<<x<<" ";
cout<<endl;
}
planes