QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#407479 | #8297. Defining Labels | lonlyness | AC ✓ | 86ms | 3592kb | C++23 | 1.5kb | 2024-05-08 19:42:41 | 2024-05-08 19:42:43 |
Judging History
answer
#include<iostream>
#include<algorithm>
#include<cstring>
#include<queue>
#include<vector>
#include<set>
#include<map>
#include<cmath>
using namespace std;
#define int long long
#define endl "\n"
const int N = 3e5+10;
int n,m,k;
typedef pair<int,int> PII;
int get(int x ,int cnt)
{
int res = 1;
for(int i= 1;i <= cnt;i ++)res*=x;
return res;
}
void solve()
{
cin>>n>>m;
vector<int>ans;
int sum = 0;
int tem = 0;
for(int i = 1;;i ++)
{
tem+=get(n,i);
if(m<=tem){
map<int,int>mp;
int cnt= 0;
for(int j = 9-n+1;j <= 9;j ++)mp[cnt++]=j;
vector<int>res;
for(int j = 0;j < i;j ++)res.push_back(0);
tem-=get(n,i);
m-=tem;
vector<int>ans;
m--;
while(m){
ans.push_back(m%n);
m/=n;
}
for(int j = 0;j < ans.size();j ++)
{
res[j]+=ans[j];
// cout<<res[j]<<endl;
}
reverse(res.begin(),res.end());
for(int j = 0;j < i;j ++)
{
char c= mp[res[j]]+'0';
cout<<c;
}
cout<<endl;
return;
}
}
}
signed main()
{
ios_base::sync_with_stdio(0); cin.tie(0);cout.tie(0);
int t=1;
cin>>t;
while(t--)
{
solve();
}
return 0;
}
这程序好像有点Bug,我给组数据试试?
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3592kb
input:
2 10 10 5 10
output:
9 59
result:
ok 2 lines
Test #2:
score: 0
Accepted
time: 86ms
memory: 3556kb
input:
100000 8 385305681 7 109699235 4 261908086 7 502646222 4 12580383 5 126745533 3 288419055 2 85504901 6 321113975 2 282134041 10 993024241 2 586597753 9 19217233 5 87237368 7 379291900 2 393340455 2 237168121 5 128698999 10 937803725 3 34331441 6 144544189 7 221381693 9 69838388 8 504174151 4 1156320...
output:
3786757232 4693488784 88767967676867 37534486833 788888669688 668865768557 797898789978778979 89888998889899889998888998 84799659768 8888998988898888899888899898 881913130 88898999989989988898989999898 39138971 578756987877 34475855393 8999899988899998899888989888 998889888989998898999999898 6698657...
result:
ok 100000 lines
Extra Test:
score: 0
Extra Test Passed