結果
| 問題 |
No.2081 Make a Test Case of GCD Subset
|
| コンテスト | |
| ユーザー |
Rubikun
|
| 提出日時 | 2024-07-11 05:10:14 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,619 bytes |
| コンパイル時間 | 2,101 ms |
| コンパイル使用メモリ | 197,176 KB |
| 最終ジャッジ日時 | 2025-02-22 02:58:54 |
|
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | WA * 1 |
| other | WA * 27 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return true; } return false; }
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define mp make_pair
#define si(x) int(x.size())
const int mod=998244353,MAX=300005,INF=15<<26;
vector<int> prime;//i番目の素数
bool is_prime[MAX+1];
void sieve(int n){
for(int i=0;i<=n;i++){
is_prime[i]=true;
}
is_prime[0]=is_prime[1]=false;
for(int i=2;i<=n;i++){
if(is_prime[i]){
prime.push_back(i);
for(int j=2*i;j<=n;j+=i){
is_prime[j] = false;
}
}
}
}
int main(){
std::ifstream in("text.txt");
std::cin.rdbuf(in.rdbuf());
cin.tie(0);
ios::sync_with_stdio(false);
sieve(100000);
ll M;cin>>M;
vector<ll> ans;
ll id=0,z=0;
ll MM=M;
while(MM){
for(ll t=33;t>=0;t--){
if((1LL<<t)-1<=MM){
z+=t;
MM-=((1LL<<t)-1);
}
}
}
z--;
while(M){
for(ll t=33;t>=0;t--){
if((1LL<<t)-1<=M){
ans.push_back(prime[id]);
for(ll k=1;k<t;k++) ans.push_back(prime[id]*prime[z--]);
M-=((1LL<<t)-1);
id++;
}
}
}
cout<<si(ans)<<"\n";
for(int i=0;i<si(ans);i++){
if(i) cout<<" ";
cout<<ans[i];
}
cout<<"\n";
}
Rubikun