QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#468777#7225. The Kirakira CycleinksamuraiML 1257ms245440kbC++231.3kb2024-07-09 00:41:252024-07-09 00:41:26

Judging History

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

  • [2024-07-09 00:41:26]
  • 评测
  • 测评结果:ML
  • 用时:1257ms
  • 内存:245440kb
  • [2024-07-09 00:41:25]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define rng(i,c,n) for(int i=c;i<n;i++)
#define fi first
#define se second
#define pb push_back
#define sz(a) (int) a.size()
#define all(a) a.begin(),a.end()
#define vec(...) vector<__VA_ARGS__>
#define _3zlqvu8 ios::sync_with_stdio(0),cin.tie(0)
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pii;
void print(){cout<<'\n';}
template<class h,class...t>
void print(const h&v,const t&...u){cout<<v<<' ',print(u...);}

const int L=30399200;

bitset<L> usd;
int qs[L+11];
long f[L+11];

const int L1=5e4;

void slv(int n){
	for(int i=1;i<=n;i++){
		for(int x=i;x<=L;x+=i){
			f[x]-=x;
			if(x+i<=L) f[x+i]+=x;
		}
	}
	for(int i=1;i<=L;i++){
		f[i]+=f[i-1];
	}
	for(int i=1;i<=L;i++){
		f[i]+=(1ll)*i*n;
	}
	int ans=0;
	rng(a,1,L1+1){
		if(qs[a]) continue;
		vi delay;
		int x=a,step=1;
		while(1){
		    if(x>L) break;
			if(qs[x]){
				if(usd[x]) ans=max(ans,step-qs[x]);
				break;
			}
			delay.pb(x);
			usd[x]=1;
			qs[x]=step;
			x=f[x];
			step+=1;
		}
		for(auto x:delay) usd[x]=0;
	}
	cout<<ans<<"\n";
}

signed main(){
_3zlqvu8;
	// for(int n=1;n<=20;n++)
	// {
	// 	slv(100);
	// 	rep(i,L) usd[i]=qs[i]=f[i]=0;
	// }
	int n;
	cin>>n;
	slv(n);
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 92ms
memory: 243368kb

input:

2

output:

1

result:

ok 1 number(s): "1"

Test #2:

score: 0
Accepted
time: 238ms
memory: 243288kb

input:

10

output:

4

result:

ok 1 number(s): "4"

Test #3:

score: 0
Accepted
time: 522ms
memory: 243600kb

input:

43

output:

7

result:

ok 1 number(s): "7"

Test #4:

score: 0
Accepted
time: 63ms
memory: 243300kb

input:

1

output:

1

result:

ok 1 number(s): "1"

Test #5:

score: 0
Accepted
time: 128ms
memory: 243296kb

input:

3

output:

1

result:

ok 1 number(s): "1"

Test #6:

score: 0
Accepted
time: 144ms
memory: 243556kb

input:

4

output:

3

result:

ok 1 number(s): "3"

Test #7:

score: 0
Accepted
time: 163ms
memory: 243296kb

input:

5

output:

2

result:

ok 1 number(s): "2"

Test #8:

score: 0
Accepted
time: 186ms
memory: 243292kb

input:

6

output:

2

result:

ok 1 number(s): "2"

Test #9:

score: 0
Accepted
time: 180ms
memory: 243292kb

input:

7

output:

1

result:

ok 1 number(s): "1"

Test #10:

score: 0
Accepted
time: 222ms
memory: 243356kb

input:

8

output:

3

result:

ok 1 number(s): "3"

Test #11:

score: 0
Accepted
time: 245ms
memory: 243292kb

input:

9

output:

2

result:

ok 1 number(s): "2"

Test #12:

score: 0
Accepted
time: 262ms
memory: 243520kb

input:

11

output:

7

result:

ok 1 number(s): "7"

Test #13:

score: 0
Accepted
time: 294ms
memory: 243584kb

input:

13

output:

6

result:

ok 1 number(s): "6"

Test #14:

score: 0
Accepted
time: 353ms
memory: 243296kb

input:

17

output:

4

result:

ok 1 number(s): "4"

Test #15:

score: 0
Accepted
time: 370ms
memory: 243392kb

input:

19

output:

5

result:

ok 1 number(s): "5"

Test #16:

score: 0
Accepted
time: 413ms
memory: 243344kb

input:

23

output:

3

result:

ok 1 number(s): "3"

Test #17:

score: 0
Accepted
time: 452ms
memory: 243364kb

input:

29

output:

2

result:

ok 1 number(s): "2"

Test #18:

score: 0
Accepted
time: 470ms
memory: 243296kb

input:

31

output:

13

result:

ok 1 number(s): "13"

Test #19:

score: 0
Accepted
time: 494ms
memory: 243300kb

input:

37

output:

5

result:

ok 1 number(s): "5"

Test #20:

score: 0
Accepted
time: 510ms
memory: 243360kb

input:

41

output:

21

result:

ok 1 number(s): "21"

Test #21:

score: 0
Accepted
time: 601ms
memory: 243364kb

input:

60

output:

8

result:

ok 1 number(s): "8"

Test #22:

score: 0
Accepted
time: 716ms
memory: 245440kb

input:

100

output:

11

result:

ok 1 number(s): "11"

Test #23:

score: 0
Accepted
time: 723ms
memory: 243392kb

input:

105

output:

41

result:

ok 1 number(s): "41"

Test #24:

score: 0
Accepted
time: 759ms
memory: 243292kb

input:

128

output:

31

result:

ok 1 number(s): "31"

Test #25:

score: 0
Accepted
time: 767ms
memory: 243292kb

input:

130

output:

25

result:

ok 1 number(s): "25"

Test #26:

score: 0
Accepted
time: 899ms
memory: 243524kb

input:

256

output:

52

result:

ok 1 number(s): "52"

Test #27:

score: 0
Accepted
time: 915ms
memory: 243328kb

input:

290

output:

15

result:

ok 1 number(s): "15"

Test #28:

score: 0
Accepted
time: 1028ms
memory: 243412kb

input:

455

output:

104

result:

ok 1 number(s): "104"

Test #29:

score: 0
Accepted
time: 1041ms
memory: 243408kb

input:

512

output:

45

result:

ok 1 number(s): "45"

Test #30:

score: 0
Accepted
time: 1205ms
memory: 244048kb

input:

777

output:

35

result:

ok 1 number(s): "35"

Test #31:

score: 0
Accepted
time: 1169ms
memory: 243700kb

input:

707

output:

175

result:

ok 1 number(s): "175"

Test #32:

score: 0
Accepted
time: 1007ms
memory: 243400kb

input:

449

output:

13

result:

ok 1 number(s): "13"

Test #33:

score: 0
Accepted
time: 1077ms
memory: 243552kb

input:

573

output:

168

result:

ok 1 number(s): "168"

Test #34:

score: 0
Accepted
time: 1208ms
memory: 244044kb

input:

858

output:

49

result:

ok 1 number(s): "49"

Test #35:

score: 0
Accepted
time: 865ms
memory: 243292kb

input:

230

output:

58

result:

ok 1 number(s): "58"

Test #36:

score: 0
Accepted
time: 1257ms
memory: 244220kb

input:

972

output:

117

result:

ok 1 number(s): "117"

Test #37:

score: 0
Accepted
time: 1200ms
memory: 244008kb

input:

844

output:

47

result:

ok 1 number(s): "47"

Test #38:

score: 0
Accepted
time: 964ms
memory: 243592kb

input:

378

output:

37

result:

ok 1 number(s): "37"

Test #39:

score: 0
Accepted
time: 1010ms
memory: 243340kb

input:

423

output:

49

result:

ok 1 number(s): "49"

Test #40:

score: 0
Accepted
time: 862ms
memory: 243352kb

input:

209

output:

20

result:

ok 1 number(s): "20"

Test #41:

score: -100
Memory Limit Exceeded

input:

5645

output:

338

result: