結果
| 問題 |
No.689 E869120 and Constructing Array 3
|
| ユーザー |
yosupot
|
| 提出日時 | 2018-05-18 23:43:09 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 2 ms / 1,000 ms |
| コード長 | 2,074 bytes |
| コンパイル時間 | 1,215 ms |
| コンパイル使用メモリ | 112,060 KB |
| 実行使用メモリ | 5,376 KB |
| 最終ジャッジ日時 | 2024-06-28 14:04:23 |
| 合計ジャッジ時間 | 2,289 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 13 |
ソースコード
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cassert>
#include <algorithm>
#include <numeric>
#include <random>
#include <vector>
#include <array>
#include <bitset>
#include <queue>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
using namespace std;
using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;
constexpr ll TEN(int n) { return (n==0) ? 1 : 10*TEN(n-1); }
template<class T> using V = vector<T>;
template<class T> using VV = V<V<T>>;
V<ll> v = {71, 26, 70, 31, 98, 29};
using P = pair<int, int>;
P ck(ll k, ll a) {
int ma = -1;
P res;
for (int i = 0; i <= a; i++) {
for (int j = 0; j <= a; j++) {
int z = i*j;
if (k < z) continue;
if (ma < z) {
ma = z;
res = P(i, j);
}
}
}
return res;
}
V<ll> ans;
void push(P p, ll a, ll b) {
for (int i = 0; i < p.first; i++) {
ans.push_back(a);
}
for (int i = 0; i < p.second; i++) {
ans.push_back(b);
}
}
bool ispr(ll x) {
for (int i = 2; i*i <= x; i++) {
if (x % i == 0) return false;
}
return true;
}
int main() {
// for (int i = 0; i < 6; i++) {
// for (int j = i+1; j < 6; j++) {
// if (ispr(v[i]+v[j])) {
// cout << "W " << i << " " << j << endl;
// }
// }
// }
ll k;
cin >> k;
P p1 = ck(k, 100);
k -= p1.first*p1.second;
P p2 = ck(k, 10);
k -= p2.first*p2.second;
P p3 = ck(k, 10);
k -= p3.first*p3.second;
push(p1, v[0], v[1]);
push(p2, v[2], v[3]);
push(p3, v[4], v[5]);
assert(k == 0);
// int n = int(ans.size());
// ll z = 0;
// for (int i = 0; i < n; i++) {
// for (int j = i+1; j < n; j++) {
// if (ispr(ans[i]+ans[j])) z++;
// }
// }
// cout << z << endl;
cout << ans.size() << endl;
for (ll d: ans) {
cout << d << " ";
}
cout << endl;
}
yosupot