output
stringlengths
52
181k
instruction
stringlengths
296
182k
#include <bits/stdc++.h> using namespace std; int possibleKoutsu(string str1, string str2) { if (str1[0] == str2[0] && str1[1] == str2[1]) return 1; return 0; } int possibleShuntsu(string str1, string str2) { int diff = (int)str1[0] - (int)str2[0]; if (str1[1] == str2[1] && (abs(diff) == 1 || abs(diff) == 2)) r...
### Prompt Develop a solution in cpp to the problem described below: Tokitsukaze is playing a game derivated from Japanese mahjong. In this game, she has three tiles in her hand. Each tile she owns is a suited tile, which means it has a suit (manzu, pinzu or souzu) and a number (a digit ranged from 1 to 9). In this p...
#include <bits/stdc++.h> using namespace std; bitset<65000000> f; long long m[200995]; vector<long long> z; map<long long, long long> u; map<long long, long long> u1; map<string, int> v; string w[200008]; int main() { ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); long long t, c, d, e, i...
### Prompt Generate a Cpp solution to the following problem: Tokitsukaze is playing a game derivated from Japanese mahjong. In this game, she has three tiles in her hand. Each tile she owns is a suited tile, which means it has a suit (manzu, pinzu or souzu) and a number (a digit ranged from 1 to 9). In this problem, ...
#include <bits/stdc++.h> using namespace std; int main() { ios::sync_with_stdio(0); cin.tie(0); string tiles[4]; cin >> tiles[0] >> tiles[1] >> tiles[2]; sort(tiles, tiles + 3); map<string, int> k; map<char, vector<int> > s; for (int i = 0; i < 3; ++i) k[tiles[i]]++, s[tiles[i][1]].push_back(tiles[i...
### Prompt Your task is to create a CPP solution to the following problem: Tokitsukaze is playing a game derivated from Japanese mahjong. In this game, she has three tiles in her hand. Each tile she owns is a suited tile, which means it has a suit (manzu, pinzu or souzu) and a number (a digit ranged from 1 to 9). In ...
#include <bits/stdc++.h> using namespace std; int main() { string s[3]; for (int i = 0; i < 3; i++) { cin >> s[i]; } if (s[0][0] > s[1][0]) swap(s[0], s[1]); if (s[1][0] > s[2][0]) swap(s[1], s[2]); if (s[0][0] > s[1][0]) swap(s[0], s[1]); int c1 = 1, c2 = 1; for (int i = 0; i < 2; i++) { if (s[...
### Prompt Generate a Cpp solution to the following problem: Tokitsukaze is playing a game derivated from Japanese mahjong. In this game, she has three tiles in her hand. Each tile she owns is a suited tile, which means it has a suit (manzu, pinzu or souzu) and a number (a digit ranged from 1 to 9). In this problem, ...
#include <bits/stdc++.h> using namespace std; int primes[] = {2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89}; string alpha = "abcdefghijklmnopqrstuvwxyz"; signed main() { string s[3]; ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); c...
### Prompt Generate a Cpp solution to the following problem: Tokitsukaze is playing a game derivated from Japanese mahjong. In this game, she has three tiles in her hand. Each tile she owns is a suited tile, which means it has a suit (manzu, pinzu or souzu) and a number (a digit ranged from 1 to 9). In this problem, ...
#include <bits/stdc++.h> using namespace std; const long long mod = 1e9 + 7, siz = 1e6 + 5; long long t, n, m, k, a[siz]; vector<long long> v[4]; string s1, s2, s3; void chk(string s) { if (s[1] == 'm') v[1].push_back(s[0] - '0'); else if (s[1] == 'p') v[2].push_back(s[0] - '0'); else v[3].push_back(s...
### Prompt Please formulate a Cpp solution to the following problem: Tokitsukaze is playing a game derivated from Japanese mahjong. In this game, she has three tiles in her hand. Each tile she owns is a suited tile, which means it has a suit (manzu, pinzu or souzu) and a number (a digit ranged from 1 to 9). In this p...
#include <bits/stdc++.h> using namespace std; char s[100]; pair<int, int> arr[10]; int ttt(char a) { if (a == 's') return 1; if (a == 'p') return 2; return 3; } int main() { gets(s); int pos = 0; for (int i = 1; i <= 3; i++) { int x = s[pos] - '0'; pos++; int y = ttt(s[pos]); pos += 2; a...
### Prompt Develop a solution in Cpp to the problem described below: Tokitsukaze is playing a game derivated from Japanese mahjong. In this game, she has three tiles in her hand. Each tile she owns is a suited tile, which means it has a suit (manzu, pinzu or souzu) and a number (a digit ranged from 1 to 9). In this p...
#include <bits/stdc++.h> using namespace std; vector<string> v(3); bool f0() { if (v[0] == v[1] && v[0] == v[2]) return true; if (v[0][1] == v[1][1] && v[0][1] == v[2][1] && v[1][0] == v[0][0] + 1 && v[2][0] == v[1][0] + 1) return true; return false; } bool f1() { for (int i = 0; i < 3; ++i) for (...
### Prompt Your challenge is to write a Cpp solution to the following problem: Tokitsukaze is playing a game derivated from Japanese mahjong. In this game, she has three tiles in her hand. Each tile she owns is a suited tile, which means it has a suit (manzu, pinzu or souzu) and a number (a digit ranged from 1 to 9)....
#include <bits/stdc++.h> using namespace std; int main() { int i; vector<int> v; string s1, s2, s3; cin >> s1 >> s2 >> s3; if (s1[1] == s2[1] && s1[1] == s3[1]) { v.push_back(s1[0]); v.push_back(s2[0]); v.push_back(s3[0]); sort(v.begin(), v.end()); if ((v[0] + 1) == v[1] && (v[1] + 1 == v[...
### Prompt Please create a solution in CPP to the following problem: Tokitsukaze is playing a game derivated from Japanese mahjong. In this game, she has three tiles in her hand. Each tile she owns is a suited tile, which means it has a suit (manzu, pinzu or souzu) and a number (a digit ranged from 1 to 9). In this p...
#include <bits/stdc++.h> using namespace std; int main() { string t1, t2, t3; char m1, m2, m3; cin >> t1 >> t2 >> t3; int n1, n2, n3; vector<int> a(3); n1 = t1[0] - '0'; n2 = t2[0] - '0'; n3 = t3[0] - '0'; m1 = t1[1]; m2 = t2[1]; m3 = t3[1]; a[0] = n1; a[1] = n2; a[2] = n3; sort(a.begin(),...
### Prompt In cpp, your task is to solve the following problem: Tokitsukaze is playing a game derivated from Japanese mahjong. In this game, she has three tiles in her hand. Each tile she owns is a suited tile, which means it has a suit (manzu, pinzu or souzu) and a number (a digit ranged from 1 to 9). In this proble...
#include <bits/stdc++.h> using namespace std; signed main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); ; string s[3]; cin >> s[0] >> s[1] >> s[2]; if (s[0] == s[1] and s[1] == s[2]) { cout << "0\n"; return 0; } sort(s, s + 3); char a = s[0][0] + 1; char c = s[2][0] ...
### Prompt Please create a solution in cpp to the following problem: Tokitsukaze is playing a game derivated from Japanese mahjong. In this game, she has three tiles in her hand. Each tile she owns is a suited tile, which means it has a suit (manzu, pinzu or souzu) and a number (a digit ranged from 1 to 9). In this p...
#include <bits/stdc++.h> using namespace std; long long smallest(long long x, long long y, long long z) { long long c = 0; while (x && y && z) { x--; y--; z--; c++; } return c; } long long smallest(long long x, long long y) { return (x < y) ? x : y; } void solve() { string input[3]; long lon...
### Prompt Please provide a CPP coded solution to the problem described below: Tokitsukaze is playing a game derivated from Japanese mahjong. In this game, she has three tiles in her hand. Each tile she owns is a suited tile, which means it has a suit (manzu, pinzu or souzu) and a number (a digit ranged from 1 to 9)....
#include <bits/stdc++.h> using namespace std; long long gcd(long long a_, long long b_) { if (b_ > a_) swap(b_, a_); return (b_ == 0 ? a_ : gcd(b_, a_ % b_)); } int n, arr[15][10]; char c; int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(NULL); for (long long i = 0; i < 3; i++) { cin >> n...
### Prompt Please create a solution in cpp to the following problem: Tokitsukaze is playing a game derivated from Japanese mahjong. In this game, she has three tiles in her hand. Each tile she owns is a suited tile, which means it has a suit (manzu, pinzu or souzu) and a number (a digit ranged from 1 to 9). In this p...
#include <bits/stdc++.h> using namespace std; using ll = long long; using ull = unsigned long long; using pii = pair<int, int>; const int mod = 1e9 + 7; const int maxn = 1e6 + 5; string s[3]; bool isShun1(int i, int j) { return (s[i][1] == s[j][1] && s[i][0] == s[j][0] - 1); } bool isShun2(int i, int j) { return (s...
### Prompt Generate a Cpp solution to the following problem: Tokitsukaze is playing a game derivated from Japanese mahjong. In this game, she has three tiles in her hand. Each tile she owns is a suited tile, which means it has a suit (manzu, pinzu or souzu) and a number (a digit ranged from 1 to 9). In this problem, ...
#include <bits/stdc++.h> using namespace std; const long long mx = 1e6 + 9; const long long inf = 1e18 + 9; long long A[mx], B[mx], freq[mx], fr[mx]; vector<pair<long long, long long> > vp1, vp2; vector<long long> v1; vector<char> v2; bool sign[mx]; map<char, bool> mp; int32_t main() { long long n = 0, m = 0, k = 0, ...
### Prompt Develop a solution in cpp to the problem described below: Tokitsukaze is playing a game derivated from Japanese mahjong. In this game, she has three tiles in her hand. Each tile she owns is a suited tile, which means it has a suit (manzu, pinzu or souzu) and a number (a digit ranged from 1 to 9). In this p...
#include <bits/stdc++.h> using namespace std; map<string, int> m; int main() { string s; string b[4]; int ind = 0; for (int i = 1; i <= 3; i++) { string a; cin >> a; b[i] = a; if (i > 1) { if (a != s) ind = 1; } m[a]++; s = a; } if (ind == 0) { cout << 0; return 0; ...
### Prompt Please formulate a CPP solution to the following problem: Tokitsukaze is playing a game derivated from Japanese mahjong. In this game, she has three tiles in her hand. Each tile she owns is a suited tile, which means it has a suit (manzu, pinzu or souzu) and a number (a digit ranged from 1 to 9). In this p...
#include <bits/stdc++.h> using namespace std; int inf = 100000000; long long INF = 4000000000000000000; long long MOD = 1000000007; int main() { vector<string> s(3); vector<int> a(3); for (int(i) = 0; (i) < (3); (i)++) cin >> s.at(i); sort(s.begin(), s.end()); for (int(i) = 0; (i) < (3); (i)++) a.at(i) = s.at...
### Prompt In Cpp, your task is to solve the following problem: Tokitsukaze is playing a game derivated from Japanese mahjong. In this game, she has three tiles in her hand. Each tile she owns is a suited tile, which means it has a suit (manzu, pinzu or souzu) and a number (a digit ranged from 1 to 9). In this proble...
#include <bits/stdc++.h> using namespace std; long long MOD = 1e9 + 7; long long powmod(long long a, long long l, long long md) { long long res = 1; while (l) { if (l & 1) res = res * a % md; l /= 2; a = a * a % md; } return res; } long long binpow(long long a, long long l) { long long res = 1; ...
### Prompt Please provide a CPP coded solution to the problem described below: Tokitsukaze is playing a game derivated from Japanese mahjong. In this game, she has three tiles in her hand. Each tile she owns is a suited tile, which means it has a suit (manzu, pinzu or souzu) and a number (a digit ranged from 1 to 9)....
#include <bits/stdc++.h> using namespace std; string s[2000]; int main() { cin >> s[0] >> s[1] >> s[2]; sort(s, s + 3); if (s[0] == s[1] && s[1] == s[2]) { cout << 0 << endl; return 0; } if (s[0][1] == s[1][1] && s[1][1] == s[2][1]) { if (s[1][0] - s[0][0] == 1 && s[2][0] - s[1][0] == 1) { c...
### Prompt Create a solution in CPP for the following problem: Tokitsukaze is playing a game derivated from Japanese mahjong. In this game, she has three tiles in her hand. Each tile she owns is a suited tile, which means it has a suit (manzu, pinzu or souzu) and a number (a digit ranged from 1 to 9). In this problem...
#include <bits/stdc++.h> using namespace std; int main() { long long i, l, j, m, n, k; string a, b, c; cin >> a >> b >> c; if (a == b && b == c) { cout << 0; return 0; } if (a[1] == b[1] && b[1] == c[1]) { long long s[3]; s[0] = a[0] - '0'; s[1] = b[0] - '0'; s[2] = c[0] - '0'; s...
### Prompt Please create a solution in Cpp to the following problem: Tokitsukaze is playing a game derivated from Japanese mahjong. In this game, she has three tiles in her hand. Each tile she owns is a suited tile, which means it has a suit (manzu, pinzu or souzu) and a number (a digit ranged from 1 to 9). In this p...
#include <bits/stdc++.h> using namespace std; const int N = 1e5 + 5; const int inf = 1e9 + 1; const int prime_100000000 = 5761460; const double eps = 1e-15; const double EPS = 1e-9; const double PI = acos(-1.0); long long gcd(long long a, long long b) { if (b == 0) return a; return gcd(b, a % b); } long long lcm(lo...
### Prompt Your task is to create a Cpp solution to the following problem: Tokitsukaze is playing a game derivated from Japanese mahjong. In this game, she has three tiles in her hand. Each tile she owns is a suited tile, which means it has a suit (manzu, pinzu or souzu) and a number (a digit ranged from 1 to 9). In ...
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); vector<string> v(3); map<string, int> m; for (int i = 0; i < 3; i++) cin >> v[i]; m[v[0]] = 1; m[v[1]] = 1; m[v[2]] = 1; vector<int> ans; for (int i = 0; i < 3; i++) { int temp...
### Prompt In Cpp, your task is to solve the following problem: Tokitsukaze is playing a game derivated from Japanese mahjong. In this game, she has three tiles in her hand. Each tile she owns is a suited tile, which means it has a suit (manzu, pinzu or souzu) and a number (a digit ranged from 1 to 9). In this proble...
#include <bits/stdc++.h> using namespace std; int main() { string s[3]; cin >> s[0] >> s[1] >> s[2]; if (s[0][0] > s[1][0]) swap(s[0], s[1]); if (s[0][0] > s[2][0]) swap(s[0], s[2]); if (s[1][0] > s[2][0]) swap(s[2], s[1]); if (s[0] == s[1] and s[1] == s[2]) { cout << 0; return 0; } else if (s[0] ...
### Prompt Please formulate a Cpp solution to the following problem: Tokitsukaze is playing a game derivated from Japanese mahjong. In this game, she has three tiles in her hand. Each tile she owns is a suited tile, which means it has a suit (manzu, pinzu or souzu) and a number (a digit ranged from 1 to 9). In this p...
#include <bits/stdc++.h> using namespace std; const int maxn = 10000; int a[3]; int main() { string s; for (int i = 0; i < 3; ++i) { cin >> s; a[i] = (s[0] - '0') + (s[1] - 'a') * 100; } sort(a, a + 3); int t1 = a[1] - a[0], t2 = a[2] - a[1]; if (t1 == t2 && (t1 == 1 || t1 == 0)) puts("0"); el...
### Prompt Create a solution in Cpp for the following problem: Tokitsukaze is playing a game derivated from Japanese mahjong. In this game, she has three tiles in her hand. Each tile she owns is a suited tile, which means it has a suit (manzu, pinzu or souzu) and a number (a digit ranged from 1 to 9). In this problem...
#include <bits/stdc++.h> using namespace std; char s1[20], s2[20], s3[20]; int ques(char a, char b, char c) { if ((a - b == 1 && b - c == 1) || (a - c == 1 && c - b == 1) || (b - c == 1 && c - a == 1) || (b - a == 1 && a - c == 1) || (c - a == 1 && a - b == 1) || (c - b == 1 && b - a == 1)) return 1; ...
### Prompt Develop a solution in Cpp to the problem described below: Tokitsukaze is playing a game derivated from Japanese mahjong. In this game, she has three tiles in her hand. Each tile she owns is a suited tile, which means it has a suit (manzu, pinzu or souzu) and a number (a digit ranged from 1 to 9). In this p...
#include <bits/stdc++.h> using namespace std; int main() { string a, b, c; cin >> a >> b >> c; char x = '1'; char y[3] = {'m', 'p', 's'}; map<string, int> ump; for (int i = 0; i < 3; i++) { string make = ""; make += y[i]; for (int j = 1; j <= 9; j++) { make = (char)(j + '0') + make; ...
### Prompt Please provide a Cpp coded solution to the problem described below: Tokitsukaze is playing a game derivated from Japanese mahjong. In this game, she has three tiles in her hand. Each tile she owns is a suited tile, which means it has a suit (manzu, pinzu or souzu) and a number (a digit ranged from 1 to 9)....
#include <bits/stdc++.h> using namespace std; int main() { int x, d, e, f; string a, b, c; cin >> a >> b >> c; d = a[0] - '0'; e = b[0] - '0'; f = c[0] - '0'; if (a == b && b == c && c == a) { x = 0; } else if ((a == b) || a == c || b == c) { x = 1; } else if ((a[1] == b[1] && abs(d - e) <= 2)...
### Prompt In cpp, your task is to solve the following problem: Tokitsukaze is playing a game derivated from Japanese mahjong. In this game, she has three tiles in her hand. Each tile she owns is a suited tile, which means it has a suit (manzu, pinzu or souzu) and a number (a digit ranged from 1 to 9). In this proble...
#include <bits/stdc++.h> using namespace std; int main() { string s[3]; map<string, long long> map1; map<char, long long> map2; map2['m'] = 0, map2['p'] = 1, map2['s'] = 2; long long a[10][3] = {}; for (int i = 0; i < 3; i++) { cin >> s[i]; map1[s[i]]++; a[s[i][0] - '0'][map2[s[i][1]]] = 1; } ...
### Prompt Generate a cpp solution to the following problem: Tokitsukaze is playing a game derivated from Japanese mahjong. In this game, she has three tiles in her hand. Each tile she owns is a suited tile, which means it has a suit (manzu, pinzu or souzu) and a number (a digit ranged from 1 to 9). In this problem, ...
#include <bits/stdc++.h> using namespace std; void putitin(string ss, vector<int> &s, vector<int> &m, vector<int> &p) { int ele = (int)ss[0] - (int)'0'; if (ss[1] == 's') { s.push_back(ele); } if (ss[1] == 'm') { m.push_back(ele); } if (ss[1] == 'p') { p.push_back(ele); } } void solve() { st...
### Prompt In Cpp, your task is to solve the following problem: Tokitsukaze is playing a game derivated from Japanese mahjong. In this game, she has three tiles in her hand. Each tile she owns is a suited tile, which means it has a suit (manzu, pinzu or souzu) and a number (a digit ranged from 1 to 9). In this proble...
#include <bits/stdc++.h> using namespace std; int main() { vector<string> v; for (int i = 0; i < 3; i++) { string s; cin >> s; v.push_back(s); } vector<string> so; vector<string> po; vector<string> mo; for (int i = 0; i < v.size(); i++) { if (v[i][1] == 's') so.push_back(v[i]); e...
### Prompt Generate a cpp solution to the following problem: Tokitsukaze is playing a game derivated from Japanese mahjong. In this game, she has three tiles in her hand. Each tile she owns is a suited tile, which means it has a suit (manzu, pinzu or souzu) and a number (a digit ranged from 1 to 9). In this problem, ...
#include <bits/stdc++.h> using namespace std; const long long MX5 = 3 * 1e5 + 3; const long long MX6 = 1 * 1e6 + 37; const long long INF = 8e18; const long long MOD = 1e9 + 7; const long long MOD2 = 998244353; long long power(long long a, long long b, long long md) { return (!b ? 1 : (b & 1 ? a * power(a...
### Prompt Develop a solution in Cpp to the problem described below: Tokitsukaze is playing a game derivated from Japanese mahjong. In this game, she has three tiles in her hand. Each tile she owns is a suited tile, which means it has a suit (manzu, pinzu or souzu) and a number (a digit ranged from 1 to 9). In this p...
#include <bits/stdc++.h> using namespace std; int k, ans; int a[4]; string s1, s2, s3; map<string, int> fix; int main() { cin >> s1 >> s2 >> s3; fix[s1]++; fix[s2]++; fix[s3]++; ans = min(min((3 - fix[s2]), (3 - fix[s3])), (3 - fix[s1])); if (s1[1] == s2[1] && s1[1] == s3[1]) { a[1] = s1[0]; a[2] = ...
### Prompt Please create a solution in cpp to the following problem: Tokitsukaze is playing a game derivated from Japanese mahjong. In this game, she has three tiles in her hand. Each tile she owns is a suited tile, which means it has a suit (manzu, pinzu or souzu) and a number (a digit ranged from 1 to 9). In this p...
#include <bits/stdc++.h> const long long INF = (1LL << 60) - 1; using namespace std; long long power(long long x, long long y) { long long res = 1; x = x % 1000000007; while (y > 0) { if (y & 1) res = (res * x) % 1000000007; y = y >> 1; x = (x * x) % 1000000007; } return res; } long long BINARY_SE...
### Prompt Develop a solution in CPP to the problem described below: Tokitsukaze is playing a game derivated from Japanese mahjong. In this game, she has three tiles in her hand. Each tile she owns is a suited tile, which means it has a suit (manzu, pinzu or souzu) and a number (a digit ranged from 1 to 9). In this p...
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); map<string, int> mp; string s1, s2, s3; cin >> s1 >> s2 >> s3; mp[s1]++; mp[s2]++; mp[s3]++; int ans = 3; for (char c = '1'; c <= '9'; c++) { string x; x += c; string a = x + 'm'; ans = min(ans...
### Prompt Please provide a CPP coded solution to the problem described below: Tokitsukaze is playing a game derivated from Japanese mahjong. In this game, she has three tiles in her hand. Each tile she owns is a suited tile, which means it has a suit (manzu, pinzu or souzu) and a number (a digit ranged from 1 to 9)....
#include <bits/stdc++.h> using namespace std; int main() { string s; pair<int, char> arr[3]; cin >> s; arr[0].first = s[0] - '0'; arr[0].second = s[1]; cin >> s; arr[1].first = s[0] - '0'; arr[1].second = s[1]; cin >> s; arr[2].first = s[0] - '0'; arr[2].second = s[1]; if (arr[0].first == arr[1]...
### Prompt Please create a solution in cpp to the following problem: Tokitsukaze is playing a game derivated from Japanese mahjong. In this game, she has three tiles in her hand. Each tile she owns is a suited tile, which means it has a suit (manzu, pinzu or souzu) and a number (a digit ranged from 1 to 9). In this p...
#include <bits/stdc++.h> using namespace std; long long modInverse(long long a, long long m); long long gcd(long long a, long long b); long long power(long long x, unsigned long long y, unsigned long long m); long long logint(long long x, long long y); long long gcd(long long a, long long b) { if (a == 0) return b; ...
### Prompt Develop a solution in Cpp to the problem described below: Tokitsukaze is playing a game derivated from Japanese mahjong. In this game, she has three tiles in her hand. Each tile she owns is a suited tile, which means it has a suit (manzu, pinzu or souzu) and a number (a digit ranged from 1 to 9). In this p...
#include <bits/stdc++.h> using namespace std; template <class T> inline bool read(T &x) { int c = getchar(); int sgn = 1; while (~c && c<'0' | c> '9') { if (c == '-') sgn = -1; c = getchar(); } for (x = 0; ~c && '0' <= c && c <= '9'; c = getchar()) x = x * 10 + c - '0'; x *= sgn; return ~c; } cons...
### Prompt Your task is to create a CPP solution to the following problem: Tokitsukaze is playing a game derivated from Japanese mahjong. In this game, she has three tiles in her hand. Each tile she owns is a suited tile, which means it has a suit (manzu, pinzu or souzu) and a number (a digit ranged from 1 to 9). In ...
#include <bits/stdc++.h> using namespace std; int a[3], i; int main() { string s; for (i = 0; i < 3; i++) { cin >> s; a[i] = (s[0] - '0') + (s[1] - 'a') * 100; } sort(a, a + 3); int t1 = a[1] - a[0]; int t2 = a[2] - a[1]; if (t1 == t2 && (t1 == 0 || t1 == 1)) cout << "0"; else if (t1 == 1 ||...
### Prompt Please provide a cpp coded solution to the problem described below: Tokitsukaze is playing a game derivated from Japanese mahjong. In this game, she has three tiles in her hand. Each tile she owns is a suited tile, which means it has a suit (manzu, pinzu or souzu) and a number (a digit ranged from 1 to 9)....
#include <bits/stdc++.h> using namespace std; long long int arr[10] = {0}; long long int brr[10] = {0}; long long int crr[10] = {0}; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); string s1, s2, s3; cin >> s1 >> s2 >> s3; if (s1[1] == 'm') arr[int(s1[0]) - 48]++; else if...
### Prompt Please provide a CPP coded solution to the problem described below: Tokitsukaze is playing a game derivated from Japanese mahjong. In this game, she has three tiles in her hand. Each tile she owns is a suited tile, which means it has a suit (manzu, pinzu or souzu) and a number (a digit ranged from 1 to 9)....
#include <bits/stdc++.h> using namespace std; template <typename T> void pr(vector<T> &v) { for (int i = 0; i < (int)(v).size(); i++) cout << v[i] << " "; cout << '\n'; ; } template <typename T> void pr(vector<vector<T>> &v) { for (int i = 0; i < (int)(v).size(); i++) { pr(v[i]); } } template <typename T>...
### Prompt Please formulate a Cpp solution to the following problem: Tokitsukaze is playing a game derivated from Japanese mahjong. In this game, she has three tiles in her hand. Each tile she owns is a suited tile, which means it has a suit (manzu, pinzu or souzu) and a number (a digit ranged from 1 to 9). In this p...
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); string s[3]; cin >> s[0] >> s[1] >> s[2]; int ans = 2; if (s[0] == s[1] && s[1] == s[2]) return cout << 0, 0; if (s[0] == s[1] || s[1] == s[2] || s[0] == s[2]) return cout << 1, 0;...
### Prompt Please create a solution in CPP to the following problem: Tokitsukaze is playing a game derivated from Japanese mahjong. In this game, she has three tiles in her hand. Each tile she owns is a suited tile, which means it has a suit (manzu, pinzu or souzu) and a number (a digit ranged from 1 to 9). In this p...
#include <bits/stdc++.h> using namespace std; void solve() { string a[3]; cin >> a[0] >> a[1] >> a[2]; map<char, vector<long long> > m; for (auto i : a) m[i[1]].push_back(i[0]); int ok = 2; for (auto i : m) { vector<long long> r = i.second; sort(r.begin(), r.end()); if (r.size() == 1) { co...
### Prompt Please formulate a CPP solution to the following problem: Tokitsukaze is playing a game derivated from Japanese mahjong. In this game, she has three tiles in her hand. Each tile she owns is a suited tile, which means it has a suit (manzu, pinzu or souzu) and a number (a digit ranged from 1 to 9). In this p...
#include <bits/stdc++.h> using namespace std; const bool online_judge = true; const long long inf = 1LL << 60; long long toInt(string s) { long long res; stringstream ss; ss << s; ss >> res; return res; } string toString(long long n) { stringstream ss; ss << n; return ss.str(); } void run() { long lon...
### Prompt Your task is to create a Cpp solution to the following problem: A team quiz game called "What? Where? When?" is very popular in Berland. The game is centered on two teams competing. They are the team of six Experts versus the team of the Audience. A person from the audience asks a question and the experts ...
#include <bits/stdc++.h> using namespace std; const int oo = 0x3f3f3f3f; const double eps = 1e-9; vector<int> lucky; void generate(long long n) { if (n > 1000000000LL) return; else { generate(n * 10 + 4); generate(n * 10 + 7); if (n > 0) lucky.push_back(n); } } void unrank(vector<int> &perm, int n...
### Prompt Please provide a CPP coded solution to the problem described below: Petya loves lucky numbers. Everybody knows that lucky numbers are positive integers whose decimal representation contains only the lucky digits 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not. One day Petya dream...
#include <bits/stdc++.h> using namespace std; int N, K, A[14 + 1]; int u[14 + 1]; long long fact[2 * 14 + 1]; vector<long long> all_lucky; void gen_lucky(int x, int len) { if (len == 9) { all_lucky.push_back(x); return; } if (len >= 1) { all_lucky.push_back(x); } gen_lucky(x * 10 + 4, len + 1); ...
### Prompt In cpp, your task is to solve the following problem: Petya loves lucky numbers. Everybody knows that lucky numbers are positive integers whose decimal representation contains only the lucky digits 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not. One day Petya dreamt of a lexicogr...
#include <bits/stdc++.h> using namespace std; int n, k, N; int fact[13], p[13], a[13]; int first(int n) { queue<long long> q; q.push(0); int res = -1; while (q.front() <= 1LL * n) { long long cur = q.front(); res++; q.pop(); q.push(10 * cur + 4); q.push(10 * cur + 7); } return res; } int...
### Prompt Please provide a cpp coded solution to the problem described below: Petya loves lucky numbers. Everybody knows that lucky numbers are positive integers whose decimal representation contains only the lucky digits 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not. One day Petya dream...
#include <bits/stdc++.h> using namespace std; const long double PI = 3.14159265358979323; const long long int linf = 1000111000111000111LL; const long long int inf = 1011111111; const long long int N = 100005; vector<long long int> v1[10], v2; set<long long int> st2; int32_t main() { ios::sync_with_stdio(false); ci...
### Prompt Your task is to create a CPP solution to the following problem: Petya loves lucky numbers. Everybody knows that lucky numbers are positive integers whose decimal representation contains only the lucky digits 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not. One day Petya dreamt of...
#include <bits/stdc++.h> using namespace std; int lucky[3000], cnt; void dfs(long long now) { if (now > 1000000000) return; if (now) lucky[cnt++] = (int)now; dfs(now * 10 + 4); dfs(now * 10 + 7); } long long fact[20]; int n, m, num[20]; bool flag[20]; int find(int k) { for (int i = 1;; i++) { if (!flag[i]...
### Prompt In CPP, your task is to solve the following problem: Petya loves lucky numbers. Everybody knows that lucky numbers are positive integers whose decimal representation contains only the lucky digits 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not. One day Petya dreamt of a lexicogr...
#include <bits/stdc++.h> using namespace std; long long fact[15]; vector<long long> luckies; long long next(int x) { return *lower_bound(luckies.begin(), luckies.end(), x); } long long to_lucky(int x, int l) { long long res = 0; for (int i = 0; i < (l); ++i) if (x & (1 << i)) res = res * 10 + 4; els...
### Prompt Generate a cpp solution to the following problem: Petya loves lucky numbers. Everybody knows that lucky numbers are positive integers whose decimal representation contains only the lucky digits 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not. One day Petya dreamt of a lexicograph...
#include <bits/stdc++.h> using namespace std; int main() { int n, k, count = 0, ch = 0, c = 0; int mas[15] = {1, 2, 6, 24, 120, 720, 5040, 40320, 362880, 3628800, 39916800, 479001600}; int isp[1000] = {}, dl = 0; long long int mas2[1030] = { 4, 7, 44,...
### Prompt In Cpp, your task is to solve the following problem: Petya loves lucky numbers. Everybody knows that lucky numbers are positive integers whose decimal representation contains only the lucky digits 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not. One day Petya dreamt of a lexicogr...
#include <bits/stdc++.h> using namespace std; long long int fact[14]; long long int perm[13]; set<long long int> lucky; void genfact() { fact[0] = 1; for (long long int i = 1; i < 14; ++i) fact[i] = i * fact[i - 1]; } void genperm(long long int n, long long int k) { list<long long int> a; n = min(n, 13ll); fo...
### Prompt Construct a cpp code solution to the problem outlined: Petya loves lucky numbers. Everybody knows that lucky numbers are positive integers whose decimal representation contains only the lucky digits 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not. One day Petya dreamt of a lexico...
#include <bits/stdc++.h> using namespace std; long long t[1500], n, k; long long fac[20], base, tmp, rec[20], Ans; bool used[20]; void init(long long x) { if (x > 1e8) return; t[++t[0]] = x * 10 + 4; init(x * 10 + 4); t[++t[0]] = x * 10 + 7; init(x * 10 + 7); } bool check(long long x) { for (long long i = 1...
### Prompt Please provide a cpp coded solution to the problem described below: Petya loves lucky numbers. Everybody knows that lucky numbers are positive integers whose decimal representation contains only the lucky digits 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not. One day Petya dream...
#include <bits/stdc++.h> using namespace std; template <class T> T abs(T x) { return x > 0 ? x : (-x); } template <class T> T sqr(T x) { return x * x; } vector<long long> gen() { vector<long long> res; for (int len = 1; len <= 11; ++len) for (int mask = 0; mask < (1 << len); ++mask) { long long cur = ...
### Prompt Please provide a Cpp coded solution to the problem described below: Petya loves lucky numbers. Everybody knows that lucky numbers are positive integers whose decimal representation contains only the lucky digits 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not. One day Petya dream...
#include <bits/stdc++.h> using namespace std; long long fac[15]; vector<int> getKthPerm(vector<int> arr, long long k) { if (k == 1) return arr; int n = arr.size(); for (int i = 1; i <= n; i++) { if (k <= fac[n - 1] * i) { vector<int> brr; for (int j = 0; j < n; j++) { if (j + 1 == i) conti...
### Prompt Please create a solution in Cpp to the following problem: Petya loves lucky numbers. Everybody knows that lucky numbers are positive integers whose decimal representation contains only the lucky digits 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not. One day Petya dreamt of a lex...
#include <bits/stdc++.h> using namespace std; int n, kk, ans, a[15]; long long ci[15]; bool ok; bool check(int i) { while (i) { if ((i % 10 != 4) && (i % 10 != 7)) return false; i = i / 10; } return true; } int cal(int r) { long long now = 0; int ans = 0, a[11] = {0}; while (now < r) { int j = 1...
### Prompt Your task is to create a CPP solution to the following problem: Petya loves lucky numbers. Everybody knows that lucky numbers are positive integers whose decimal representation contains only the lucky digits 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not. One day Petya dreamt of...
#include <bits/stdc++.h> using namespace std; const int MAX = 20; int n; long long int k, fat[MAX], tmp[MAX]; vector<long long int> lk; int lucky(long long int x) { while (x > 0LL) { long long int a = (x % 10LL); if (a != 4LL && a != 7LL) return 0; x /= 10LL; } return 1; } void lk_gen(int pos) { if ...
### Prompt Your task is to create a cpp solution to the following problem: Petya loves lucky numbers. Everybody knows that lucky numbers are positive integers whose decimal representation contains only the lucky digits 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not. One day Petya dreamt of...
#include <bits/stdc++.h> using namespace std; const int maxn = 1e5 + 50; const int inf = 0x3f3f3f3f; const int MOD = 1e9 + 7; int n, k; int fac[15] = {1, 1, 2, 6, 24, 120, 720, 5040, 40320, 362880, 3628800, 39916800, 479001600}; int Hash[20], p[20]; vector<long long> V; long ...
### Prompt Please create a solution in cpp to the following problem: Petya loves lucky numbers. Everybody knows that lucky numbers are positive integers whose decimal representation contains only the lucky digits 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not. One day Petya dreamt of a lex...
#include <bits/stdc++.h> using namespace std; vector<long long> v; void CalcLucky(long long num, long long limit) { long long temp4; temp4 = num * 10 + 4; long long temp7; temp7 = num * 10 + 7; v.push_back(temp4); v.push_back(temp7); if (temp4 <= limit) CalcLucky(temp4, limit); if (temp7 <= limit) CalcL...
### Prompt Your challenge is to write a CPP solution to the following problem: Petya loves lucky numbers. Everybody knows that lucky numbers are positive integers whose decimal representation contains only the lucky digits 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not. One day Petya dream...
#include <bits/stdc++.h> using namespace std; int n, m, p; long long fac[30]; long long Pow[30]; long long who[30]; int v[30]; set<long long> Set; set<int> Hash; void dfs(int dep, long long now) { if (dep < 0) { Set.insert(now); return; } dfs(dep - 1, now + Pow[dep] * 4); dfs(dep - 1, now + Pow[dep] * 7...
### Prompt Construct a CPP code solution to the problem outlined: Petya loves lucky numbers. Everybody knows that lucky numbers are positive integers whose decimal representation contains only the lucky digits 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not. One day Petya dreamt of a lexico...
#include <bits/stdc++.h> using namespace std; long long bigmod(long long b, long long p) { if (p == 0) return 1; long long my = bigmod(b, p / 2); my *= my; my %= 1000000007; if (p & 1) my *= b, my %= 1000000007; return my; } int setb(int n, int pos) { return n = n | (1 << pos); } int resb(int n, int pos) { ...
### Prompt In CPP, your task is to solve the following problem: Petya loves lucky numbers. Everybody knows that lucky numbers are positive integers whose decimal representation contains only the lucky digits 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not. One day Petya dreamt of a lexicogr...
#include <bits/stdc++.h> using namespace std; const int N = 4e3 + 5; const long long mod = 1e9 + 7; long long power(long long a, long long b, long long c) { long long ret = 1; while (b > 0) { if (b % 2 == 1) ret = (ret * a) % c; b /= 2; a = (a * a) % c; } return ret; } int fact[13]; vector<int> valu...
### Prompt Create a solution in CPP for the following problem: Petya loves lucky numbers. Everybody knows that lucky numbers are positive integers whose decimal representation contains only the lucky digits 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not. One day Petya dreamt of a lexicogra...
#include <bits/stdc++.h> using namespace std; const int N = 2005; long long is_luck[N]; long long permu[20]; int get_luck(); int get_permu(long long, long long, long long, long long); bool judge_luck(long long); int main() { long long n, m, res = 0; cin >> n >> m; int cnt = 0; cnt = get_luck(); long long rema...
### Prompt In Cpp, your task is to solve the following problem: Petya loves lucky numbers. Everybody knows that lucky numbers are positive integers whose decimal representation contains only the lucky digits 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not. One day Petya dreamt of a lexicogr...
#include <bits/stdc++.h> using namespace std; long long n, k, num = 1; long long kol = 1, RES = 0; vector<int> mas, other; vector<int> all; int main() { cin >> n >> k; long long num = 4; while (num <= n) { all.push_back(num); string s = ""; int nn = num; while (nn) { if (nn % 10 == 4) ...
### Prompt Please provide a Cpp coded solution to the problem described below: Petya loves lucky numbers. Everybody knows that lucky numbers are positive integers whose decimal representation contains only the lucky digits 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not. One day Petya dream...
#include <bits/stdc++.h> using namespace std; const double pi = acos(-1.0); vector<long long> a; int main() { for (int _b = (10), len = (1); len <= _b; len++) for (int mask = 0, _n = (1 << len); mask < _n; mask++) { long long x = 0; for (int i = (len)-1; i >= 0; i--) x = x * 10 + ((mask & (1 <...
### Prompt Develop a solution in Cpp to the problem described below: Petya loves lucky numbers. Everybody knows that lucky numbers are positive integers whose decimal representation contains only the lucky digits 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not. One day Petya dreamt of a lex...
#include <bits/stdc++.h> using namespace std; struct FenwickT { long long t[2100]; void add(long long i, long long val) { for (; i < 2100; i += ((i) & (-i))) t[i] += val; } long long query(long long i) { long long sol = 0; for (; i > 0; i -= ((i) & (-i))) sol += t[i]; return sol; } }; struct F...
### Prompt Please provide a Cpp coded solution to the problem described below: Petya loves lucky numbers. Everybody knows that lucky numbers are positive integers whose decimal representation contains only the lucky digits 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not. One day Petya dream...
#include <bits/stdc++.h> #pragma GCC optimize("Ofast") #pragma GCC optimize("unroll-loops") #pragma GCC target("sse,sse2,ssse3,sse3,sse4,popcnt,avx,mmx,abm,tune=native") using namespace std; long long n, k, cnt, i, f[20] = {1, 1}, j; vector<long long> vec, rem; set<long long> luck; void gen(long long n, long long tot) ...
### Prompt Your task is to create a CPP solution to the following problem: Petya loves lucky numbers. Everybody knows that lucky numbers are positive integers whose decimal representation contains only the lucky digits 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not. One day Petya dreamt of...
#include <bits/stdc++.h> using namespace std; int n, k; int ans = 0; long long fac[30]; map<int, bool> M; bool checklucky(long long x) { for (; x; x /= 10) if (x % 10 != 4 && x % 10 != 7) return 0; return 1; } int check(int cur) { if (cur < max(n - 20 + 1, 1)) return checklucky(cur); int tmp = k; M.clear(...
### Prompt Please provide a Cpp coded solution to the problem described below: Petya loves lucky numbers. Everybody knows that lucky numbers are positive integers whose decimal representation contains only the lucky digits 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not. One day Petya dream...
#include <bits/stdc++.h> using namespace std; long long fact[22] = {1}; vector<int> solve(int n, long long k) { int i, j, r; vector<int> ans; set<int> st; for (i = n - 1; i >= 0; i--) { int t = (k - 1) / fact[i] + 1; k -= (t - 1) * fact[i]; r = 0; for (j = 1; j <= n; j++) if (st.find(j) ==...
### Prompt Please create a solution in Cpp to the following problem: Petya loves lucky numbers. Everybody knows that lucky numbers are positive integers whose decimal representation contains only the lucky digits 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not. One day Petya dreamt of a lex...
#include <bits/stdc++.h> using namespace std; const long long maxn = 14; long long f[maxn]; long long n, k, ANS; vector<long long> ans; vector<long long> v, p; bool is(long long a) { while (a) { if (a % 10 != 4 && a % 10 != 7) { return false; } a /= 10; } return true; } int32_t main() { cin >>...
### Prompt Develop a solution in cpp to the problem described below: Petya loves lucky numbers. Everybody knows that lucky numbers are positive integers whose decimal representation contains only the lucky digits 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not. One day Petya dreamt of a lex...
#include <bits/stdc++.h> using namespace std; const long long SQ = 100000; const long long MAXN = SQ * SQ; long long fact[100]; void init() { fact[0] = 1; for (long long i = 1; fact[i - 1] < MAXN; i++) fact[i] = fact[i - 1] * i; } long long p[100]; void k_perm(long long n, long long k) { k--; for (long long i =...
### Prompt Develop a solution in cpp to the problem described below: Petya loves lucky numbers. Everybody knows that lucky numbers are positive integers whose decimal representation contains only the lucky digits 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not. One day Petya dreamt of a lex...
#include <bits/stdc++.h> using namespace std; vector<long long> sil(14); vector<long long> lucky; set<long long> luckyS; void gen() { for (int i = 1; i <= 10; ++i) { for (int j = 0; j < (1LL << i); ++j) { long long x = 0; for (int k = 0; k < i; ++k) { if ((j & (1LL << k)) > 0) x = x ...
### Prompt Create a solution in Cpp for the following problem: Petya loves lucky numbers. Everybody knows that lucky numbers are positive integers whose decimal representation contains only the lucky digits 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not. One day Petya dreamt of a lexicogra...
#include <bits/stdc++.h> using namespace std; vector<int> lucky_nums; vector<int> datos; vector<long long> factorial; set<long long> numeros; int idx_cambio; void obten_lucky(int n) { numeros.insert(0); for (int i = 0; i < 10; ++i) { set<long long> temp = numeros; for (const auto& act : temp) { long l...
### Prompt Your task is to create a CPP solution to the following problem: Petya loves lucky numbers. Everybody knows that lucky numbers are positive integers whose decimal representation contains only the lucky digits 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not. One day Petya dreamt of...
#include <bits/stdc++.h> using namespace std; const long long inf = 1000ll * 1000 * 1000; const int size = 100; long long smb, n, k; int ans; bool used[size]; int perm[size]; void genthemall(long long num) { if (num > inf) return; if (num <= n - 15 && num >= 1) ans++; genthemall(num * 10 + 4); genthemall(num * ...
### Prompt Please provide a cpp coded solution to the problem described below: Petya loves lucky numbers. Everybody knows that lucky numbers are positive integers whose decimal representation contains only the lucky digits 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not. One day Petya dream...
#include <bits/stdc++.h> using namespace std; template <class T> void pv(ostream &out, T a, T b) { for (T i = a; i != b; ++i) { out << *i << " "; } out << endl; } template <class T> void pvp(ostream &out, T a, T b) { for (T i = a; i != b; ++i) { out << "(" << i->first << ", " << i->second << ") "; } ...
### Prompt Your task is to create a cpp solution to the following problem: Petya loves lucky numbers. Everybody knows that lucky numbers are positive integers whose decimal representation contains only the lucky digits 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not. One day Petya dreamt of...
#include <bits/stdc++.h> const int MAX_FACT = 14; int N, K; long long fact[MAX_FACT]; int countLucky(long long val, int n) { int sol = 0; if (val <= n) { if (val > 0) ++sol; sol += countLucky(val * 10 + 4, n); sol += countLucky(val * 10 + 7, n); } return sol; } bool isLucky(int val) { do { int...
### Prompt Please create a solution in CPP to the following problem: Petya loves lucky numbers. Everybody knows that lucky numbers are positive integers whose decimal representation contains only the lucky digits 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not. One day Petya dreamt of a lex...
#include <bits/stdc++.h> using namespace std; long long fact[20]; int permutation[20]; vector<int> canUse; int luckySmaller(int n) { queue<long long> q; while (!q.empty()) q.pop(); q.push(0); int ans = 0; while (!q.empty()) { long long f = q.front(); q.pop(); long long a[2] = {f * 10 + 4, f * 10 +...
### Prompt Develop a solution in CPP to the problem described below: Petya loves lucky numbers. Everybody knows that lucky numbers are positive integers whose decimal representation contains only the lucky digits 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not. One day Petya dreamt of a lex...
#include <bits/stdc++.h> using namespace std; const long long N = 14, LIM = 5e9; vector<long long> vec, per; long long fac[N]; set<long long> s; long long n, k, ind, ans; void bt(long long num) { if (num > LIM) return; vec.push_back(num); bt(num * 10 + 4); bt(num * 10 + 7); } bool f(long long n) { while (n > ...
### Prompt Your task is to create a Cpp solution to the following problem: Petya loves lucky numbers. Everybody knows that lucky numbers are positive integers whose decimal representation contains only the lucky digits 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not. One day Petya dreamt of...
#include <bits/stdc++.h> using namespace std; const double dinf = 1e200; void ext(int c) {} int ar[30]; bool was[30]; int n; int k; long long fact[30]; vector<long long> nums; void gen(long long v) { if (v > 1000000000) return; nums.push_back(v); gen(v * 10 + 4); gen(v * 10 + 7); } int main() { fact[0] = 1; ...
### Prompt Your task is to create a Cpp solution to the following problem: Petya loves lucky numbers. Everybody knows that lucky numbers are positive integers whose decimal representation contains only the lucky digits 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not. One day Petya dreamt of...
#include <bits/stdc++.h> using namespace std; const int mod = 1e9 + 7; const long long inf = 5e18; vector<string> num_string({"4", "7"}); map<long long, int> mp; vector<long long> fact; bool check(long long mid, long long n, long long k) { if (n - mid >= fact.size()) { return false; } else { return fact[n -...
### Prompt In Cpp, your task is to solve the following problem: Petya loves lucky numbers. Everybody knows that lucky numbers are positive integers whose decimal representation contains only the lucky digits 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not. One day Petya dreamt of a lexicogr...
#include <bits/stdc++.h> using namespace std; long long fact[20], n, k; bool isGood(long long x) { while (x) { if (x % 10 != 4 && x % 10 != 7) return 0; x /= 10; } return 1; } vector<long long> getkth(long long k, long long n, long long x) { vector<long long> v(n + 1, 0); for (long long i = 1; i <= n;...
### Prompt Generate a CPP solution to the following problem: Petya loves lucky numbers. Everybody knows that lucky numbers are positive integers whose decimal representation contains only the lucky digits 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not. One day Petya dreamt of a lexicograph...
#include <bits/stdc++.h> int lucky(int x) { while (x) { if (x % 10 != 4 && x % 10 != 7) break; x /= 10; } if (x == 0) { return 1; } else { return 0; } } int fact(int n) { int x = 1, i; for (i = 1; i <= n; i++) x *= i; return x; } int main() { int n, k, p = 0, q = 2, r = 2, sum = 0, i, ...
### Prompt Please create a solution in Cpp to the following problem: Petya loves lucky numbers. Everybody knows that lucky numbers are positive integers whose decimal representation contains only the lucky digits 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not. One day Petya dreamt of a lex...
#include <bits/stdc++.h> using namespace std; long long N, K; long long f[15]; int count(long long x, long long k) { if (x > k) return 0; return 1 + count(10 * x + 4, k) + count(10 * x + 7, k); } bool check(long long x) { if (x == 0) return false; while (x) { long long r = x % 10; if (r != 4 && r != 7) ...
### Prompt Please create a solution in Cpp to the following problem: Petya loves lucky numbers. Everybody knows that lucky numbers are positive integers whose decimal representation contains only the lucky digits 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not. One day Petya dreamt of a lex...
#include <bits/stdc++.h> using namespace std; template <class T> string i2s(T x) { ostringstream o; o << x; return o.str(); } int s2i(string x) { int r = 0; istringstream sin(x); sin >> r; return r; } long long fact[14]; int N, K; bool isLucky(int x) { string s = i2s(x); for (int i = 0; i < s.size(); ...
### Prompt Develop a solution in cpp to the problem described below: Petya loves lucky numbers. Everybody knows that lucky numbers are positive integers whose decimal representation contains only the lucky digits 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not. One day Petya dreamt of a lex...
#include <bits/stdc++.h> using namespace std; double PI = 3.141592653589793; const int mx = 13; long long cnt[mx + 1]; int val[mx + 1]; bool lck(int n) { bool out = 1; while (n != 0) { if (n % 10 != 4 && n % 10 != 7) out = 0; n /= 10; } return out; } const int bmx = 9; vector<int> proc; void init() { ...
### Prompt Generate a cpp solution to the following problem: Petya loves lucky numbers. Everybody knows that lucky numbers are positive integers whose decimal representation contains only the lucky digits 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not. One day Petya dreamt of a lexicograph...
#include <bits/stdc++.h> using namespace std; int m = 0; int nn; long long n, k; long long fact[20]; long long a[20000]; int b[20]; bool check[20]; int per[20]; bool found; int res; void doit(int, int); void gen(int); bool isLucky(int); int main() { cin >> n >> k; fact[0] = fact[1] = 1; for (int i = 2; i <= 13; i...
### Prompt Generate a CPP solution to the following problem: Petya loves lucky numbers. Everybody knows that lucky numbers are positive integers whose decimal representation contains only the lucky digits 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not. One day Petya dreamt of a lexicograph...
#include <bits/stdc++.h> using namespace std; const int INF = (int)1E9 + 5; const long long LINF = (long long)4E18 + 5; const long double PI = acos(-1.0); const long double E = 2.718281828459045L; template <typename T> T gcd(T a, T b) { return (b == 0) ? abs(a) : gcd(b, a % b); } template <typename T> inline T lcm(T ...
### Prompt Your task is to create a Cpp solution to the following problem: Petya loves lucky numbers. Everybody knows that lucky numbers are positive integers whose decimal representation contains only the lucky digits 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not. One day Petya dreamt of...
#include <bits/stdc++.h> using namespace std; const int N = 1e5 + 10, mod = 1e9 + 7; vector<int> v; long long fac[N]; int n, k; bool check(int x) { while (x) { int y = x % 10; x /= 10; if (y != 4 && y != 7) return 0; } return 1; } vector<int> get(int cnt, int num) { set<int> s; vector<int> ret; ...
### Prompt Please provide a Cpp coded solution to the problem described below: Petya loves lucky numbers. Everybody knows that lucky numbers are positive integers whose decimal representation contains only the lucky digits 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not. One day Petya dream...
#include <bits/stdc++.h> using namespace std; long long lu[] = { 4, 7, 44, 47, 74, 77, 444, 447, 474, 477, 744, 747, 774, 777, 4444, 4447, 4474, 4477, 4744, 4747, 4774, 4777, 7444, 744...
### Prompt Create a solution in cpp for the following problem: Petya loves lucky numbers. Everybody knows that lucky numbers are positive integers whose decimal representation contains only the lucky digits 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not. One day Petya dreamt of a lexicogra...
#include <bits/stdc++.h> using namespace std; int n, k; int mx[15]; int cal(int ix) { if (ix == 0) return 0; long long temp = 1, i; for (i = 1;; i++) { temp *= i; if (temp >= ix) break; } int p = i - 1; if (temp == ix) { reverse(mx, mx + p + 1); return 0; } int t = temp / i; t = (ix - ...
### Prompt Develop a solution in CPP to the problem described below: Petya loves lucky numbers. Everybody knows that lucky numbers are positive integers whose decimal representation contains only the lucky digits 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not. One day Petya dreamt of a lex...
#include <bits/stdc++.h> using namespace std; long long mod = 1000000007; vector<int> gen_perm(int n, int k) { long long fact[20]; fact[0] = 1; for (long long i = 1; i < 20; i++) { fact[i] = i * fact[i - 1]; fact[i] %= mod; } bool placed[20] = {0}; vector<int> v; for (int p = 1; p <= n; p++) { ...
### Prompt Generate a cpp solution to the following problem: Petya loves lucky numbers. Everybody knows that lucky numbers are positive integers whose decimal representation contains only the lucky digits 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not. One day Petya dreamt of a lexicograph...
#include <bits/stdc++.h> using namespace std; const long long dx[] = {4LL, 7LL}; vector<long long> lucky; vector<long long> P; int main() { { queue<int> Q; Q.push(0); while (!Q.empty()) { long long x = Q.front(); for (int i = 0; i < 2; i++) { long long x1 = x * 10LL + dx[i]; lu...
### Prompt Create a solution in Cpp for the following problem: Petya loves lucky numbers. Everybody knows that lucky numbers are positive integers whose decimal representation contains only the lucky digits 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not. One day Petya dreamt of a lexicogra...
#include <bits/stdc++.h> using namespace std; template <class _T> inline _T sqr(const _T &first) { return first * first; } template <class _T> inline string tostr(const _T &a) { ostringstream os(""); os << a; return os.str(); } const long double PI = 3.1415926535897932384626433832795L; const long double EPS = 1...
### Prompt In CPP, your task is to solve the following problem: Petya loves lucky numbers. Everybody knows that lucky numbers are positive integers whose decimal representation contains only the lucky digits 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not. One day Petya dreamt of a lexicogr...
#include <bits/stdc++.h> const int N = 100100; using namespace std; long long n, k, cnt; bool used[1000]; void build(long long x, long long mx) { if (x > mx) return; if (x) cnt++; build(x * 10 + 4, mx); build(x * 10 + 7, mx); } bool check(long long x) { while (x) { if (x % 10 != 4 && x % 10 != 7) return f...
### Prompt Your task is to create a CPP solution to the following problem: Petya loves lucky numbers. Everybody knows that lucky numbers are positive integers whose decimal representation contains only the lucky digits 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not. One day Petya dreamt of...
#include <bits/stdc++.h> using namespace std; const long long mod = 1e9 + 7, INF = 1e18; long long n, k; long long tot(long long count) { if (count > n) return 0; return 1 + tot(count * 10 + 7) + tot(count * 10 + 4); } long long findit(long long a) { while (a) { if (a % 10 != 4 && a % 10 != 7) return 0; a...
### Prompt Develop a solution in cpp to the problem described below: Petya loves lucky numbers. Everybody knows that lucky numbers are positive integers whose decimal representation contains only the lucky digits 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not. One day Petya dreamt of a lex...
#include <bits/stdc++.h> using namespace std; long long gcd(long long a, long long b) { return b ? gcd(b, a % b) : a; } long long lb = 10000000000; void vrikodara(long long n = 12) { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); cout << setprecision(n) << fixed; } long long n, k; set<long long> s; vect...
### Prompt Please formulate a CPP solution to the following problem: Petya loves lucky numbers. Everybody knows that lucky numbers are positive integers whose decimal representation contains only the lucky digits 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not. One day Petya dreamt of a lex...
#include <bits/stdc++.h> using namespace std; long long factorial[13], res = 0; bool OK(int n) { stringstream ss; string s; ss << n; ss >> s; ss.clear(); for (int i = 0; i < s.size(); i++) { if (s[i] != '4' && s[i] != '7') return false; } return true; } int main() { int n, k; cin >> n >> k; ve...
### Prompt Construct a Cpp code solution to the problem outlined: Petya loves lucky numbers. Everybody knows that lucky numbers are positive integers whose decimal representation contains only the lucky digits 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not. One day Petya dreamt of a lexico...
#include <bits/stdc++.h> using namespace std; set<long long> S; void go(const long long &x, const int &M, const long long &U) { if (x > U) return; if (x > M) S.insert(x); go(10 * x + 4, M, U), go(10 * x + 7, M, U); } bool ok(long long x) { for (; x; x /= 10) { int a = x % 10; if (a != 4 && a != 7) retur...
### Prompt Your task is to create a Cpp solution to the following problem: Petya loves lucky numbers. Everybody knows that lucky numbers are positive integers whose decimal representation contains only the lucky digits 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not. One day Petya dreamt of...
#include <bits/stdc++.h> using namespace std; const double pi = acos(-1.0); const double eps = 1E-7; const int inf = int(1e9) + 7; int a[200000]; int tot; void dfs(long long x, int th) { if (x > 0) a[tot++] = x; if (th > 0) { dfs(x * 10 + 4, th - 1); dfs(x * 10 + 7, th - 1); } } long long jie(int x) { l...
### Prompt Construct a Cpp code solution to the problem outlined: Petya loves lucky numbers. Everybody knows that lucky numbers are positive integers whose decimal representation contains only the lucky digits 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not. One day Petya dreamt of a lexico...
#include <bits/stdc++.h> using namespace std; long long getLuckyNumberNoGreater(long long mx) { vector<long long> nums; if (mx >= 4) nums.push_back(4); if (mx >= 7) nums.push_back(7); for (int i = 0; i < nums.size() - 1 + 1; ++i) { auto x = nums[i]; if (x * 10 + 4 <= mx) nums.push_back(x * 10 + 4); ...
### Prompt Please formulate a Cpp solution to the following problem: Petya loves lucky numbers. Everybody knows that lucky numbers are positive integers whose decimal representation contains only the lucky digits 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not. One day Petya dreamt of a lex...
#include <bits/stdc++.h> using namespace std; int logfac(long long k) { long long fac = 1; int ans = 0; while (fac < k) { ans++; fac *= ans; } return ans; } int a[100]; long long fact[30]; bool mark[100]; void make_permutation(int now, int n, int k) { if (now == n) return; int i; for (i = 1; i <...
### Prompt Please formulate a cpp solution to the following problem: Petya loves lucky numbers. Everybody knows that lucky numbers are positive integers whose decimal representation contains only the lucky digits 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not. One day Petya dreamt of a lex...