QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#39645 | #1875. Nein | g | AC ✓ | 187ms | 11584kb | C++20 | 15.7kb | 2022-07-12 17:20:58 | 2022-07-12 17:21:00 |
Judging History
answer
/**
* author: gary
* created: 11.07.2022 21:30:55
**/
#include<bits/stdc++.h>
#define rb(a,b,c) for(int a=b;a<=c;++a)
#define rl(a,b,c) for(int a=b;a>=c;--a)
#define rep(a,b) for(int a=0;a<b;++a)
#define LL long long
#define II(a,b) make_pair(a,b)
#define SRAND mt19937 rng(chrono::steady_clock::now().time_since_epoch().count())
#define random(a) rng()%a
#define ALL(a) a.begin(),a.end()
#define check_min(a,b) a=min(a,b)
#define check_max(a,b) a=max(a,b)
using namespace std;
//ctto
typedef long long ll;
typedef long double ld;
typedef complex<ld> pt;
const ld PI = acos(-1.L);
template<class T> struct cplx {
T x, y;
cplx() {
x = 0.0;
y = 0.0;
}
cplx(T nx, T ny = 0) {
x = nx;
y = ny;
}
cplx operator+(const cplx &c) const {
return {x + c.x, y + c.y};
}
cplx operator-(const cplx &c) const {
return {x - c.x, y - c.y};
}
cplx operator*(const cplx &c) const {
return {x*c.x - y * c.y, x*c.y + y * c.x};
}
cplx& operator*=(const cplx &c) {
return *this = {x*c.x - y * c.y, x*c.y + y * c.x};
}
inline T real() const {
return x;
}
inline T imag() const {
return y;
}
// Only supports right scalar multiplication like p*c
template<class U> cplx operator*(const U &c) const {
return {x * c, y * c};
}
template<class U> cplx operator/(const U &c) const {
return {x / c, y / c};
}
template<class U> void operator/=(const U &c) {
x /= c;
y /= c;
}
};
#define polar(r,a) (cplx<ld>){r*cos(a),r*sin(a)}
const int DIG = 9, FDIG = 4;
const int BASE = 1e9, FBASE = 1e4;
typedef cplx<ld> Cplx;
// use mulmod when taking mod by int v and v>2e9
// you can use mod by bigint in that case too
struct BigInt {
int sgn;
vector<int> a;
BigInt() : sgn(1) {}
BigInt(ll v) {
*this = v;
}
BigInt& operator = (ll v) {
sgn = 1;
if (v < 0) sgn = -1, v = -v;
a.clear();
for (; v > 0; v /= BASE) a.push_back(v % BASE);
return *this;
}
BigInt(const BigInt& other) {
sgn = other.sgn;
a = other.a;
}
friend void swap(BigInt& a, BigInt& b) {
swap(a.sgn, b.sgn);
swap(a.a, b.a);
}
BigInt& operator = (BigInt other) {
swap(*this, other);
return *this;
}
BigInt(BigInt&& other) : BigInt() {
swap(*this, other);
}
BigInt(const string& s) {
read(s);
}
void read(const string& s) {
sgn = 1;
a.clear();
int k = 0;
for (; k < s.size() && (s[k] == '-' || s[k] == '+'); k++)
if (s[k] == '-') sgn = -sgn;
for (int i = s.size() - 1; i >= k; i -= DIG) {
int x = 0;
for (int j = max(k, i - DIG + 1); j <= i; j++) x = x * 10 + s[j] - '0';
a.push_back(x);
}
trim();
}
friend istream& operator>>(istream &in, BigInt &v) {
string s;
in >> s;
v.read(s);
return in;
}
friend ostream& operator<<(ostream &out, const BigInt &v) {
if (v.sgn == -1 && !v.zero()) out << '-';
out << (v.a.empty() ? 0 : v.a.back());
for (int i = (int) v.a.size() - 2; i >= 0; --i)
out << setw(DIG) << setfill('0') << v.a[i];
return out;
}
bool operator<(const BigInt &v) const {
if (sgn != v.sgn) return sgn < v.sgn;
if (a.size() != v.a.size()) return a.size() * sgn < v.a.size() * v.sgn;
for (int i = (int)a.size() - 1; i >= 0; i--)
if (a[i] != v.a[i]) return a[i] * sgn < v.a[i] * sgn;
return 0;
}
bool operator>(const BigInt &v) const {
return v < *this;
}
bool operator<=(const BigInt &v) const {
return !(v < *this);
}
bool operator>=(const BigInt &v) const {
return !(*this < v);
}
bool operator==(const BigInt &v) const {
return !(*this < v) && !(v < *this);
}
bool operator!=(const BigInt &v) const {
return *this < v || v < *this;
}
friend int __cmp(const BigInt& x, const BigInt& y) {
if (x.a.size() != y.a.size()) return x.a.size() < y.a.size() ? -1 : 1;
for (int i = (int) x.a.size() - 1; i >= 0; --i) if (x.a[i] != y.a[i])
return x.a[i] < y.a[i] ? -1 : 1;
return 0;
}
BigInt operator-() const {
BigInt res = *this;
if (zero()) return res;
res.sgn = -sgn;
return res;
}
void __add(const BigInt& v) {
if (a.size() < v.a.size()) a.resize(v.a.size(), 0);
for (int i = 0, carry = 0; i < max(a.size(), v.a.size()) || carry; ++i) {
if (i == a.size()) a.push_back(0);
a[i] += carry + (i < (int) v.a.size() ? v.a[i] : 0);
carry = a[i] >= BASE;
if (carry) a[i] -= BASE;
}
}
void __sub(const BigInt& v) {
for (int i = 0, carry = 0; i < (int) v.a.size() || carry; ++i) {
a[i] -= carry + (i < (int) v.a.size() ? v.a[i] : 0);
carry = a[i] < 0;
if (carry) a[i] += BASE;
}
this->trim();
}
BigInt operator+=(const BigInt& v) {
if (sgn == v.sgn) __add(v);
else if (__cmp(*this, v) >= 0) __sub(v);
else {
BigInt vv = v;
swap(*this, vv);
__sub(vv);
}
return *this;
}
BigInt operator-=(const BigInt& v) {
if (sgn == v.sgn) {
if (__cmp(*this, v) >= 0) __sub(v);
else {
BigInt vv = v;
swap(*this, vv);
__sub(vv);
sgn = -sgn;
}
} else __add(v);
return *this;
}
template< typename L, typename R >
typename enable_if <
is_convertible<L, BigInt>::value &&
is_convertible<R, BigInt>::value &&
is_lvalue_reference < R&& >::value,
BigInt >::type friend operator + (L&& l, R&& r) {
BigInt result(forward<L>(l));
result += r;
return result;
}
template< typename L, typename R >
typename enable_if <
is_convertible<L, BigInt>::value &&
is_convertible<R, BigInt>::value &&
is_rvalue_reference < R&& >::value,
BigInt >::type friend operator + (L&& l, R&& r) {
BigInt result(move(r));
result += l;
return result;
}
template< typename L, typename R >
typename enable_if <
is_convertible<L, BigInt>::value &&
is_convertible<R, BigInt>::value,
BigInt >::type friend operator - (L&& l, R&& r) {
BigInt result(forward<L>(l));
result -= r;
return result;
}
friend pair<BigInt, BigInt> divmod(const BigInt& a1, const BigInt& b1) {
ll norm = BASE / (b1.a.back() + 1);
BigInt a = a1.abs() * norm, b = b1.abs() * norm, q = 0, r = 0;
q.a.resize(a.a.size());
for (int i = a.a.size() - 1; i >= 0; i--) {
r *= BASE;
r += a.a[i];
ll s1 = r.a.size() <= b.a.size() ? 0 : r.a[b.a.size()];
ll s2 = r.a.size() <= b.a.size() - 1 ? 0 : r.a[b.a.size() - 1];
ll d = ((ll) BASE * s1 + s2) / b.a.back();
r -= b * d;
while (r < 0) r += b, --d;
q.a[i] = d;
}
q.sgn = a1.sgn * b1.sgn;
r.sgn = a1.sgn;
q.trim();
r.trim();
auto res = make_pair(q, r / norm);
if (res.second < 0) res.second += b1;
return res;
}
BigInt operator/(const BigInt &v) const {
return divmod(*this, v).first;
}
BigInt operator%(const BigInt &v) const {
return divmod(*this, v).second;
}
void operator/=(int v) {
if (llabs(v) >= BASE) {
*this /= BigInt(v);
return;
}
if (v < 0) sgn = -sgn, v = -v;
for (int i = (int) a.size() - 1, rem = 0; i >= 0; --i) {
ll cur = a[i] + rem * (ll)BASE;
a[i] = (int) (cur / v);
rem = (int) (cur % v);
}
trim();
}
BigInt operator/(int v) const {
if (llabs(v) >= BASE) return *this / BigInt(v);
BigInt res = *this;
res /= v;
return res;
}
void operator/=(const BigInt &v) {
*this = *this / v;
}
ll operator%(ll v) const {
int m = 0;
for (int i = a.size() - 1; i >= 0; --i) m = (a[i] + m * (ll) BASE) % v;
return m * sgn;
}
void operator*=(int v) {
if (llabs(v) >= BASE) {
*this *= BigInt(v);
return;
}
if (v < 0) sgn = -sgn, v = -v;
for (int i = 0, carry = 0; i < a.size() || carry; ++i) {
if (i == a.size()) a.push_back(0);
ll cur = a[i] * (ll) v + carry;
carry = (int) (cur / BASE);
a[i] = (int) (cur % BASE);
}
trim();
}
BigInt operator*(int v) const {
if (llabs(v) >= BASE) return *this * BigInt(v);
BigInt res = *this;
res *= v;
return res;
}
static vector<int> convert_base(const vector<int> &a, int old_digits, int new_digits) {
vector<ll> p(max(old_digits, new_digits) + 1);
p[0] = 1;
for (int i = 1; i < (int) p.size(); i++)
p[i] = p[i - 1] * 10;
vector<int> res;
ll cur = 0;
int cur_digits = 0;
for (int i = 0; i < (int) a.size(); i++) {
cur += a[i] * p[cur_digits];
cur_digits += old_digits;
while (cur_digits >= new_digits) {
res.push_back((ll)(cur % p[new_digits]));
cur /= p[new_digits];
cur_digits -= new_digits;
}
}
res.push_back((int) cur);
while (!res.empty() && !res.back())
res.pop_back();
return res;
}
void fft(vector<Cplx>& a, bool invert) const {
int n = a.size();
for (int i = 1, j = 0; i < n; ++i) {
int bit = n / 2;
for (; j >= bit; bit /= 2) j -= bit;
j += bit;
if (i < j) swap(a[i], a[j]);
}
for (int len = 2; len <= n; len *= 2) {
ld ang = 2 * PI / len * (invert ? -1 : 1);
Cplx wlen = polar(1, ang);
for (int i = 0; i < n; i += len) {
Cplx w(1);
for (int j = 0; j < len / 2; ++j) {
Cplx u = a[i + j], v = a[i + j + len / 2] * w;
a[i + j] = u + v;
a[i + j + len / 2] = u - v;
w *= wlen;
}
}
}
if (invert) for (int i = 0; i < n; ++i) a[i] /= n;
}
void multiply_fft(const vector<int> &a, const vector<int> &b, vector<int> &res) const {
vector<Cplx> fa(a.begin(), a.end()), fb(b.begin(), b.end());
int n = 1;
while (n < max(a.size(), b.size())) n *= 2;
n *= 2;
fa.resize(n);
fb.resize(n);
fft(fa, 0);
fft(fb, 0);
for (int i = 0; i < n; ++i) fa[i] *= fb[i];
fft(fa, 1);
res.resize(n);
ll carry = 0;
for (int i = 0; i < n; i++) {
ll t = (ll)(fa[i].real() + 0.5) + carry;
carry = t / FBASE;
res[i] = t % FBASE;
}
}
static inline int rev_incr(int a, int n) {
int msk = n / 2, cnt = 0;
while ( a & msk ) {
cnt++;
a <<= 1;
}
a &= msk - 1;
a |= msk;
while ( cnt-- ) a >>= 1;
return a;
}
static vector<Cplx> FFT(vector<Cplx> v, int dir = 1) {
Cplx wm, w, u, t;
int n = v.size();
vector<Cplx> V(n);
for (int k = 0, a = 0; k < n; ++k, a = rev_incr(a, n))
V[a] = v[k] / ld(dir > 0 ? 1 : n);
for (int m = 2; m <= n; m <<= 1) {
wm = polar( (ld)1, dir * 2 * PI / m );
for (int k = 0; k < n; k += m) {
w = 1;
for (int j = 0; j < m / 2; ++j, w *= wm) {
u = V[k + j];
t = w * V[k + j + m / 2];
V[k + j] = u + t;
V[k + j + m / 2] = u - t;
}
}
}
return V;
}
static void convolution(const vector<int>& a, const vector<int>& b, vector<int>& c) {
int sz = a.size() + b.size() - 1;
int n = 1 << int(ceil(log2(sz)));
vector<Cplx> av(n, 0), bv(n, 0), cv;
for (int i = 0; i < a.size(); i++) av[i] = a[i];
for (int i = 0; i < b.size(); i++) bv[i] = b[i];
cv = FFT(bv);
bv = FFT(av);
for (int i = 0; i < n; i++) av[i] = bv[i] * cv[i];
cv = FFT(av, -1);
c.resize(n);
ll carry = 0;
for (int i = 0; i < n; i++) {
ll t = ll(cv[i].real() + 0.5) + carry;
carry = t / FBASE;
c[i] = t % FBASE;
}
}
BigInt mul_simple(const BigInt &v) const {
BigInt res;
res.sgn = sgn * v.sgn;
res.a.resize(a.size() + v.a.size());
for (int i = 0; i < a.size(); i++) if (a[i])
for (int j = 0, carry = 0; j < v.a.size() || carry; j++) {
ll cur = res.a[i + j] + (ll) a[i] * (j < v.a.size() ? v.a[j] : 0) + carry;
carry = (int) (cur / BASE);
res.a[i + j] = (int) (cur % BASE);
}
res.trim();
return res;
}
BigInt mul_fft(const BigInt& v) const {
BigInt res;
convolution(convert_base(a, DIG, FDIG), convert_base(v.a, DIG, FDIG), res.a);
res.a = convert_base(res.a, FDIG, DIG);
res.trim();
return res;
}
void operator*=(const BigInt &v) {
*this = *this * v;
}
BigInt operator*(const BigInt &v) const {
if (1LL * a.size() * v.a.size() <= 1000111) return mul_simple(v);
return mul_fft(v);
}
BigInt abs() const {
BigInt res = *this;
res.sgn *= res.sgn;
return res;
}
void trim() {
while (!a.empty() && !a.back()) a.pop_back();
}
bool zero() const {
return a.empty() || (a.size() == 1 && !a[0]);
}
friend BigInt gcd(const BigInt &a, const BigInt &b) {
return b.zero() ? a : gcd(b, a % b);
}
};
const LL INF=2e18;
typedef pair<int,int> mp;
int k;
LL n;
LL f[1001][1001];
LL mul(LL A,LL B){
if(A==0||B==0) return 0;
return (A>=INF/B? INF:A*B);
}
LL add(LL A,LL B){
return min(INF,A+B);
}
void print(__int128_t num){
if(!num) return ;
print(num/10);
cout<<char('0'+num%10);
}
LL calc(vector<int> cnt,vector<int> sum){
LL rest=0;
int tmp=45;
rb(i,1,tmp){
// = (10^k-1)*i
__int128_t val=1;
rb(j,1,k) val*=10;
val--;
val*=i;
LL dp[2][45*8];
memset(dp,0,sizeof(dp));
int now,nex;
now=0,nex=1;
dp[now][0]=1;
int z=0;
while (val){
memset(dp[nex],0,sizeof(dp[nex]));
rb(j,0,45*8-1){
if(dp[now][j]){
rb(l,0,1e9){
if(z>=k&&l) break;
if(z<k) check_max(l,sum[z]);
if(z<k&&l-sum[z]>cnt[z]*8) break;
if((j+l)%10!=val%10) continue;
if(z>=k){
dp[nex][j/10]=add(dp[nex][j/10],dp[now][j]);
}
else{
dp[nex][(j+l)/10]=add(dp[nex][(j+l)/10],mul(dp[now][j],f[cnt[z]][l-sum[z]]));
}
}
}
}
val/=10;
swap(now,nex);
++z;
}
rest=add(rest,dp[now][0]);
}
return rest;
}
LL calc_z(int len){
LL rest=0;
rb(i,1,8){
vector<int> c(k,len/k),sum(k,0);
rep(i,len%k) c[i]++;
c[(len-1)%k]--;
sum[(len-1)%k]=i;
rest=add(rest,calc(c,sum));
}
return rest;
}
int main(){
cin>>k>>n;
int len=1;
f[0][0]=1;
rb(i,0,999){
rb(j,0,1000){
rb(k,0,8){
if(k+j<=1000){
f[i+1][j+k]+=f[i][j];
check_min(f[i+1][j+k],INF);
}
}
}
}
while (true){
auto tmp=calc_z(len);
if(tmp>=n) break;
n-=tmp;
++len;
}
vector<int> num;
int cnt[18];
fill(cnt,cnt+k,len/k);
rep(j,len%k) cnt[j]++;
vector<int> sum(k,0);
// cout<<len<<endl;
rl(i,len-1,0){
cnt[i%k]--;
vector<int> c(k,0);
rep(j,k) c[j]=cnt[j];
rb(j,(i==len-1? 1:0),8){
sum[i%k]+=j;
auto tmp=calc(c,sum);
// cout<<i<<":"<<tmp<<' '<<n<<' '<<j<<endl;
if(tmp>=n){
// cout<<j<<" "<<n<<" "<<tmp<<endl;
num.push_back(j);
break;
}
n-=tmp;
sum[i%k]-=j;
}
}
BigInt rest=0;
for(auto it:num) rest*=10,rest+=it;
BigInt B=1;
rb(i,1,k) B*=10;
B-=1;
cout<<rest/B<<endl;
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 14ms
memory: 11396kb
input:
1 1
output:
2
result:
ok answer is '2'
Test #2:
score: 0
Accepted
time: 14ms
memory: 11576kb
input:
1 8
output:
9
result:
ok answer is '9'
Test #3:
score: 0
Accepted
time: 14ms
memory: 11388kb
input:
1 9
output:
12
result:
ok answer is '12'
Test #4:
score: 0
Accepted
time: 11ms
memory: 11400kb
input:
1 10
output:
13
result:
ok answer is '13'
Test #5:
score: 0
Accepted
time: 24ms
memory: 11580kb
input:
5 1
output:
11112
result:
ok answer is '11112'
Test #6:
score: 0
Accepted
time: 25ms
memory: 11392kb
input:
5 84
output:
11235
result:
ok answer is '11235'
Test #7:
score: 0
Accepted
time: 18ms
memory: 11396kb
input:
5 668
output:
12345
result:
ok answer is '12345'
Test #8:
score: 0
Accepted
time: 27ms
memory: 11400kb
input:
5 733942
output:
2281488
result:
ok answer is '2281488'
Test #9:
score: 0
Accepted
time: 127ms
memory: 11580kb
input:
18 528599760553218747
output:
30725517742188427234
result:
ok answer is '30725517742188427234'
Test #10:
score: 0
Accepted
time: 137ms
memory: 11396kb
input:
18 964828716126767591
output:
55758681752658348563
result:
ok answer is '55758681752658348563'
Test #11:
score: 0
Accepted
time: 132ms
memory: 11368kb
input:
18 401057671700316435
output:
22687686284122211545
result:
ok answer is '22687686284122211545'
Test #12:
score: 0
Accepted
time: 149ms
memory: 11452kb
input:
18 837286627273865280
output:
48255733668453323265
result:
ok answer is '48255733668453323265'
Test #13:
score: 0
Accepted
time: 138ms
memory: 11388kb
input:
18 273515582847414124
output:
15116382182883344554
result:
ok answer is '15116382182883344554'
Test #14:
score: 0
Accepted
time: 134ms
memory: 11584kb
input:
18 55923968082999579
output:
2876461768512185545
result:
ok answer is '2876461768512185545'
Test #15:
score: 0
Accepted
time: 56ms
memory: 11452kb
input:
8 715524960511324231
output:
12022650248772112989
result:
ok answer is '12022650248772112989'
Test #16:
score: 0
Accepted
time: 116ms
memory: 11500kb
input:
16 151753916084873076
output:
6182363727541142425
result:
ok answer is '6182363727541142425'
Test #17:
score: 0
Accepted
time: 37ms
memory: 11444kb
input:
2 587982875953389216
output:
4754915500630529532
result:
ok answer is '4754915500630529532'
Test #18:
score: 0
Accepted
time: 65ms
memory: 11580kb
input:
10 24211831526938061
output:
410770411555582497
result:
ok answer is '410770411555582497'
Test #19:
score: 0
Accepted
time: 139ms
memory: 11584kb
input:
18 460440787100486905
output:
26131416714411853682
result:
ok answer is '26131416714411853682'
Test #20:
score: 0
Accepted
time: 64ms
memory: 11364kb
input:
8 896669742674035749
output:
14750223579258782248
result:
ok answer is '14750223579258782248'
Test #21:
score: 0
Accepted
time: 87ms
memory: 11496kb
input:
12 556270735102360402
output:
13827553636696643430
result:
ok answer is '13827553636696643430'
Test #22:
score: 0
Accepted
time: 31ms
memory: 11460kb
input:
2 992499694970876542
output:
8147123087598806742
result:
ok answer is '8147123087598806742'
Test #23:
score: 0
Accepted
time: 61ms
memory: 11584kb
input:
9 191349424180689911
output:
3224103375245122149
result:
ok answer is '3224103375245122149'
Test #24:
score: 0
Accepted
time: 12ms
memory: 11404kb
input:
1 1000000000000000000
output:
7317596822929805779
result:
ok answer is '7317596822929805779'
Test #25:
score: 0
Accepted
time: 32ms
memory: 11448kb
input:
2 1000000000000000000
output:
8207298656583156714
result:
ok answer is '8207298656583156714'
Test #26:
score: 0
Accepted
time: 35ms
memory: 11460kb
input:
3 1000000000000000000
output:
10124840976332612776
result:
ok answer is '10124840976332612776'
Test #27:
score: 0
Accepted
time: 45ms
memory: 11444kb
input:
4 1000000000000000000
output:
11134918859204347753
result:
ok answer is '11134918859204347753'
Test #28:
score: 0
Accepted
time: 47ms
memory: 11444kb
input:
5 1000000000000000000
output:
12248384925950595769
result:
ok answer is '12248384925950595769'
Test #29:
score: 0
Accepted
time: 56ms
memory: 11404kb
input:
6 1000000000000000000
output:
13481441167144812720
result:
ok answer is '13481441167144812720'
Test #30:
score: 0
Accepted
time: 59ms
memory: 11452kb
input:
7 1000000000000000000
output:
14851839567286627600
result:
ok answer is '14851839567286627600'
Test #31:
score: 0
Accepted
time: 56ms
memory: 11580kb
input:
8 1000000000000000000
output:
16400312227388843586
result:
ok answer is '16400312227388843586'
Test #32:
score: 0
Accepted
time: 63ms
memory: 11492kb
input:
9 1000000000000000000
output:
18070802619848417970
result:
ok answer is '18070802619848417970'
Test #33:
score: 0
Accepted
time: 69ms
memory: 11400kb
input:
10 1000000000000000000
output:
18876263506622668979
result:
ok answer is '18876263506622668979'
Test #34:
score: 0
Accepted
time: 80ms
memory: 11444kb
input:
11 1000000000000000000
output:
22516357784746378893
result:
ok answer is '22516357784746378893'
Test #35:
score: 0
Accepted
time: 85ms
memory: 11392kb
input:
12 1000000000000000000
output:
25606071173776613626
result:
ok answer is '25606071173776613626'
Test #36:
score: 0
Accepted
time: 90ms
memory: 11496kb
input:
13 1000000000000000000
output:
30153652575287329992
result:
ok answer is '30153652575287329992'
Test #37:
score: 0
Accepted
time: 93ms
memory: 11444kb
input:
14 1000000000000000000
output:
34032144146113465692
result:
ok answer is '34032144146113465692'
Test #38:
score: 0
Accepted
time: 110ms
memory: 11392kb
input:
15 1000000000000000000
output:
38476235652741893950
result:
ok answer is '38476235652741893950'
Test #39:
score: 0
Accepted
time: 113ms
memory: 11448kb
input:
16 1000000000000000000
output:
44453843638835448269
result:
ok answer is '44453843638835448269'
Test #40:
score: 0
Accepted
time: 122ms
memory: 11392kb
input:
17 1000000000000000000
output:
51178357488582512218
result:
ok answer is '51178357488582512218'
Test #41:
score: 0
Accepted
time: 130ms
memory: 11388kb
input:
18 1000000000000000000
output:
57644143667246653868
result:
ok answer is '57644143667246653868'
Test #42:
score: 0
Accepted
time: 78ms
memory: 11424kb
input:
11 169906399332236675
output:
3542071158723189134
result:
ok answer is '3542071158723189134'
Test #43:
score: 0
Accepted
time: 74ms
memory: 11448kb
input:
10 836507396055528616
output:
15844261021999264957
result:
ok answer is '15844261021999264957'
Test #44:
score: 0
Accepted
time: 133ms
memory: 11580kb
input:
18 271736347334110166
output:
14838142784382116438
result:
ok answer is '14838142784382116438'
Test #45:
score: 0
Accepted
time: 89ms
memory: 11420kb
input:
13 705965302907659012
output:
20780554485617714682
result:
ok answer is '20780554485617714682'
Test #46:
score: 0
Accepted
time: 127ms
memory: 11500kb
input:
17 141194262776175153
output:
6535463816612312328
result:
ok answer is '6535463816612312328'
Test #47:
score: 0
Accepted
time: 80ms
memory: 11404kb
input:
12 575423218349724000
output:
14318523724188758677
result:
ok answer is '14318523724188758677'
Test #48:
score: 0
Accepted
time: 71ms
memory: 11404kb
input:
11 10652178218240141
output:
201716847375538682
result:
ok answer is '201716847375538682'
Test #49:
score: 0
Accepted
time: 105ms
memory: 11500kb
input:
15 677253166351597490
output:
25718425137845667325
result:
ok answer is '25718425137845667325'
Test #50:
score: 0
Accepted
time: 99ms
memory: 11448kb
input:
14 112482121925146336
output:
3478827471866842353
result:
ok answer is '3478827471866842353'
Test #51:
score: 0
Accepted
time: 85ms
memory: 11460kb
input:
13 138182159835368774
output:
3736504553128889177
result:
ok answer is '3736504553128889177'
Test #52:
score: 0
Accepted
time: 125ms
memory: 11420kb
input:
17 572411115408917620
output:
28263577418567266116
result:
ok answer is '28263577418567266116'
Test #53:
score: 0
Accepted
time: 111ms
memory: 11444kb
input:
16 7640070982466466
output:
275752565647555878
result:
ok answer is '275752565647555878'
Test #54:
score: 0
Accepted
time: 112ms
memory: 11448kb
input:
15 441869026556015312
output:
16212131234378684940
result:
ok answer is '16212131234378684940'
Test #55:
score: 0
Accepted
time: 93ms
memory: 11400kb
input:
14 876097982129564158
output:
30138111462733879719
result:
ok answer is '30138111462733879719'
Test #56:
score: 0
Accepted
time: 134ms
memory: 11576kb
input:
18 543698978852856099
output:
31531851816668641477
result:
ok answer is '31531851816668641477'
Test #57:
score: 0
Accepted
time: 124ms
memory: 11492kb
input:
17 977927934426404945
output:
50224732558555875933
result:
ok answer is '50224732558555875933'
Test #58:
score: 0
Accepted
time: 123ms
memory: 11448kb
input:
16 413156889999953790
output:
17247527871564162333
result:
ok answer is '17247527871564162333'
Test #59:
score: 0
Accepted
time: 112ms
memory: 11420kb
input:
15 847385845573502637
output:
32858466436756182939
result:
ok answer is '32858466436756182939'
Test #60:
score: 0
Accepted
time: 68ms
memory: 11580kb
input:
10 282614801147051482
output:
5234025743251842898
result:
ok answer is '5234025743251842898'
Test #61:
score: 0
Accepted
time: 103ms
memory: 11452kb
input:
15 973760833528793663
output:
37522313475261748199
result:
ok answer is '37522313475261748199'
Test #62:
score: 0
Accepted
time: 78ms
memory: 11420kb
input:
10 408989789102342508
output:
7507683644212199226
result:
ok answer is '7507683644212199226'
Test #63:
score: 0
Accepted
time: 137ms
memory: 11396kb
input:
18 843218748970858650
output:
48517453136216784320
result:
ok answer is '48517453136216784320'
Test #64:
score: 0
Accepted
time: 128ms
memory: 11388kb
input:
17 278447704544407496
output:
13445647446417261863
result:
ok answer is '13445647446417261863'
Test #65:
score: 0
Accepted
time: 120ms
memory: 11400kb
input:
16 712676664412923638
output:
31626684778484371838
result:
ok answer is '31626684778484371838'
Test #66:
score: 0
Accepted
time: 77ms
memory: 11448kb
input:
11 147905615691505187
output:
3115037238176298995
result:
ok answer is '3115037238176298995'
Test #67:
score: 0
Accepted
time: 96ms
memory: 11452kb
input:
14 814506608119829833
output:
27141557811571426774
result:
ok answer is '27141557811571426774'
Test #68:
score: 0
Accepted
time: 187ms
memory: 11388kb
input:
18 249735567988345974
output:
13745718855311428535
result:
ok answer is '13745718855311428535'
Test #69:
score: 0
Accepted
time: 150ms
memory: 11448kb
input:
17 683964523561894820
output:
34462588212244874220
result:
ok answer is '34462588212244874220'
Test #70:
score: 0
Accepted
time: 125ms
memory: 11448kb
input:
12 119193479135443666
output:
2777183132661531726
result:
ok answer is '2777183132661531726'
Test #71:
score: 0
Accepted
time: 133ms
memory: 11424kb
input:
18 577967474662410047
output:
33372657423746582198
result:
ok answer is '33372657423746582198'