zoukankan      html  css  js  c++  java
  • coin test。。。。nyoj--204

    Coin Test
    时间限制:3000 ms  |  内存限制:65535 KB
    难度:1
     
    描述

    As is known to all,if you throw a coin up and let it droped on the desk there are usually three results. Yes,just believe what I say ~it can be the right side or the other side or standing on the desk, If you don't believe this,just try In the past there were some famous mathematicians working on this .They repeat the throwing job once again. But jacmy is a lazy boy.He is busy with dating or playing games.He have no time to throw a single coin for 100000 times. Here comes his idea,He just go bank and exchange thousands of dollars into coins and then throw then on the desk only once. The only job left for him is to count the number of coins with three conditions.

    He will show you the coins on the desk to you one by one. Please tell him the possiblility of the coin on the right side as a fractional number if the possiblity between the result and 0.5 is no larger than 0.003. BE CAREFUL that even 1/2,50/100,33/66 are equal only 1/2 is accepted ! if the difference between the result and 0.5 is larger than 0.003,Please tell him "Fail".Or if you see one coin standing on the desk,just say "Bingo" any way.

     
    输入
    Three will be two line as input.
    The first line is a number N(1<N<65536)
    telling you the number of coins on the desk.
    The second line is the result with N litters.The letter are "U","D",or "S","U" means the coin is on the right side. "D" means the coin is on the other side ."S" means standing on the desk.
    输出
    If test successeded,just output the possibility of the coin on the right side.If the test failed please output "Fail",If there is one or more"S",please output "Bingo"
    样例输入
    6
    UUUDDD
    样例输出
    1/2
    
    来源
    郑州大学校赛题目
    上传者
    张云聪
     
     1 #include<stdio.h>
     2 double g(int u,int v)/* 第一坑   分数化简  先要求其公约数*/
     3 {
     4     int r;
     5 
     6         while(v!=0)
     7         {
     8             r=u%v;
     9             u=v;
    10             v=r;
    11         }
    12     return u;
    13 }
    14 
    15 int main()//坑爹的水题啊。。。。。
    16 {
    17     int N,i,n;
    18     char ss[65538];
    19     double s,m,t;
    20     scanf("%d",&N);
    21     getchar();/*注意输入字符前要吸收 Enter */
    22     for(i=0;i<N;i++)
    23     scanf("%c",&ss[i]);
    24     for(n=0,m=0,i=0;i<N;i++)
    25     {
    26     if(ss[i]=='U') m++;
    27     if(ss[i]=='S') n++;
    28     }
    29      t=g(m,N);/*求最大公约数*/
    30     s=(double)m/N;/*第二坑  数据类型。。。int/int结果依然是int,强制转换数据类型*/
    31     if(n>0)   printf("Bingo");
    32     else if(s-0.5==0) printf("%.lf/%.lf",m/t,N/t);/*第三坑  注意数据输出的类型,并且需要化简分数*/
    33     else if(s-0.5<0.003&&s-0.005>-0.003||s-0.5==0.003)/*注意小细节,判断范围保证-0.003<s-0.5<=0.003。。。*/
    34     printf("%.lf/%.lf",m/t,N/t);
    35     else printf("Fail");
    36     printf("
    ");
    37     return 0;
    38 
    39 }
    View Code

    三个小时奋战的结果。。。细节问题???还是基础问题???好好纠结啊。。。。

    一切尽在不言中啦。。。。。。。

  • 相关阅读:
    Oracle 备份与恢复 15 个典型问题
    Oracle Rman 增量备份与差异备份
    Oracle top 查询TOP SQL
    Oracle 将另外一张表的列更新到本表的列
    Mysql Innodb 表碎片整理
    python Django 之 Model ORM inspectdb(数据库表反向生成)
    MySQL 5.6比较重要的参数,以及5.5到5.6默认值有过变化的参数
    Python Django 前后端数据交互 之 HttpRequest、HttpResponse、render、redirect
    HTML(一)基础
    Python Django 前后端数据交互 之 HTTP协议下GET与POST的区别
  • 原文地址:https://www.cnblogs.com/xiaoyunoo/p/3183583.html
Copyright © 2011-2022 走看看