日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

A Greeting from Qinhuangdao Gym - 102769A 2020ccpc秦皇岛分站赛

發布時間:2023/12/4 编程问答 25 豆豆
生活随笔 收集整理的這篇文章主要介紹了 A Greeting from Qinhuangdao Gym - 102769A 2020ccpc秦皇岛分站赛 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

題意:

給你n個紅球和m個藍色球。然后以相等的概率隨機選擇了其中兩個。選擇兩個紅球的概率是多少?

題目:

Welcome to the CCPC Qinhuangdao Site!

Qinhuangdao is a beautiful coastal city full of charm, integrating historical heritage and modern civilization. It was named after the Emperor QinShiHuang’s east tour in 215 BC for seeking immortals.

The infiltration of more than 2000 years of history has left a rich cultural treasure here. Bo Yi, Shu Qi, Qi Jiguang, Cao Cao, and Mao Zedong, Many Heroes throughout the ages have endowed Qinhuangdao with the thousand-year cultural context, the unique and precious heritage, and the profound historical memory.

Pleasant natural scenery has shaped her beautiful appearance. Thousands of miles of Yan Mountains, the Great Wall, and the vast seas are miraculously met here. The blue sky, green land, blue sea, and golden sand gather together to welcome guests.

To toast your arrival, Alex prepared a simple problem to help you warm up.

Alex has red balls and blue balls. Then, Alex randomly chose two of these balls with equal probability. What is the probability that he chose two red balls?

Output the required probability in the form of irreducible fraction.

Input

The first line of input gives the number of test cases, . test cases follow.

For each test case, the only line contains two integers , where is the number of red balls and is the number of blue balls.

Output

For each test case, output one line containing “Case #x: y”, where is the test case number (starting from ), and is the answer in the form of irreducible fraction in format A/B.

If the required probability equals to zero, output 0/1. If the required probability equals to , output 1/1.

Example

Input

3
1 1
2 1
8 8

Output

Case #1: 0/1
Case #2: 1/3
Case #3: 7/30

分析:

1.注意審題,在紅球數量小于2時,既不可能存在取兩個紅球的情況下直接輸出0/1;
2.歐幾里得算法。

AC代碼:

#include<stdio.h> #include<string.h> #include<algorithm> using namespace std; int t,n,m,k,a,b; int gcd(int a,int b) {return b==0?a:gcd(b,a%b); } int main() {k=1;scanf("%d",&t);while(t--){scanf("%d%d",&n,&m);printf("Case #%d: ",k++);if(n<2)printf("0/1\n");else{a=n*(n-1);b=(n+m)*(n+m-1);printf("%d/%d\n",a/gcd(a,b),b/gcd(a,b));}}return 0; }

總結

以上是生活随笔為你收集整理的A Greeting from Qinhuangdao Gym - 102769A 2020ccpc秦皇岛分站赛的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。