Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //849 не проходит по времени
- #include <cstdio>
- #include <algorithm>
- #include <cstdlib>
- #include <vector>
- using namespace std;
- typedef unsigned long long int li;
- typedef union {
- unsigned long long int x;
- unsigned int y:4;
- } uni;
- bool if_interes(li n, int t) {
- vector<int> a(16, 0);
- bool ret = true;
- uni b;
- while (n != 0) {
- b.x = n;
- ++ a[b.y];
- n >>= 4;
- }
- if (*max_element(a.begin(), a.end()) > t)
- ret = false;
- return ret;
- }
- int main(void) {
- FILE* fin = fopen("input.txt", "r");
- FILE* fout = fopen("output.txt", "w");
- int k, t;
- fscanf(fin, "%d%d", &k, &t);
- fclose(fin);
- li n = 1;
- for (int i = 0; i < k; ++ n) {
- if (if_interes(n, t))
- ++ i;
- }
- fprintf(fout, "%llx\n", n - 1);
- fclose(fout);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement