QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#102053#4366. Forever Youngfzj2007WA 26ms3516kbC++141.8kb2023-05-02 11:09:342023-05-02 11:09:35

Judging History

你现在查看的是最新测评结果

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2023-05-02 11:09:35]
  • 评测
  • 测评结果:WA
  • 用时:26ms
  • 内存:3516kb
  • [2023-05-02 11:09:34]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
namespace IO{
	template<typename T>inline bool read(T &x){
		x=0;
		char ch=getchar();
		bool flag=0,ret=0;
		while(ch<'0'||ch>'9') flag=flag||(ch=='-'),ch=getchar();
		while(ch>='0'&&ch<='9') x=x*10+ch-'0',ch=getchar(),ret=1;
		x=flag?-x:x;
        return ret;
	}
	template<typename T,typename ...Args>inline bool read(T& a,Args& ...args){
	    return read(a)&&read(args...);
	}
	template<typename T>void prt(T x){
		if(x>9) prt(x/10);
		putchar(x%10+'0');
	}
	template<typename T>inline void put(T x){
		if(x<0) putchar('-'),x=-x;
		prt(x);
	}
	template<typename T>inline void put(char ch,T x){
		if(x<0) putchar('-'),x=-x;
		prt(x);
		putchar(ch);
	}
	template<typename T,typename ...Args>inline void put(T a,Args ...args){
	    put(a);
		put(args...);
	}
	template<typename T,typename ...Args>inline void put(const char ch,T a,Args ...args){
	    put(ch,a);
		put(ch,args...);
	}
	inline void put(string s){
		for(int i=0,sz=s.length();i<sz;i++) putchar(s[i]);
	}
	inline void put(const char* s){
		for(int i=0,sz=strlen(s);i<sz;i++) putchar(s[i]);
	}
}
using namespace IO;
#define int long long
int k,lim,st[25],ans;
inline int calc(int x,int y){
	int tp=0;
	while(y) st[++tp]=y%10,y/=10;
	int res=0;
	for(int i=tp;i;i--){
		if((__int128)res*x+st[i]>k) return k+1; 
		res=res*x+st[i];
	} 
	return res;
}
signed main(){
	read(k,lim);
	for(int i=500000;i;i--){
		int x=k,tp=0,flag=1,val=0;
		while(x) st[++tp]=x%i,flag=flag&&(st[tp]<10),x/=i;
		while(tp) val=val*10+st[tp],tp--;
		if(flag&&val>=lim){
			ans=i;
			break;
		}
	}
	for(int i=lim;i<=2000;i++){
		int l=1,r=k,res=k;
		while(l<=r){
			int mid=l+r>>1;
			if(calc(mid,i)<=k) l=mid+1,res=mid;
			else r=mid-1; 
		}
		if(calc(res,i)!=k) continue;
		ans=max(ans,res);
	}
	put('\n',ans);
	return 0;
}

详细

Test #1:

score: 100
Accepted
time: 7ms
memory: 3336kb

input:

32 20

output:

16

result:

ok single line: '16'

Test #2:

score: 0
Accepted
time: 5ms
memory: 3288kb

input:

2016 100

output:

42

result:

ok single line: '42'

Test #3:

score: 0
Accepted
time: 1ms
memory: 3348kb

input:

1000000000000000000 10

output:

1000000000000000000

result:

ok single line: '1000000000000000000'

Test #4:

score: 0
Accepted
time: 15ms
memory: 3336kb

input:

149239876439186 470

output:

11

result:

ok single line: '11'

Test #5:

score: 0
Accepted
time: 12ms
memory: 3296kb

input:

4851495 95

output:

539054

result:

ok single line: '539054'

Test #6:

score: 0
Accepted
time: 13ms
memory: 3344kb

input:

19839853985 19839853985

output:

10

result:

ok single line: '10'

Test #7:

score: 0
Accepted
time: 3ms
memory: 3284kb

input:

1000000000000000000 17

output:

999999999999999993

result:

ok single line: '999999999999999993'

Test #8:

score: 0
Accepted
time: 3ms
memory: 3516kb

input:

1000000000000000000 23

output:

499999999999999998

result:

ok single line: '499999999999999998'

Test #9:

score: 0
Accepted
time: 1ms
memory: 3296kb

input:

1000000000000000000 58

output:

166666666666666666

result:

ok single line: '166666666666666666'

Test #10:

score: 0
Accepted
time: 2ms
memory: 3288kb

input:

1000000000000000000 145

output:

999999997

result:

ok single line: '999999997'

Test #11:

score: 0
Accepted
time: 0ms
memory: 3300kb

input:

1000000000000000000 230

output:

500000000

result:

ok single line: '500000000'

Test #12:

score: 0
Accepted
time: 1ms
memory: 3296kb

input:

1000000000000000000 1050

output:

999999

result:

ok single line: '999999'

Test #13:

score: 0
Accepted
time: 21ms
memory: 3464kb

input:

1000000000000000000 9593

output:

1000

result:

ok single line: '1000'

Test #14:

score: 0
Accepted
time: 24ms
memory: 3296kb

input:

1000000000000000000 1000000000000000000

output:

10

result:

ok single line: '10'

Test #15:

score: 0
Accepted
time: 22ms
memory: 3388kb

input:

981759819857981583 10

output:

981759819857981583

result:

ok single line: '981759819857981583'

Test #16:

score: 0
Accepted
time: 26ms
memory: 3296kb

input:

981759819857981583 17

output:

981759819857981576

result:

ok single line: '981759819857981576'

Test #17:

score: 0
Accepted
time: 26ms
memory: 3388kb

input:

981759819857981583 23

output:

490879909928990790

result:

ok single line: '490879909928990790'

Test #18:

score: 0
Accepted
time: 25ms
memory: 3292kb

input:

981759819857981583 58

output:

196351963971596315

result:

ok single line: '196351963971596315'

Test #19:

score: 0
Accepted
time: 22ms
memory: 3296kb

input:

981759819857981583 140

output:

10

result:

ok single line: '10'

Test #20:

score: 0
Accepted
time: 22ms
memory: 3272kb

input:

981759819857981583 230

output:

10

result:

ok single line: '10'

Test #21:

score: 0
Accepted
time: 21ms
memory: 3328kb

input:

981759819857981583 1050

output:

10

result:

ok single line: '10'

Test #22:

score: 0
Accepted
time: 24ms
memory: 3296kb

input:

981759819857981583 9593

output:

10

result:

ok single line: '10'

Test #23:

score: 0
Accepted
time: 24ms
memory: 3208kb

input:

981759819857981583 74292

output:

10

result:

ok single line: '10'

Test #24:

score: 0
Accepted
time: 21ms
memory: 3504kb

input:

140986742987698176 10

output:

140986742987698176

result:

ok single line: '140986742987698176'

Test #25:

score: 0
Accepted
time: 26ms
memory: 3212kb

input:

158918593147583853 849

output:

10

result:

ok single line: '10'

Test #26:

score: 0
Accepted
time: 23ms
memory: 3280kb

input:

206808958398095782 82

output:

25851119799761972

result:

ok single line: '25851119799761972'

Test #27:

score: 0
Accepted
time: 25ms
memory: 3468kb

input:

675097804382958295 123

output:

12

result:

ok single line: '12'

Test #28:

score: 0
Accepted
time: 24ms
memory: 3300kb

input:

782891909194182377 95

output:

86987989910464708

result:

ok single line: '86987989910464708'

Test #29:

score: 0
Accepted
time: 24ms
memory: 3328kb

input:

782891909194182377 96

output:

25012

result:

ok single line: '25012'

Test #30:

score: 0
Accepted
time: 24ms
memory: 3496kb

input:

782891909194182377 30000

output:

11

result:

ok single line: '11'

Test #31:

score: 0
Accepted
time: 24ms
memory: 3464kb

input:

988246947114416919 93

output:

109805216346046324

result:

ok single line: '109805216346046324'

Test #32:

score: 0
Accepted
time: 24ms
memory: 3288kb

input:

988246947114416919 95

output:

26512

result:

ok single line: '26512'

Test #33:

score: 0
Accepted
time: 24ms
memory: 3276kb

input:

988246947114416919 29000

output:

10

result:

ok single line: '10'

Test #34:

score: 0
Accepted
time: 17ms
memory: 3208kb

input:

9000630015000129 100

output:

100002

result:

ok single line: '100002'

Test #35:

score: 0
Accepted
time: 25ms
memory: 3388kb

input:

999996640752785561 100

output:

31622

result:

ok single line: '31622'

Test #36:

score: 0
Accepted
time: 7ms
memory: 3336kb

input:

10 10

output:

10

result:

ok single line: '10'

Test #37:

score: 0
Accepted
time: 3ms
memory: 3272kb

input:

11 10

output:

11

result:

ok single line: '11'

Test #38:

score: 0
Accepted
time: 7ms
memory: 3288kb

input:

19 13

output:

16

result:

ok single line: '16'

Test #39:

score: 0
Accepted
time: 25ms
memory: 3332kb

input:

949986743716085769 100

output:

983040

result:

ok single line: '983040'

Test #40:

score: -100
Wrong Answer
time: 25ms
memory: 3288kb

input:

801548868891525129 100

output:

10

result:

wrong answer 1st lines differ - expected: '737280', found: '10'