Submission #57990215


Source Code Expand

#include <bits/stdc++.h>
using namespace std;
#define int long long

mt19937_64 RNG(chrono::steady_clock::now().time_since_epoch().count());

const int INF = 1e18;

int power(int a, int b) {
	if(b == 0) {
		return 1;
	}
	if(b == 1) {
		return a;
	}
	int x = power(a, b / 2);
	x *= x;
	if(b & 1) {
		x *= a;
	}
	return x;
}

void Solve() 
{
	int m;
	cin >> m;
	vector<int> ans;
	for(int i = 10; i >= 0; i--) {
		while(power(3LL, i) <= m) {
			m -= power(3LL, i);
			ans.push_back(i);
		}
	}
	cout << ans.size() << "\n";
	for(int i: ans) {
		cout << i << " ";
	}
	cout << "\n";
}

int32_t main() 
{
	auto begin = std::chrono::high_resolution_clock::now();
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int t = 1;
	// cin >> t;
	for(int i = 1; i <= t; i++) 
	{
		//cout << "Case #" << i << ": ";
		Solve();
	}
	auto end = std::chrono::high_resolution_clock::now();
    auto elapsed = std::chrono::duration_cast<std::chrono::nanoseconds>(end - begin);
    //cerr << "Time measured: " << elapsed.count() * 1e-9 << " seconds.\n"; 
	return 0;
}

Submission Info

Submission Time
Task B - 3^A
User aryan12
Language C++ 20 (gcc 12.2)
Score 200
Code Size 1093 Byte
Status AC
Exec Time 2 ms
Memory 3636 KiB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 200 / 200
Status
AC × 3
AC × 51
Set Name Test Cases
Sample 00_sample_100.txt, 00_sample_59048.txt, 00_sample_6.txt
All 00_sample_100.txt, 00_sample_59048.txt, 00_sample_6.txt, 01_small_1.txt, 01_small_10.txt, 01_small_11.txt, 01_small_2.txt, 01_small_3.txt, 01_small_4.txt, 01_small_5.txt, 01_small_7.txt, 01_small_8.txt, 01_small_9.txt, 02_large_39365.txt, 02_large_52487.txt, 02_large_56861.txt, 02_large_58319.txt, 02_large_58805.txt, 02_large_58967.txt, 02_large_59021.txt, 02_large_59039.txt, 02_large_59045.txt, 02_large_98414.txt, 03_handmade_100000.txt, 03_handmade_78732.txt, 03_handmade_98409.txt, 03_handmade_98412.txt, 03_handmade_98413.txt, 03_handmade_98415.txt, 03_handmade_99144.txt, 03_handmade_99870.txt, 03_handmade_99871.txt, 03_handmade_99872.txt, 03_handmade_99873.txt, 03_handmade_99953.txt, 03_handmade_99954.txt, 03_handmade_99981.txt, 03_handmade_99990.txt, 03_handmade_99997.txt, 03_handmade_99998.txt, 03_handmade_99999.txt, 04_random_11273.txt, 04_random_16808.txt, 04_random_27545.txt, 04_random_37710.txt, 04_random_43659.txt, 04_random_50074.txt, 04_random_50879.txt, 04_random_75250.txt, 04_random_77924.txt, 04_random_8931.txt
Case Name Status Exec Time Memory
00_sample_100.txt AC 1 ms 3456 KiB
00_sample_59048.txt AC 1 ms 3556 KiB
00_sample_6.txt AC 1 ms 3488 KiB
01_small_1.txt AC 1 ms 3488 KiB
01_small_10.txt AC 1 ms 3496 KiB
01_small_11.txt AC 1 ms 3552 KiB
01_small_2.txt AC 1 ms 3496 KiB
01_small_3.txt AC 1 ms 3408 KiB
01_small_4.txt AC 1 ms 3496 KiB
01_small_5.txt AC 1 ms 3348 KiB
01_small_7.txt AC 1 ms 3492 KiB
01_small_8.txt AC 1 ms 3512 KiB
01_small_9.txt AC 1 ms 3556 KiB
02_large_39365.txt AC 1 ms 3504 KiB
02_large_52487.txt AC 1 ms 3500 KiB
02_large_56861.txt AC 1 ms 3504 KiB
02_large_58319.txt AC 1 ms 3412 KiB
02_large_58805.txt AC 1 ms 3504 KiB
02_large_58967.txt AC 1 ms 3508 KiB
02_large_59021.txt AC 1 ms 3636 KiB
02_large_59039.txt AC 1 ms 3508 KiB
02_large_59045.txt AC 2 ms 3504 KiB
02_large_98414.txt AC 1 ms 3412 KiB
03_handmade_100000.txt AC 1 ms 3564 KiB
03_handmade_78732.txt AC 1 ms 3496 KiB
03_handmade_98409.txt AC 1 ms 3412 KiB
03_handmade_98412.txt AC 1 ms 3504 KiB
03_handmade_98413.txt AC 1 ms 3544 KiB
03_handmade_98415.txt AC 1 ms 3492 KiB
03_handmade_99144.txt AC 1 ms 3468 KiB
03_handmade_99870.txt AC 1 ms 3500 KiB
03_handmade_99871.txt AC 1 ms 3504 KiB
03_handmade_99872.txt AC 1 ms 3500 KiB
03_handmade_99873.txt AC 1 ms 3500 KiB
03_handmade_99953.txt AC 1 ms 3488 KiB
03_handmade_99954.txt AC 1 ms 3492 KiB
03_handmade_99981.txt AC 1 ms 3492 KiB
03_handmade_99990.txt AC 1 ms 3552 KiB
03_handmade_99997.txt AC 1 ms 3464 KiB
03_handmade_99998.txt AC 1 ms 3492 KiB
03_handmade_99999.txt AC 1 ms 3444 KiB
04_random_11273.txt AC 1 ms 3628 KiB
04_random_16808.txt AC 1 ms 3348 KiB
04_random_27545.txt AC 1 ms 3460 KiB
04_random_37710.txt AC 1 ms 3556 KiB
04_random_43659.txt AC 1 ms 3544 KiB
04_random_50074.txt AC 1 ms 3544 KiB
04_random_50879.txt AC 1 ms 3512 KiB
04_random_75250.txt AC 1 ms 3428 KiB
04_random_77924.txt AC 1 ms 3488 KiB
04_random_8931.txt AC 1 ms 3500 KiB