首页 > 其他分享 >第一周 B - Die Roll

第一周 B - Die Roll

时间:2023-01-05 16:01:37浏览次数:45  
标签:Wakko 第一周 int Die will Yakko max Roll Dot

题目描述

Yakko, Wakko and Dot, world-famous animaniacs, decided to rest from acting in cartoons, and take a leave to travel a bit. Yakko dreamt to go to Pennsylvania, his Motherland and the Motherland of his ancestors. Wakko thought about Tasmania, its beaches, sun and sea. Dot chose Transylvania as the most mysterious and unpredictable place.

But to their great regret, the leave turned to be very short, so it will be enough to visit one of the three above named places. That's why Yakko, as the cleverest, came up with a truly genius idea: let each of the three roll an ordinary six-sided die, and the one with the highest amount of points will be the winner, and will take the other two to the place of his/her dreams.

Yakko thrown a die and got Y points, Wakko — W points. It was Dot's turn. But she didn't hurry. Dot wanted to know for sure what were her chances to visit Transylvania.

It is known that Yakko and Wakko are true gentlemen, that's why if they have the same amount of points with Dot, they will let Dot win.

Y W D三个要去旅游,三个人有各自想去的地方,于是投六面筛子决定,点数最大的胜利。若已知Y W的点数,求D胜利的概率。(若Y W的点数与D相同,作为绅士,他们会让D赢)

代码

#include <iostream>
using namespace std;

//最大公约数
int gcd(int n, int m) {
    if (m == 0) return n;
    else if (n % m == 0) return m;
    else return gcd(m, n % m);
}

int main(){
    int Y = 1, W = 1 ,D = 1;
    while(cin >> Y >> W){
        int max = 0;//比较器
        int i = 0;//概率计数器

        if(Y>=W) max = Y;
        else max = W;
        
        //统计可能赢的点数
        for(D = 1; D <= 6 ; D++){
            if(D >= max){
                i++;
            }
        }
        //约分
        cout << i/gcd(i,6) << "/" << 6/gcd(i,6) << endl;
    }
    return 0;
}

测试

标签:Wakko,第一周,int,Die,will,Yakko,max,Roll,Dot
From: https://www.cnblogs.com/Aquarius-CHEqijin/p/17027806.html

相关文章

  • UGUI之Scroll view
    Scrollview是一个方便制作滑动的组件。游戏里背包等经常用到的。效果如下:之前说过自己来制作滑动器的方法下面讲的是一个更为简单的方法:使用ScrollView组件。方法如下:1.首......
  • Unity3d碰撞器与触发器的区别详解(rigidbody移动和charactercontroller移动区别)
    Rigidbody或者charactercontroller移动才可以用collider的碰撞。正文:要产生碰撞必须为游戏对象添加刚体(Rigidbody)和碰撞器,刚体可以让物体在物理影响下运动。碰撞体是物理......
  • 找到多个与名为“default”的控制器匹配的类型。如果为此请求(“{controller}/{action
    找到多个与名为“default”的控制器匹配的类型。如果为此请求(“{controller}/{action}/{id}”)提供服务的路由没有指定命名空间以搜索与此请求相匹配的控制器,则会发生这种......
  • CodeForces 991C Candies(二分答案)
    CodeForces991CCandies(二分答案)http://codeforces.com/problemset/problem/991/C    题意:给出一个数n,表示有n块蛋糕,有两个人a,b。a每次可以取k块蛋糕(如果剩下......
  • HidController控件下载安装
    用Delphi或C++开发USB接口时要用到的HidController控件,如果你找不到去哪下载参考这里。下载地址:https://sourceforge.net/projects/jvcl/下载后解压里面两个文件夹......
  • vue3-seamless-scroll联合echarts时,无法产生两个chart问题
    最近需要用到el-table和echarts的滚动播放,在很多关于vue3和echarts的例子中都是这两种的://html<divref="refinstance">ref</div>//scriptletref=echarts.init(refin......
  • 第一周周报
    潘键颖2021002020092023/1/2本周总结:本周的前半周由于阳了比较难受一直在床上躺着基本没怎么训练。所以这周的训练只在后半周。后半周就是学习新内容,写一两道模板题然......
  • scrolls基准
    长文档数据集SCROLLS:StandardizedCompaRisonOverLongLanguageSequencesWhatisSCROLLS?SCROLLSisasuiteofdatasetsthatrequiresynthesizinginformatio......
  • java vop 打印controller的入参和出参
    packagecom.sleep.demo.intercepter;importcom.alibaba.fastjson.JSONObject;importlombok.extern.slf4j.Slf4j;importorg.apache.commons.lang3.ArrayUtils;imp......
  • CSS 平滑滚动 scroll-behavior: smooth
    凡是需要滚动的地方都加一句scroll-behavior:smooth来提升滚动体验!经常使用的锚点定位功能就有了平滑定位功能,如<ahref="#">返回顶部</a>全局css中也建议添加html,body......