Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- using namespace std;
- #define pb push_back
- #define mp make_pair
- #define forn(i, a, n) for (auto (i) = (a); (i) < (n); ++i)
- #define int ll
- #define fs first
- #define sc second
- typedef long long ll;
- typedef unsigned long long ull;
- typedef long double ld;
- const int maxn = 1e5 + 7;
- const int inf = 1e9 + 7;
- const ld eps = 1e-6;
- string dp[10000];
- signed main() {
- ios_base::sync_with_stdio(0);
- cin.tie(0); cout.tie(0);
- int n;
- cin >> n;
- forn (i, 0, 2) {
- forn (j, 0, 2) {
- forn (k, 0, 2) {
- forn (l, 0, 2) {
- string x = "";
- int ind = 0;
- if (!i) {
- x += '2';
- ind += 2000;
- }
- else {
- x += '3';
- ind += 3000;
- }
- if (!j) {
- x += '2';
- ind += 200;
- }
- else {
- x += '3';
- ind += 300;
- }
- if (!k) {
- x += '2';
- ind += 20;
- }
- else {
- x += '3';
- ind += 30;
- }
- if (!l) {
- x += '2';
- ind += 2;
- }
- else {
- x += '3';
- ind += 3;
- }
- dp[ind] = x;
- }
- }
- }
- }
- forn (i, 0, 2) {
- forn (j, 0, 2) {
- forn (k, 0, 2) {
- string x = "";
- int ind = 0;
- if (!i) {
- ind += 200;
- x += '2';
- }
- else {
- ind += 300;
- x += '3';
- }
- if (!j) {
- ind += 20;
- x += '2';
- }
- else {
- ind += 30;
- x += '3';
- }
- if (!k) {
- ind += 2;
- x += '2';
- }
- else {
- ind += 3;
- x += 3;
- }
- dp[ind] = x;
- }
- }
- }
- dp[22] = "22";
- dp[23] = "23";
- dp[32] = "32";
- dp[33] = "33";
- dp[3] = "3";
- dp[2] = "2";
- forn (i, 0, 10000) {
- if (dp[i] == "")
- continue ;
- forn (j, 0, 10000) {
- if (dp[j] == "")
- continue ;
- int ind = i * j;
- if (ind >= 10000)
- break ;
- if (dp[i * j].size() > dp[i].size() + 1 + dp[j].size() || dp[i * j] == "") {
- dp[i * j] = dp[i];
- dp[i * j] += '*';
- dp[i * j] += dp[j];
- }
- }
- }
- forn (i, 0, 10000) {
- if (dp[i] == "")
- continue ;
- forn (j, 0, 10000) {
- if (dp[j] == "")
- continue ;
- int ind = i + j;
- if (ind >= 10000)
- break ;
- if (dp[i + j].size() > (dp[i].size() + dp[j].size() + 1) || dp[i + j] == "") {
- dp[i + j] = dp[i];
- dp[i + j] += '+';
- dp[i + j] += dp[j];
- }
- }
- }
- if (dp[n] == "") {
- cout << "No solution";
- }
- else {
- cout << dp[n];
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement