結果

問題 No.3316 Make 81181819 with only 0,1,or 8
コンテスト
ユーザー Aeren
提出日時 2025-10-31 21:23:20
言語 C++23
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 2,031 bytes
コンパイル時間 3,269 ms
コンパイル使用メモリ 283,512 KB
実行使用メモリ 7,720 KB
最終ジャッジ日時 2025-10-31 21:23:27
合計ジャッジ時間 6,848 ms
ジャッジサーバーID
(参考情報)
judge3 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other AC * 1 WA * 21
権限があれば一括ダウンロードができます

ソースコード

diff #

// #pragma GCC target("avx2,bmi2,popcnt,lzcnt")
// #pragma GCC optimize("O3,unroll-loops")
#include <bits/stdc++.h>
// #include <x86intrin.h>
using namespace std;
using namespace numbers;
#ifdef LOCAL
	#include "Debug.h"
#else
	#define debug_endl() 42
	#define debug(...) 42
	#define debug2(...) 42
	#define debug_bin(...) 42
#endif
// Returns the largest integer k with x >= k * y
template<class T, class U> T floor_div(T x, U y){
	assert(y > 0);
	return x / y - (x % y < 0);
}
// Returns the smallest integer k with x <= k * y
template<class T, class U> T ceil_div(T x, U y){
	assert(y > 0);
	return x / y + (x % y > 0);
}
template<class T> T &ctmin(T &x){ return x; }
template<class T, class Head, class ...Tail> T &ctmin(T &x, const Head &h, const Tail &... t){ return ctmin(x = min<T>(x, h), t...); }
template<class T> T &ctmax(T &x){ return x; }
template<class T, class Head, class ...Tail> T &ctmax(T &x, const Head &h, const Tail &... t){ return ctmax(x = max<T>(x, h), t...); }



int main(){
	cin.tie(0)->sync_with_stdio(0);
	cin.exceptions(ios::badbit | ios::failbit);
	const int mx = 81181819;
	vector<int> pow{1};
	while((int)pow.size() < 9){
		pow.push_back(pow.back() * 10);
	}
	auto solve_testcase = [&](auto testcase_id)->int{
		int s;
		cin >> s, s = mx - s;
		auto solve = [&](int res)->optional<vector<int>>{
			vector<int> value(res);
			int rem = s;\
			for(auto d = 7; d >= 0; -- d){
				int i = 0;
				for(auto x: {8, 1}){
					while(i < res && rem >= x * pow[d]){
						value[i ++] += x * pow[d];
						rem -= x * pow[d];
					}
				}
			}
			return !rem ? value : optional<vector<int>>{};
		};
		for(auto res = 1; res <= 9; ++ res){
			if(auto res_ptr = solve(res)){
				cout << res << "\n";
				ranges::copy(*res_ptr, ostream_iterator<int>(cout, "\n"));
				return 0;
			}
		}
		assert(false);
		return 0;
	};
	int testcase_count;
	cin >> testcase_count;
	for(auto testcase_id = 0; testcase_id < testcase_count; ++ testcase_id){
		solve_testcase(testcase_id);
	}
	return 0;
}

/*
70

18 11 11 10 10 10
*/
0