Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <algorithm>
- #include <bitset>
- #include <cassert>
- #include <cmath>
- #include <cstdint>
- #include <cstring>
- #include <deque>
- #include <fstream>
- #include <iomanip>
- #include <iostream>
- #include <limits>
- #include <map>
- #include <numeric>
- #include <ostream>
- #include <queue>
- #include <random>
- #include <set>
- #include <sstream>
- #include <stack>
- #include <string>
- #include <unordered_map>
- #include <unordered_set>
- #include <vector>
- using namespace std;
- /// Pragmas ///
- /// define ///
- #define pii pair<int, int>
- #define pll pair<ll, ll>
- #define V vector
- #define MP make_pair
- #define vi vector<int>
- #define ff first
- #define ss second
- #define vl vector<long long>
- /// typedef ///
- typedef long long ll;
- typedef long double ld;
- typedef unsigned long long ull;
- /// solve ///
- // consts
- const double PI = acos(-1);
- const ll MOD = 1000000007;
- const ll MOD2 = 1000000009;
- // const int p = 239;
- const ll p = 1'000'000;
- string inf;
- const int N = 150000 + 5000;
- const double eps = 1e-18;
- int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
- int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
- #define int long long
- ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
- ll lcm(ll a, ll b) { return a * (b / gcd(a, b)); }
- vl x = {6, 2, 3, 2, 4, 5, 4, 7};
- vl y = {0, 1, 1, 2, 0, 0, 1, 0};
- vl xy = {0, 1, 2, 3, 4, 5, 6, 8};
- void solve() {
- ull a, b;
- cin >> a >> b;
- inf = "";
- for (size_t i = 0; i < 352; i++) {
- inf += '9';
- }
- V<V<string>> dp(a + 30, V<string>(b + 30, inf));
- // baza база base
- for (size_t i = 1; i < x.size(); i++) {
- dp[x[i]][y[i]] = '0' + xy[i];
- }
- for (ll aa = 0; aa <= a; aa++) {
- for (ll bb = 0; bb <= b; bb++) {
- for (ll i = 0; i < x.size(); i++) {
- if (aa - x[i] < 0 || bb - y[i] < 0)
- continue;
- string temp = (dp[aa - x[i]][bb - y[i]]);
- temp += ('0' + xy[i]);
- if (temp.size() < dp[aa][bb].size()) {
- dp[aa][bb] = temp;
- } else if (temp.size() > dp[aa][bb].size()) {
- continue;
- } else {
- dp[aa][bb] = min(dp[aa][bb], temp);
- }
- }
- }
- }
- if (dp[a][b] == inf) {
- cout << "Wrong" << '\n';
- } else {
- cout << dp[a][b] << '\n';
- }
- }
- //
- signed main() {
- ios_base::sync_with_stdio(false);
- cin.tie(NULL);
- cout.tie(NULL);
- freopen("input.txt", "r", stdin);
- freopen("output.txt", "w", stdout);
- int t = 1;
- // cin >> t;
- while (t--)
- solve();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement