QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#430534 | #8347. 毒假强 | Kevin5307 | 100 ✓ | 531ms | 3916kb | C++23 | 2.0kb | 2024-06-03 21:59:47 | 2024-06-03 21:59:48 |
Judging History
answer
//Author: Kevin
#include<bits/stdc++.h>
//#pragma GCC optimize("O2")
using namespace std;
#define ll long long
#define ull unsigned ll
#define pb emplace_back
#define mp make_pair
#define ALL(x) (x).begin(),(x).end()
#define rALL(x) (x).rbegin(),(x).rend()
#define srt(x) sort(ALL(x))
#define rev(x) reverse(ALL(x))
#define rsrt(x) sort(rALL(x))
#define sz(x) (int)(x.size())
#define inf 0x3f3f3f3f
#define pii pair<int,int>
#define lb(v,x) (int)(lower_bound(ALL(v),x)-v.begin())
#define ub(v,x) (int)(upper_bound(ALL(v),x)-v.begin())
#define uni(v) v.resize(unique(ALL(v))-v.begin())
#define longer __int128_t
void die(string S){puts(S.c_str());exit(0);}
const ll thres=1000000000000000005ll;
int k;
ll n;
void update(ll &a,ll b)
{
a+=b;
a=min(a,thres);
}
ll mul(ll x,ll y)
{
if(!x||!y) return 0;
if(y>thres/x) return thres;
return x*y;
}
ll dp[44][44*8];
longer pw10[39];
void print(longer x)
{
if(x>=10)
print(x/10);
cout<<(int)(x%10);
}
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
cin>>k>>n;
n++;
dp[0][0]=1;
for(int i=1;i<44;i++)
for(int j=0;j<44*8;j++)
for(int x=0;x<9&&x<=j;x++)
update(dp[i][j],dp[i-1][j-x]);
pw10[0]=1;
for(int i=1;i<39;i++)
pw10[i]=pw10[i-1]*10;
longer ans=0;
longer cur=0;
longer val=pw10[k]-1;
for(int i=40;i>=0;i--)
{
for(int j=0;j<9;j++)
{
ll cnt=0;
longer need=(val-cur%val)%val;
for(longer real=need;real<=pw10[k]*42*8;real+=val)
{
ll f[25][44];
memset(f,0,sizeof(f));
f[0][0]=1;
for(int x=1;x<=24;x++)
{
int have=0;
if(x<=k&&i>=x)
have=(i-x+k)/k;
int realvalue=(real/pw10[x-1])%10;
for(int y=0;y<44;y++)
for(int z=0;z<=have*8;z++) if((y+z)%10==realvalue)
update(f[x][(y+z)/10],mul(f[x-1][y],dp[have][z]));
}
update(cnt,f[24][0]);
}
if(cnt>=n)
{
ans=ans*10+j;
break;
}
n-=cnt;
cur+=pw10[i%k];
}
}
print(ans/val);
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Subtask #1:
score: 25
Accepted
Test #1:
score: 25
Accepted
time: 140ms
memory: 3684kb
input:
2 653
output:
1069
result:
ok single line: '1069'
Test #2:
score: 0
Accepted
time: 137ms
memory: 3700kb
input:
2 729
output:
1168
result:
ok single line: '1168'
Test #3:
score: 0
Accepted
time: 136ms
memory: 3684kb
input:
2 378
output:
569
result:
ok single line: '569'
Test #4:
score: 0
Accepted
time: 144ms
memory: 3712kb
input:
3 673
output:
1329
result:
ok single line: '1329'
Test #5:
score: 0
Accepted
time: 142ms
memory: 3648kb
input:
3 803
output:
1514
result:
ok single line: '1514'
Test #6:
score: 0
Accepted
time: 143ms
memory: 3684kb
input:
3 999
output:
1772
result:
ok single line: '1772'
Test #7:
score: 0
Accepted
time: 148ms
memory: 3692kb
input:
1 754
output:
1142
result:
ok single line: '1142'
Test #8:
score: 0
Accepted
time: 139ms
memory: 3684kb
input:
3 673
output:
1329
result:
ok single line: '1329'
Test #9:
score: 0
Accepted
time: 147ms
memory: 3864kb
input:
3 728
output:
1390
result:
ok single line: '1390'
Test #10:
score: 0
Accepted
time: 144ms
memory: 3624kb
input:
3 644
output:
1277
result:
ok single line: '1277'
Test #11:
score: 0
Accepted
time: 143ms
memory: 3580kb
input:
3 403
output:
734
result:
ok single line: '734'
Test #12:
score: 0
Accepted
time: 137ms
memory: 3688kb
input:
2 196
output:
286
result:
ok single line: '286'
Test #13:
score: 0
Accepted
time: 141ms
memory: 3860kb
input:
1 73
output:
90
result:
ok single line: '90'
Test #14:
score: 0
Accepted
time: 136ms
memory: 3896kb
input:
2 661
output:
1079
result:
ok single line: '1079'
Test #15:
score: 0
Accepted
time: 143ms
memory: 3628kb
input:
1 648
output:
889
result:
ok single line: '889'
Subtask #2:
score: 35
Accepted
Test #16:
score: 35
Accepted
time: 262ms
memory: 3576kb
input:
1 345034715579071096
output:
2513029422339367072
result:
ok single line: '2513029422339367072'
Test #17:
score: 0
Accepted
time: 304ms
memory: 3864kb
input:
1 928064447724082316
output:
6841649390539291284
result:
ok single line: '6841649390539291284'
Test #18:
score: 0
Accepted
time: 277ms
memory: 3624kb
input:
1 541392330132197148
output:
3934945708734153715
result:
ok single line: '3934945708734153715'
Test #19:
score: 0
Accepted
time: 264ms
memory: 3628kb
input:
1 932096632324717020
output:
6866796948572468426
result:
ok single line: '6866796948572468426'
Test #20:
score: 0
Accepted
time: 334ms
memory: 3832kb
input:
1 114451898294099023
output:
751984975176342275
result:
ok single line: '751984975176342275'
Test #21:
score: 0
Accepted
time: 248ms
memory: 3892kb
input:
1 235498410350575794
output:
1678575115834518445
result:
ok single line: '1678575115834518445'
Test #22:
score: 0
Accepted
time: 310ms
memory: 3636kb
input:
1 263087596959546780
output:
1854129753611416834
result:
ok single line: '1854129753611416834'
Test #23:
score: 0
Accepted
time: 295ms
memory: 3732kb
input:
1 576677905677423798
output:
4168653345619750896
result:
ok single line: '4168653345619750896'
Test #24:
score: 0
Accepted
time: 265ms
memory: 3684kb
input:
1 715338160945566811
output:
5200349120580131175
result:
ok single line: '5200349120580131175'
Test #25:
score: 0
Accepted
time: 283ms
memory: 3680kb
input:
1 732471942288061103
output:
5313900915618634928
result:
ok single line: '5313900915618634928'
Test #26:
score: 0
Accepted
time: 226ms
memory: 3620kb
input:
1 81591921669173834
output:
533613350411224447
result:
ok single line: '533613350411224447'
Test #27:
score: 0
Accepted
time: 276ms
memory: 3648kb
input:
1 444041620832982561
output:
3172902012381803952
result:
ok single line: '3172902012381803952'
Test #28:
score: 0
Accepted
time: 293ms
memory: 3716kb
input:
1 6697181292380282
output:
39407408296042592
result:
ok single line: '39407408296042592'
Test #29:
score: 0
Accepted
time: 280ms
memory: 3628kb
input:
1 952035664236484391
output:
7007633864782456009
result:
ok single line: '7007633864782456009'
Test #30:
score: 0
Accepted
time: 285ms
memory: 3640kb
input:
1 119337166106580019
output:
792828609748126894
result:
ok single line: '792828609748126894'
Subtask #3:
score: 40
Accepted
Test #31:
score: 40
Accepted
time: 408ms
memory: 3648kb
input:
12 874620678069272691
output:
22463825142185819370
result:
ok single line: '22463825142185819370'
Test #32:
score: 0
Accepted
time: 507ms
memory: 3916kb
input:
16 802614516796786027
output:
35407415665622422294
result:
ok single line: '35407415665622422294'
Test #33:
score: 0
Accepted
time: 347ms
memory: 3692kb
input:
6 756647802834648987
output:
10438847716008292465
result:
ok single line: '10438847716008292465'
Test #34:
score: 0
Accepted
time: 260ms
memory: 3668kb
input:
3 226896403387130337
output:
2059211761939710776
result:
ok single line: '2059211761939710776'
Test #35:
score: 0
Accepted
time: 292ms
memory: 3628kb
input:
1 347488145421093192
output:
2527387074818969159
result:
ok single line: '2527387074818969159'
Test #36:
score: 0
Accepted
time: 451ms
memory: 3692kb
input:
14 193000621330864201
output:
6067357863414375200
result:
ok single line: '6067357863414375200'
Test #37:
score: 0
Accepted
time: 314ms
memory: 3696kb
input:
6 954115818600650251
output:
12864634150158375562
result:
ok single line: '12864634150158375562'
Test #38:
score: 0
Accepted
time: 531ms
memory: 3860kb
input:
17 743225133605738266
output:
37311263433846176756
result:
ok single line: '37311263433846176756'
Test #39:
score: 0
Accepted
time: 312ms
memory: 3580kb
input:
9 252020961388627232
output:
4250078145252196572
result:
ok single line: '4250078145252196572'
Test #40:
score: 0
Accepted
time: 435ms
memory: 3680kb
input:
12 625490241962472026
output:
15466218565422592895
result:
ok single line: '15466218565422592895'
Test #41:
score: 0
Accepted
time: 506ms
memory: 3692kb
input:
17 954452527346520859
output:
48142667151713611623
result:
ok single line: '48142667151713611623'
Test #42:
score: 0
Accepted
time: 292ms
memory: 3680kb
input:
3 976431687783080972
output:
8829664277323469345
result:
ok single line: '8829664277323469345'
Test #43:
score: 0
Accepted
time: 318ms
memory: 3712kb
input:
1 847601466910992894
output:
6192959617472541715
result:
ok single line: '6192959617472541715'
Test #44:
score: 0
Accepted
time: 304ms
memory: 3676kb
input:
4 151280662907406040
output:
1473815899034367653
result:
ok single line: '1473815899034367653'
Test #45:
score: 0
Accepted
time: 242ms
memory: 3584kb
input:
2 888548487913703829
output:
7283410115572769456
result:
ok single line: '7283410115572769456'