The 11th Blue Bridge Cup Provincial Competition Group C Zhenti D: Combined Test

Test Question D: Combined Test
The total score of this question: 10 points
[Problem description] The
new crown epidemic is caused by the new crown virus and has spread in country A recently. In order to control the epidemic as soon as possible, country A is
preparing a large number of people for viral nucleic acid testing.
However, the test kit is in short supply.
In order to solve this difficulty, scientists thought of a way: combined testing. About
to put the specimens collected from multiple people (k ) into the same kit for testing. If the result is negative, it means that all k
persons are negative, and the test of k persons has been completed with one kit. If the result is positive, it means that
at least one person is positive, and all the samples of these k persons need to be tested independently again (theoretically,
if k 1 persons are negative before the test , it can be inferred that the kth person is positive, but in In actual operation,
this inference is not used, but k individuals are tested independently), plus the initial combined test, a total
of k + 1 kits have been used to complete the test of k individuals.
Country A estimates that the infection rate of the tested people is about 1%, which is evenly distributed. May I ask how much k can
save the most kit?
[Answer submission]
This is a result fill-in-the-blank question, you only need to calculate the result and submit it. The result of this question is an
integer. When submitting the answer, only fill in this integer. If you fill in the extra content, you will not be able to score.

//#define LOCK
#include<Stdio.h>
int dfs(int n)
{
    
    
	int cns=0;
	int s=100;
	cns=(s/n)+n;
	if(s/n!=n)
	{
    
    
		cns+=(s%n);
	}
	return cns;

}
int main()
{
    
    
   int a=0,min=100,xb=0;
   for(int i=1;i<=100;i++)
   {
    
    
   	a=dfs(i);
   	#ifdef LOCK
   	printf("一次采样%d人 一共需%d测试盒\n",a,i);
   	#endif
   	if(min>a)
   	   {
    
    
     	min=a;
        xb=i;
	   } 
	}
	printf("%d\n",xb);
	return 0;		
}

Guess you like

Origin blog.csdn.net/qq_46232829/article/details/107165269