sicily 6767. Making Decisions
模拟赛第一题,捡分题……
Description
In the olden days making decisions was easy. One would get a daisy and start to pluck its petals alternating between Do-it and Do-it-Not until the last petal was reached and a decision was made.
Gadget-man wants to use a computerised version. The idea is to work with a random string of zeros and ones. He will pick up two bits, one from each end of the string, and compare them. If they are the same (that is, both ones or both zeros), then it is Do-it. If they differ, then it is Do-it-Not. The two bits are then discarded and the process is repeated on the remaining string until all the bits are picked. The last two bits to be picked will be the decision maker. By the way, the string may be random but it always contains an even number of bits that is greater than zero.
Your task is to write a program that reads a string of zeros and ones and makes the decision for Gadget-man.
Input
The input starts with an integer N, on a line by itself, that represents the number of test cases. 1 <= N <= 1000. The description for each test case consists of a string of zeros and ones. There are no blank spaces separating the bits.
Output
The output consists of a single line, for each test case, which contains a string Do-it or a string Do-it-Not.
1 #include<stdio.h> 2 int main() 3 { 4 double x, y; 5 double min; 6 int n; 7 8 scanf("%lf %lf", &x, &y); 9 min = x / y; 10 11 scanf("%d", &n); 12 13 while(n--) 14 { 15 scanf("%lf %lf", &x, &y); 16 if( x/y < min ) 17 { 18 min = x/y; 19 } 20 } 21 22 printf("%.2lf\n", min*1000); 23 24 return 0; 25 }