Submission #48553377
Source Code Expand
#include <bits/stdc++.h>
#define ll long long
#define ff first
#define ss second
#define ld long double
#define vi vector<ll>
#define pi pair<ll, ll>
#define vpi vector<pi>
#define endl '\n'
// #define int long long
using namespace std;
#define all(x) begin(x), end(x)
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update>
unsigned long long power(unsigned long long x,
ll y, ll p)
{
unsigned long long res = 1; // Initialize result
x = x % p; // Update x if it is more than or
// equal to p
while (y > 0)
{
// If y is odd, multiply x with result
if (y & 1)
res = (res * x) % p;
// y must be even now
y = y >> 1; // y = y/2
x = (x * x) % p;
}
return res;
}
// Returns n^(-1) mod p
unsigned long long modInverse(unsigned long long n,
int p)
{
return power(n, p - 2, p);
}
// Returns nCr % p using Fermat's little
// theorem.
vector<ll> fac;
void initfact(int n, ll p = pow(10, 9) + 7)
{
fac.resize(n + 1);
fac[0] = 1;
for (ll i = 1; i <= n; i++)
fac[i] = (fac[i - 1] * i) % p;
}
unsigned long long nCrModPFermat(long long n,
int r, int p)
{
// If n<r, then nCr should return 0
if (n < r)
return 0;
// Base case
if (n == 0 && r == 0)
return 1;
if (n == 0)
return 0;
if (r == 0)
return 1;
// Fill factorial array so that we
// can find all factorial of r, n
// and n-r
return (fac[n] * modInverse(fac[r], p) % p * modInverse(fac[n - r], p) % p) % p;
}
ll countSetBits(ll n)
{
ll count = 0;
while (n)
{
count += n & 1;
n >>= 1;
}
return count;
}
struct dsu
{
vector<ll> data;
int components = 0;
dsu(int n = -1)
{
if (n >= 0)
init(n);
}
void init(int n)
{
data.assign(n + 1, -1);
components = n;
}
int find(int x)
{
return data[x] < 0 ? x : data[x] = find(data[x]);
}
int get_size(int x)
{
return -data[find(x)];
}
bool unite(int x, int y)
{
x = find(x);
y = find(y);
if (x == y)
return false;
if (-data[x] < -data[y])
swap(x, y);
data[x] += data[y];
data[y] = x;
components--;
return true;
}
};
ll setBitNumber(ll n)
{
if (n == 0)
return 0;
ll msb = 0;
n = n / 2;
while (n != 0)
{
n = n / 2;
msb++;
}
return (1 << msb);
}
ll countBits(ll number)
{
// log function in base 2
// take only integer part
return (ll)log2(number) + 1;
}
ll sum(ll k)
{
return k * (k + 1) / 2;
}
ll mul(ll a, ll b, ll mod = 998244353)
{
return ((a % mod) * (b % mod)) % mod;
}
int kmp(string s)
{
string chk = s;
vector<int> lps(s.size(), 0);
for (int i = 1; i < (int)lps.size(); ++i)
{
int prev_idx = lps[i - 1];
while (prev_idx > 0 && s[i] != s[prev_idx])
{
prev_idx = lps[prev_idx - 1];
}
lps[i] = prev_idx + (s[i] == s[prev_idx] ? 1 : 0);
}
return lps[lps.size() - 1];
}
ll p = pow(10, 9) + 7;
ll mod2 = 998244353;
void vscode()
{
#ifndef ONLINE_JUDGE
freopen("input.txt", "r", stdin);
freopen("output.txt", "w", stdout);
#endif
}
bool isPrime(ll n)
{
// Corner case
if (n <= 1)
return false;
// Check from 2 to n-1
for (ll i = 2; i * i <= n; i++)
if (n % i == 0)
return false;
return true;
}
bool palind(string s)
{
string tmp = s;
reverse(all(tmp));
return tmp == s;
}
ll inv(ll a, ll m)
{
ll m0 = m, t, q;
ll x0 = 0, x1 = 1;
if (m == 1)
return 0;
// Apply extended Euclid Algorithm
while (a > 1)
{
// q is quotient
q = a / m;
t = m;
// m is remainder now, process same as
// euclid's algo
m = a % m, a = t;
t = x0;
x0 = x1 - q * x0;
x1 = t;
}
// Make x1 positive
if (x1 < 0)
x1 += m0;
return x1;
}
struct FenwickTreeOneBasedIndexing
{
vector<int> bit; // binary indexed tree
int n;
FenwickTreeOneBasedIndexing(int n)
{
this->n = n + 1;
bit.assign(n + 1, 0);
}
FenwickTreeOneBasedIndexing(vector<int> a)
: FenwickTreeOneBasedIndexing(a.size())
{
for (size_t i = 0; i < a.size(); i++)
add(i, a[i]);
}
int sum(int idx)
{
int ret = 0;
for (++idx; idx > 0; idx -= idx & -idx)
ret += bit[idx];
return ret;
}
int sum(int l, int r)
{
return sum(r) - sum(l - 1);
}
void add(int idx, int val)
{
for (++idx; idx < n; idx += idx & -idx)
bit[idx] += val;
}
void range_add(int l, int r, int val)
{
add(l, val);
add(r + 1, -val);
}
int point_query(int idx)
{
int ret = 0;
for (++idx; idx > 0; idx -= idx & -idx)
ret += bit[idx];
return ret;
}
};
struct custom_hash
{
static uint64_t splitmix64(uint64_t x)
{
// http://xorshift.di.unimi.it/splitmix64.c
x += 0x9e3779b97f4a7c15;
x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
return x ^ (x >> 31);
}
size_t operator()(uint64_t x) const
{
return splitmix64(x);
}
};
vector<ll>a;
void rec(ll n,ll base,ll cnt)
{
if(cnt ==0)
{
a.push_back(n);
return;
}
if(base>=1e14)
return;
rec(n+base,base,cnt-1);
rec(n,base*10+1,cnt);
}
void solve()
{
ll n;
cin>>n;
rec(0,1,3);
sort(all(a));
cout<<a[n-1];
}
signed main()
{
ios::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
cout << fixed;
int t = 1;
vscode();
// cin>>t;
for (int i = 1; i <= t; i++)
{
// cout<<"Case #"<<i<<":"<<" ";
solve();
}
return 0;
}
//
Submission Info
| Submission Time |
|
| Task |
C - Repunit Trio |
| User |
Vold_mort |
| Language |
C++ 20 (gcc 12.2) |
| Score |
300 |
| Code Size |
6606 Byte |
| Status |
AC |
| Exec Time |
1 ms |
| Memory |
3544 KiB |
Judge Result
| Set Name |
Sample |
All |
| Score / Max Score |
0 / 0 |
300 / 300 |
| Status |
|
|
| Set Name |
Test Cases |
| Sample |
00_sample_01.txt, 00_sample_02.txt, 00_sample_03.txt |
| All |
00_sample_01.txt, 00_sample_02.txt, 00_sample_03.txt, 01_test_01.txt, 01_test_02.txt, 01_test_03.txt, 01_test_04.txt, 01_test_05.txt, 01_test_06.txt, 01_test_07.txt, 01_test_08.txt, 01_test_09.txt, 01_test_10.txt, 01_test_11.txt, 01_test_12.txt, 01_test_13.txt, 01_test_14.txt, 01_test_15.txt, 01_test_16.txt, 01_test_17.txt |
| Case Name |
Status |
Exec Time |
Memory |
| 00_sample_01.txt |
AC |
1 ms |
3440 KiB |
| 00_sample_02.txt |
AC |
1 ms |
3472 KiB |
| 00_sample_03.txt |
AC |
1 ms |
3356 KiB |
| 01_test_01.txt |
AC |
1 ms |
3424 KiB |
| 01_test_02.txt |
AC |
1 ms |
3348 KiB |
| 01_test_03.txt |
AC |
1 ms |
3536 KiB |
| 01_test_04.txt |
AC |
1 ms |
3488 KiB |
| 01_test_05.txt |
AC |
1 ms |
3540 KiB |
| 01_test_06.txt |
AC |
1 ms |
3480 KiB |
| 01_test_07.txt |
AC |
1 ms |
3536 KiB |
| 01_test_08.txt |
AC |
1 ms |
3472 KiB |
| 01_test_09.txt |
AC |
1 ms |
3468 KiB |
| 01_test_10.txt |
AC |
1 ms |
3408 KiB |
| 01_test_11.txt |
AC |
1 ms |
3440 KiB |
| 01_test_12.txt |
AC |
1 ms |
3468 KiB |
| 01_test_13.txt |
AC |
1 ms |
3544 KiB |
| 01_test_14.txt |
AC |
1 ms |
3428 KiB |
| 01_test_15.txt |
AC |
1 ms |
3472 KiB |
| 01_test_16.txt |
AC |
1 ms |
3508 KiB |
| 01_test_17.txt |
AC |
1 ms |
3544 KiB |