Nyoj 204 Coin Test "Simple question + English question"

Source: Internet
Author: User

Test instructions did not understand, there is no consideration of special circumstances 0, resulting in my contribution 7 times WA, thanks to Mau Mau reminder

Coin Test time limit: the Ms | Memory Limit:65535 KB Difficulty:1
Describe

As is known To all,if you throw a coin up and let it droped on the desk there is usually three results. Yes,just believe what I say ~it can is 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 on this. They repeat the throwing job once again. But Jacmy was a lazy boy. He is busy with dating or playing games. He has no time to throw a, coin for 100000 times. Here comes he idea,he just go bank and exchange thousands of dollars into coins and then throw in the desk only once . The only job left for him are to count the number of coins with three conditions.

He'll show you the coins on the desk-to-one by one. 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 this even 1/2,50/100,33/66 is equal only the IS accepted! If the difference between the result and 0.5 are larger than 0.003,please tell him "Fail". Or if you see one coin standing on the desk,just say ' Bingo ' any '.

Input
Three would be as input.
The first line is a number N (1<n<65536)
Telling the number of coins on the desk.
The second line was the result with N litters. The letter was "U", "D", or "S", "u" means the coin is in the right side. "D" means the coin is on the other side. " S "means standing on the desk.
Output
If test Successeded,just Output The possibility of the coin on the right side. If the test failed. Output "Fail", if there is one or more "S", please output "Bingo"
Sample input
6UUUDDD
Sample output
1/2
Source
Zhengzhou University School Competition Topic

#include <stdio.h> #include <math.h> #define MAXN 100000+10char arr[maxn];int i,len,a,b,c,n,t;int gcd (int A, int b) {return!b?a:gcd (b,a%b);} int main () {while (~SCANF ("%d", &n)) {GetChar (); scanf ("%s", arr); A=b=c=0;for (i=0;i<n;i++) {if (arr[i]== ' U ') a++; if (arr[i]== ' S ') c=1;} if (c==1) printf ("bingo\n"); else if (a==0) printf ("0\n"); else if (fabs (a*1.0/n) >0.503) printf ("fail\n"), ELSE{T=GCD (a,n);p rintf ("%d/%d\n", a/t,n/t);}} return 0;}        


Nyoj 204 Coin Test "Simple question + English question"

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.