結果

問題 No.689 E869120 and Constructing Array 3
ユーザー xuzijian629xuzijian629
提出日時 2018-08-30 08:50:10
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 2 ms / 1,000 ms
コード長 1,390 bytes
コンパイル時間 636 ms
コンパイル使用メモリ 81,328 KB
実行使用メモリ 4,352 KB
最終ジャッジ日時 2023-10-11 20:56:38
合計ジャッジ時間 2,494 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,348 KB
testcase_01 AC 1 ms
4,348 KB
testcase_02 AC 1 ms
4,352 KB
testcase_03 AC 1 ms
4,352 KB
testcase_04 AC 2 ms
4,352 KB
testcase_05 AC 2 ms
4,348 KB
testcase_06 AC 2 ms
4,352 KB
testcase_07 AC 2 ms
4,352 KB
testcase_08 AC 1 ms
4,348 KB
testcase_09 AC 1 ms
4,352 KB
testcase_10 AC 1 ms
4,348 KB
testcase_11 AC 2 ms
4,352 KB
testcase_12 AC 2 ms
4,348 KB
testcase_13 AC 1 ms
4,352 KB
testcase_14 AC 1 ms
4,352 KB
testcase_15 AC 2 ms
4,352 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:47:31: warning: ‘b’ may be used uninitialized in this function [-Wmaybe-uninitialized]
             for (int i = 0; i < r.second; i++) {
                             ~~^~~~~~~~~~
main.cpp:44:31: warning: ‘a’ may be used uninitialized in this function [-Wmaybe-uninitialized]
             for (int i = 0; i < r.first; i++) {
                             ~~^~~~~~~~~

ソースコード

diff #

#include <iostream>
#include <vector>
#include <array>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <map>
#include <unordered_map>
#include <cassert>
#pragma GCC optimize("O3")
#pragma comment(linker, "STACK:36777216")
using namespace std;
using i64 = int64_t;
constexpr i64 mod = 17;
using vi = vector<i64>;
using vvi = vector<vi>;
using ii = pair<i64, i64>;
using vii = vector<ii>;

ii simdiv(int n) {
    int a, b;
    for (int i = 1; i * i <= n; i++) {
        if (n % i == 0) {
            a = i;
            b = n / i;
        }
    }
    return ii(a, b);
}

int main() {
    int k;
    cin >> k;
    if (k == 0) {
        cout << "1\n1\n";
        return 0;
    }
    int n = k;
    while (1) {
        ii r = simdiv(n);
        if (r.first + r.second + k - n < 248) {
            vi ans;
            for (int i = 0; i < r.first; i++) {
                ans.push_back(2);
            }
            for (int i = 0; i < r.second; i++) {
                ans.push_back(3);
            }
            ans.push_back(7);
            for (int i = 0; i < k - n; i++) {
                ans.push_back(6);
            }
            cout << ans.size() << endl;
            for (int i = 0; i < ans.size() - 1; i++) {
                cout << ans[i] << " ";
            }
            cout << ans.back() << endl;
            return 0;
        }
        n--;
    }
}
0