結果
| 問題 |
No.689 E869120 and Constructing Array 3
|
| ユーザー |
beet
|
| 提出日時 | 2018-05-18 23:06:08 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 3 ms / 1,000 ms |
| コード長 | 1,005 bytes |
| コンパイル時間 | 1,581 ms |
| コンパイル使用メモリ | 170,128 KB |
| 実行使用メモリ | 5,376 KB |
| 最終ジャッジ日時 | 2024-06-28 13:58:33 |
| 合計ジャッジ時間 | 2,834 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 13 |
ソースコード
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
Int isprime(Int x){
if(x<=1) return 0;
for(Int i=2;i*i<=x;i++)
if(x%i==0) return 0;
return 1;
}
//INSERT ABOVE HERE
signed main(){
vector<Int> ps1,ps2;
for(Int i=11;ps1.size()<250u;i+=6)
if(isprime(i)) ps1.emplace_back(i);
for(Int i=13;ps2.size()<250u;i+=6)
if(isprime(i)) ps2.emplace_back(i);
Int k;
cin>>k;
if(!k){
cout<<1<<endl<<1<<endl;
return 0;
}
for(Int i=0;i<250;i++){
for(Int x=1;x<250;x++){
for(Int y=0;y<250;y++){
if(k<i*y+x*y+(x*(x-1)/2)) continue;
if((k-(i*y+x*y+(x*(x-1)/2)))%x) continue;
Int z=(k-(i*y+x*y+(x*(x-1)/2)))/x;
//cout<<i<<" "<<x<<" "<<y<<" "<<z<<endl;
Int n=i+x+y+z;
if(n>250) continue;
cout<<n<<endl;
for(Int j=0;j<x;j++){
if(j) cout<<" ";
cout<<1;
}
for(Int j=0;j<i;j++)
cout<<" "<<ps2[j]-2;
for(Int j=0;j<z;j++)
cout<<" "<<ps1[j]-1;
for(Int j=0;j<y;j++)
cout<<" "<<2;
cout<<endl;
return 0;
}
}
}
return 0;
}
beet