QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#125666#6740. FunctionAFewSunsAC ✓540ms7788kbC++142.3kb2023-07-17 09:45:302023-07-17 09:45:33

Judging History

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

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2023-07-17 09:45:33]
  • 评测
  • 测评结果:AC
  • 用时:540ms
  • 内存:7788kb
  • [2023-07-17 09:45:30]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
namespace my_std{
	#define ll int
	#define bl bool
	ll my_pow(ll a,ll b,ll mod){
		ll res=1;
		if(!b) return 1;
		while(b){
			if(b&1) res=(res*a)%mod;
			a=(a*a)%mod;
			b>>=1;
		}
		return res;
	}
	ll qpow(ll a,ll b){
		ll res=1;
		if(!b) return 1;
		while(b){
			if(b&1) res*=a;
			a*=a;
			b>>=1;
		}
		return res;
	}
	#define db double
	#define pf printf
	#define pc putchar
	#define fr(i,x,y) for(register ll i=(x);i<=(y);i++)
	#define pfr(i,x,y) for(register ll i=(x);i>=(y);i--)
	#define go(u) for(ll i=head[u];i;i=e[i].nxt)
	#define enter pc('\n')
	#define space pc(' ')
	#define fir first
	#define sec second
	#define MP make_pair
	#define il inline
	#define inf 1e18
	#define random(x) rand()*rand()%(x)
	#define inv(a,mod) my_pow((a),(mod-2),(mod))
	il ll read(){
		ll sum=0,f=1;
		char ch=0;
		while(!isdigit(ch)){
			if(ch=='-') f=-1;
			ch=getchar();
		}
		while(isdigit(ch)){
			sum=sum*10+(ch^48);
			ch=getchar();
		}
		return sum*f;
	}
	il void write(ll x){
		if(x<0){
			x=-x;
			pc('-');
		}
		if(x>9) write(x/10);
		pc(x%10+'0');
	}
	il void writeln(ll x){
		write(x);
		enter;
	}
	il void writesp(ll x){
		write(x);
		space;
	}
}
using namespace my_std;
#define mod 998244353
set<ll> s;
ll n,lsh[100010],cnt=0;
long long f[100010];
struct hash{
	#define MOD 10007
	ll head[10007],nxt[100010],to[100010],cnt=0;
	il void ins(ll x){
		nxt[++cnt]=head[x%MOD];
		to[cnt]=x;
		head[x%MOD]=cnt;
	}
	il bl query(ll x){
		for(ll i=head[x%MOD];i;i=nxt[i]) if(to[i]==x) return 1;
		return 0;
	}
}H;
int main(){
	n=read();
	H.ins(n+1);
	s.insert(n+1);
	fr(i,1,1){
		H.ins(i);
		s.insert(i);
	}
	while(!s.empty()){
		ll x=*(--s.end());
		s.erase(x);
		lsh[++cnt]=x;
		if(x<=1) continue;
		ll l=2,r;
		while(l<=min(x-1,20210926)){
			r=(x-1)/((x-1)/l);
			ll tmp=(x-1)/l+1;
			if(tmp<=1) break;
			if(!H.query(tmp)){
				H.ins(tmp);
				s.insert(tmp);
			}
			l=r+1;
		}
	}
	reverse(lsh+1,lsh+cnt+1);
	pfr(i,cnt-1,1){
		f[i]=1;
		ll l=2,r,lst=1;
		while(l<=20210926&&l*lsh[i]<=n){
			ll pos=upper_bound(lsh+lst,lsh+cnt+1,lsh[i]*l)-lsh-1;
			r=min(20210926,(lsh[pos+1]+lsh[i]-1)/lsh[i]-1);
			f[i]+=(r-l+1)*f[pos];
			l=r+1;
			lst=pos;
		}
	}
	write(f[1]%mod);
}

詳細信息

Test #1:

score: 100
Accepted
time: 0ms
memory: 3528kb

input:

1

output:

1

result:

ok 1 number(s): "1"

Test #2:

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

input:

2

output:

2

result:

ok 1 number(s): "2"

Test #3:

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

input:

100

output:

949

result:

ok 1 number(s): "949"

Test #4:

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

input:

10

output:

19

result:

ok 1 number(s): "19"

Test #5:

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

input:

1000

output:

48614

result:

ok 1 number(s): "48614"

Test #6:

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

input:

10000

output:

2602393

result:

ok 1 number(s): "2602393"

Test #7:

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

input:

100000

output:

139804054

result:

ok 1 number(s): "139804054"

Test #8:

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

input:

1000000

output:

521718285

result:

ok 1 number(s): "521718285"

Test #9:

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

input:

10000000

output:

503104917

result:

ok 1 number(s): "503104917"

Test #10:

score: 0
Accepted
time: 89ms
memory: 4884kb

input:

100000000

output:

198815604

result:

ok 1 number(s): "198815604"

Test #11:

score: 0
Accepted
time: 531ms
memory: 7788kb

input:

1000000000

output:

373787809

result:

ok 1 number(s): "373787809"

Test #12:

score: 0
Accepted
time: 537ms
memory: 7576kb

input:

999999999

output:

997616263

result:

ok 1 number(s): "997616263"

Test #13:

score: 0
Accepted
time: 523ms
memory: 7620kb

input:

999999990

output:

997615701

result:

ok 1 number(s): "997615701"

Test #14:

score: 0
Accepted
time: 531ms
memory: 7624kb

input:

999999900

output:

993928691

result:

ok 1 number(s): "993928691"

Test #15:

score: 0
Accepted
time: 528ms
memory: 7628kb

input:

999999000

output:

754532207

result:

ok 1 number(s): "754532207"

Test #16:

score: 0
Accepted
time: 531ms
memory: 7744kb

input:

999990000

output:

996592686

result:

ok 1 number(s): "996592686"

Test #17:

score: 0
Accepted
time: 527ms
memory: 7660kb

input:

999900000

output:

311678722

result:

ok 1 number(s): "311678722"

Test #18:

score: 0
Accepted
time: 535ms
memory: 7576kb

input:

999000000

output:

60462624

result:

ok 1 number(s): "60462624"

Test #19:

score: 0
Accepted
time: 540ms
memory: 7612kb

input:

990000000

output:

444576800

result:

ok 1 number(s): "444576800"

Test #20:

score: 0
Accepted
time: 488ms
memory: 7448kb

input:

900000000

output:

95615129

result:

ok 1 number(s): "95615129"

Test #21:

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

input:

1361956

output:

813433539

result:

ok 1 number(s): "813433539"

Test #22:

score: 0
Accepted
time: 11ms
memory: 3884kb

input:

7579013

output:

677659797

result:

ok 1 number(s): "677659797"

Test #23:

score: 0
Accepted
time: 16ms
memory: 3904kb

input:

8145517

output:

801509527

result:

ok 1 number(s): "801509527"

Test #24:

score: 0
Accepted
time: 9ms
memory: 3748kb

input:

6140463

output:

869023935

result:

ok 1 number(s): "869023935"

Test #25:

score: 0
Accepted
time: 9ms
memory: 3848kb

input:

3515281

output:

989091505

result:

ok 1 number(s): "989091505"

Test #26:

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

input:

6969586

output:

539840131

result:

ok 1 number(s): "539840131"