Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

二分查找

Posted by maedaqu at 2022-02-17 00:50:11 on Problem 1003
framework: https://github.com/chu-mirror/probs

@[data@]
float lengths[MAXSIZE];
@

@[macros@]
#define KEY(p) (lengths[p])
#define KEYTYPE float
@

@[main@]
@{initialize lengths@}
while (1) {
	@{read and handle input@}
}
@

@[read and handle input@]
{ float f;
	scanf("%f", &f);
	if (f == 0.0) break;
	printf("%d card(s)\n", bisearch_range(f)+1);
}
@

@[initialize lengths@]
{ int i;
	append(0); /* add lengths[0] = 0 to collection */
	for (i = 1; i < 34000; i++) {
		lengths[i] = lengths[i-1] + 1.0/(i+1);
		append(i);
	}
}
@

@[samples@]
===
1.00
3.71
0.04
5.19
0.00
>>>
3 card(s)
61 card(s)
1 card(s)
273 card(s)
@

Followed by:

Post your reply here:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator