QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#468783#7225. The Kirakira CycleinksamuraiWA 1247ms174976kbC++231.3kb2024-07-09 00:46:402024-07-09 00:46:41

Judging History

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

  • [2024-07-09 00:46:41]
  • 评测
  • 测评结果:WA
  • 用时:1247ms
  • 内存:174976kb
  • [2024-07-09 00:46:40]
  • 提交

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];
int 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;
		}
	}
	ll val=0;
	for(int i=1;i<=L;i++){
		val+=f[i];
		f[i]=val+(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);
}

详细

Test #1:

score: 100
Accepted
time: 57ms
memory: 122516kb

input:

2

output:

1

result:

ok 1 number(s): "1"

Test #2:

score: 0
Accepted
time: 129ms
memory: 122504kb

input:

10

output:

4

result:

ok 1 number(s): "4"

Test #3:

score: 0
Accepted
time: 327ms
memory: 122452kb

input:

43

output:

7

result:

ok 1 number(s): "7"

Test #4:

score: 0
Accepted
time: 48ms
memory: 122564kb

input:

1

output:

1

result:

ok 1 number(s): "1"

Test #5:

score: 0
Accepted
time: 74ms
memory: 122512kb

input:

3

output:

1

result:

ok 1 number(s): "1"

Test #6:

score: 0
Accepted
time: 66ms
memory: 122804kb

input:

4

output:

3

result:

ok 1 number(s): "3"

Test #7:

score: 0
Accepted
time: 86ms
memory: 122804kb

input:

5

output:

2

result:

ok 1 number(s): "2"

Test #8:

score: 0
Accepted
time: 84ms
memory: 122760kb

input:

6

output:

2

result:

ok 1 number(s): "2"

Test #9:

score: 0
Accepted
time: 102ms
memory: 122508kb

input:

7

output:

1

result:

ok 1 number(s): "1"

Test #10:

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

input:

8

output:

3

result:

ok 1 number(s): "3"

Test #11:

score: 0
Accepted
time: 110ms
memory: 126056kb

input:

9

output:

2

result:

ok 1 number(s): "2"

Test #12:

score: 0
Accepted
time: 140ms
memory: 124716kb

input:

11

output:

7

result:

ok 1 number(s): "7"

Test #13:

score: 0
Accepted
time: 155ms
memory: 126408kb

input:

13

output:

6

result:

ok 1 number(s): "6"

Test #14:

score: 0
Accepted
time: 193ms
memory: 124876kb

input:

17

output:

4

result:

ok 1 number(s): "4"

Test #15:

score: 0
Accepted
time: 202ms
memory: 125556kb

input:

19

output:

5

result:

ok 1 number(s): "5"

Test #16:

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

input:

23

output:

3

result:

ok 1 number(s): "3"

Test #17:

score: 0
Accepted
time: 273ms
memory: 124600kb

input:

29

output:

2

result:

ok 1 number(s): "2"

Test #18:

score: 0
Accepted
time: 277ms
memory: 124788kb

input:

31

output:

13

result:

ok 1 number(s): "13"

Test #19:

score: 0
Accepted
time: 301ms
memory: 126128kb

input:

37

output:

5

result:

ok 1 number(s): "5"

Test #20:

score: 0
Accepted
time: 315ms
memory: 124804kb

input:

41

output:

21

result:

ok 1 number(s): "21"

Test #21:

score: 0
Accepted
time: 378ms
memory: 126276kb

input:

60

output:

8

result:

ok 1 number(s): "8"

Test #22:

score: 0
Accepted
time: 464ms
memory: 124988kb

input:

100

output:

11

result:

ok 1 number(s): "11"

Test #23:

score: 0
Accepted
time: 495ms
memory: 126044kb

input:

105

output:

41

result:

ok 1 number(s): "41"

Test #24:

score: 0
Accepted
time: 526ms
memory: 125388kb

input:

128

output:

31

result:

ok 1 number(s): "31"

Test #25:

score: 0
Accepted
time: 518ms
memory: 126248kb

input:

130

output:

25

result:

ok 1 number(s): "25"

Test #26:

score: 0
Accepted
time: 623ms
memory: 125716kb

input:

256

output:

52

result:

ok 1 number(s): "52"

Test #27:

score: 0
Accepted
time: 630ms
memory: 125660kb

input:

290

output:

15

result:

ok 1 number(s): "15"

Test #28:

score: 0
Accepted
time: 710ms
memory: 126384kb

input:

455

output:

104

result:

ok 1 number(s): "104"

Test #29:

score: 0
Accepted
time: 701ms
memory: 126156kb

input:

512

output:

45

result:

ok 1 number(s): "45"

Test #30:

score: 0
Accepted
time: 785ms
memory: 125676kb

input:

777

output:

35

result:

ok 1 number(s): "35"

Test #31:

score: 0
Accepted
time: 758ms
memory: 125672kb

input:

707

output:

175

result:

ok 1 number(s): "175"

Test #32:

score: 0
Accepted
time: 718ms
memory: 124912kb

input:

449

output:

13

result:

ok 1 number(s): "13"

Test #33:

score: 0
Accepted
time: 717ms
memory: 124748kb

input:

573

output:

168

result:

ok 1 number(s): "168"

Test #34:

score: 0
Accepted
time: 791ms
memory: 125916kb

input:

858

output:

49

result:

ok 1 number(s): "49"

Test #35:

score: 0
Accepted
time: 606ms
memory: 125848kb

input:

230

output:

58

result:

ok 1 number(s): "58"

Test #36:

score: 0
Accepted
time: 810ms
memory: 128436kb

input:

972

output:

117

result:

ok 1 number(s): "117"

Test #37:

score: 0
Accepted
time: 803ms
memory: 125332kb

input:

844

output:

47

result:

ok 1 number(s): "47"

Test #38:

score: 0
Accepted
time: 721ms
memory: 124968kb

input:

378

output:

37

result:

ok 1 number(s): "37"

Test #39:

score: 0
Accepted
time: 734ms
memory: 126332kb

input:

423

output:

49

result:

ok 1 number(s): "49"

Test #40:

score: 0
Accepted
time: 585ms
memory: 125096kb

input:

209

output:

20

result:

ok 1 number(s): "20"

Test #41:

score: 0
Accepted
time: 1097ms
memory: 144760kb

input:

5645

output:

338

result:

ok 1 number(s): "338"

Test #42:

score: 0
Accepted
time: 930ms
memory: 128912kb

input:

2034

output:

249

result:

ok 1 number(s): "249"

Test #43:

score: 0
Accepted
time: 1095ms
memory: 149248kb

input:

6163

output:

206

result:

ok 1 number(s): "206"

Test #44:

score: 0
Accepted
time: 1104ms
memory: 149532kb

input:

6422

output:

346

result:

ok 1 number(s): "346"

Test #45:

score: 0
Accepted
time: 861ms
memory: 127284kb

input:

1550

output:

40

result:

ok 1 number(s): "40"

Test #46:

score: 0
Accepted
time: 1115ms
memory: 152292kb

input:

6940

output:

674

result:

ok 1 number(s): "674"

Test #47:

score: 0
Accepted
time: 900ms
memory: 128564kb

input:

2068

output:

157

result:

ok 1 number(s): "157"

Test #48:

score: 0
Accepted
time: 1065ms
memory: 147800kb

input:

6197

output:

594

result:

ok 1 number(s): "594"

Test #49:

score: 0
Accepted
time: 1074ms
memory: 150780kb

input:

6456

output:

913

result:

ok 1 number(s): "913"

Test #50:

score: 0
Accepted
time: 1141ms
memory: 165932kb

input:

8776

output:

423

result:

ok 1 number(s): "423"

Test #51:

score: 0
Accepted
time: 1018ms
memory: 135616kb

input:

3904

output:

281

result:

ok 1 number(s): "281"

Test #52:

score: 0
Accepted
time: 1020ms
memory: 137596kb

input:

4163

output:

230

result:

ok 1 number(s): "230"

Test #53:

score: 0
Accepted
time: 1035ms
memory: 139004kb

input:

4422

output:

631

result:

ok 1 number(s): "631"

Test #54:

score: 0
Accepted
time: 1056ms
memory: 139788kb

input:

4681

output:

95

result:

ok 1 number(s): "95"

Test #55:

score: 0
Accepted
time: 1148ms
memory: 166188kb

input:

8810

output:

835

result:

ok 1 number(s): "835"

Test #56:

score: 0
Accepted
time: 1022ms
memory: 135932kb

input:

3938

output:

350

result:

ok 1 number(s): "350"

Test #57:

score: 0
Accepted
time: 1152ms
memory: 169696kb

input:

9328

output:

373

result:

ok 1 number(s): "373"

Test #58:

score: 0
Accepted
time: 1033ms
memory: 138020kb

input:

4456

output:

932

result:

ok 1 number(s): "932"

Test #59:

score: 0
Accepted
time: 1036ms
memory: 140380kb

input:

4715

output:

476

result:

ok 1 number(s): "476"

Test #60:

score: 0
Accepted
time: 1113ms
memory: 157504kb

input:

7633

output:

591

result:

ok 1 number(s): "591"

Test #61:

score: 0
Accepted
time: 961ms
memory: 131180kb

input:

2762

output:

263

result:

ok 1 number(s): "263"

Test #62:

score: 0
Accepted
time: 1147ms
memory: 160832kb

input:

8152

output:

465

result:

ok 1 number(s): "465"

Test #63:

score: 0
Accepted
time: 1021ms
memory: 135748kb

input:

3280

output:

157

result:

ok 1 number(s): "157"

Test #64:

score: 0
Accepted
time: 1008ms
memory: 134004kb

input:

3539

output:

79

result:

ok 1 number(s): "79"

Test #65:

score: 0
Accepted
time: 1137ms
memory: 157816kb

input:

7668

output:

905

result:

ok 1 number(s): "905"

Test #66:

score: 0
Accepted
time: 1153ms
memory: 159072kb

input:

7927

output:

357

result:

ok 1 number(s): "357"

Test #67:

score: 0
Accepted
time: 1153ms
memory: 161976kb

input:

8186

output:

543

result:

ok 1 number(s): "543"

Test #68:

score: 0
Accepted
time: 991ms
memory: 134768kb

input:

3314

output:

306

result:

ok 1 number(s): "306"

Test #69:

score: 0
Accepted
time: 1024ms
memory: 134720kb

input:

3573

output:

69

result:

ok 1 number(s): "69"

Test #70:

score: 0
Accepted
time: 1120ms
memory: 153192kb

input:

6873

output:

667

result:

ok 1 number(s): "667"

Test #71:

score: 0
Accepted
time: 925ms
memory: 128788kb

input:

2001

output:

134

result:

ok 1 number(s): "134"

Test #72:

score: 0
Accepted
time: 1146ms
memory: 156392kb

input:

7391

output:

477

result:

ok 1 number(s): "477"

Test #73:

score: 0
Accepted
time: 976ms
memory: 129988kb

input:

2519

output:

267

result:

ok 1 number(s): "267"

Test #74:

score: 0
Accepted
time: 976ms
memory: 131308kb

input:

2778

output:

162

result:

ok 1 number(s): "162"

Test #75:

score: 0
Accepted
time: 1017ms
memory: 131996kb

input:

3037

output:

282

result:

ok 1 number(s): "282"

Test #76:

score: 0
Accepted
time: 1022ms
memory: 133320kb

input:

3296

output:

458

result:

ok 1 number(s): "458"

Test #77:

score: 0
Accepted
time: 1153ms
memory: 156960kb

input:

7426

output:

214

result:

ok 1 number(s): "214"

Test #78:

score: 0
Accepted
time: 963ms
memory: 130172kb

input:

2554

output:

102

result:

ok 1 number(s): "102"

Test #79:

score: 0
Accepted
time: 1147ms
memory: 160120kb

input:

7944

output:

283

result:

ok 1 number(s): "283"

Test #80:

score: 0
Accepted
time: 1108ms
memory: 149820kb

input:

6113

output:

121

result:

ok 1 number(s): "121"

Test #81:

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

input:

10000

output:

917

result:

ok 1 number(s): "917"

Test #82:

score: 0
Accepted
time: 1199ms
memory: 173576kb

input:

9999

output:

470

result:

ok 1 number(s): "470"

Test #83:

score: 0
Accepted
time: 1207ms
memory: 174144kb

input:

9998

output:

1552

result:

ok 1 number(s): "1552"

Test #84:

score: 0
Accepted
time: 1215ms
memory: 174716kb

input:

9997

output:

538

result:

ok 1 number(s): "538"

Test #85:

score: 0
Accepted
time: 1218ms
memory: 174080kb

input:

9996

output:

193

result:

ok 1 number(s): "193"

Test #86:

score: 0
Accepted
time: 1212ms
memory: 174540kb

input:

9995

output:

624

result:

ok 1 number(s): "624"

Test #87:

score: 0
Accepted
time: 1185ms
memory: 173832kb

input:

9994

output:

481

result:

ok 1 number(s): "481"

Test #88:

score: 0
Accepted
time: 1192ms
memory: 173552kb

input:

9993

output:

617

result:

ok 1 number(s): "617"

Test #89:

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

input:

9992

output:

433

result:

ok 1 number(s): "433"

Test #90:

score: 0
Accepted
time: 1217ms
memory: 173652kb

input:

9991

output:

425

result:

ok 1 number(s): "425"

Test #91:

score: 0
Accepted
time: 1185ms
memory: 174976kb

input:

9990

output:

509

result:

ok 1 number(s): "509"

Test #92:

score: 0
Accepted
time: 1237ms
memory: 174740kb

input:

9989

output:

808

result:

ok 1 number(s): "808"

Test #93:

score: 0
Accepted
time: 1219ms
memory: 173716kb

input:

9988

output:

734

result:

ok 1 number(s): "734"

Test #94:

score: 0
Accepted
time: 1229ms
memory: 174192kb

input:

9987

output:

922

result:

ok 1 number(s): "922"

Test #95:

score: 0
Accepted
time: 1247ms
memory: 174040kb

input:

9986

output:

1252

result:

ok 1 number(s): "1252"

Test #96:

score: 0
Accepted
time: 1238ms
memory: 174692kb

input:

9985

output:

378

result:

ok 1 number(s): "378"

Test #97:

score: 0
Accepted
time: 1240ms
memory: 173524kb

input:

9984

output:

472

result:

ok 1 number(s): "472"

Test #98:

score: 0
Accepted
time: 1233ms
memory: 173852kb

input:

9983

output:

363

result:

ok 1 number(s): "363"

Test #99:

score: 0
Accepted
time: 1204ms
memory: 174340kb

input:

9982

output:

1121

result:

ok 1 number(s): "1121"

Test #100:

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

input:

9981

output:

261

result:

ok 1 number(s): "261"

Test #101:

score: 0
Accepted
time: 1204ms
memory: 174124kb

input:

9980

output:

228

result:

ok 1 number(s): "228"

Test #102:

score: -100
Wrong Answer
time: 918ms
memory: 128212kb

input:

1811

output:

1

result:

wrong answer 1st numbers differ - expected: '2', found: '1'