zoukankan      html  css  js  c++  java
  • 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.

    View Code
     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 }
  • 相关阅读:
    用mapreduce 处理气象数据集
    熟悉常用的HBase操作,编写MapReduce作业
    爬虫大作业
    第三章 熟悉常用的HDFS操作
    数据结构化与保存
    获取全部校园新闻
    爬取校园新闻首页的新闻的详情,使用正则表达式,函数抽离
    网络爬虫基础练习
    Hadoop综合大作业
    理解MapReduce
  • 原文地址:https://www.cnblogs.com/joyeecheung/p/2813727.html
Copyright © 2011-2022 走看看