zoukankan      html  css  js  c++  java
  • URAL 2078 Bowling game

    题目:    

               Bowling game

    In all asocial teams members ignore each other uniformly, each tight-knit team builds up team spirit their own way. Olya, Egor and Oleg, for example, go play bowling. This story is about how they once decided to take their coach Denis with them for the first time.
    Denis is not used to close-knit teams and primitive fun, so he was not in favor of rolling balls. So when it came out that the device counting points near the lane was out of service, he willingly volunteered to perform the counting on a sheet of paper.
    "What can be easier?", he thought, "One just needs to write down how many pins the player knocks down in each round. I can think out a couple of problems for the next training session simultaneously".
    He has never been so wrong! At the end of the game it appeared that the scoring rules in bowling are not nearly just summing up knocked down pins, moreover, it came out that points cannot be restored from the number of knocked down pins. Oleg, Olya and Egor started to explain the rules of the game talking over each other: strikes, spares, extra roll in the last round... Denis nodded and thought: "Well, a decent problem we have here". He suggested the team calculating minimum and maximum points that can be scored by a player. It’s needless to say that Egor, Oleg and Olya completed this task easily. Now it’s your turn.
    Here are the scoring rules in bowling.
    1. The game includes 10 frames (rounds), in each frame one can earn up to 30 points.
    2. In each frame, excluding the last one, the aim is to knock down 10 pins with two rolls. If all pins are knocked down with the first roll, the second roll is omitted.
    3. In the last frame one must initially knock down 10 pins with two rolls as well. If the player succeeds, (s)he gets an extra (third) roll. All available rolls must be used, that is, if all pins have been knocked down and there are rolls left, new 10 pins are put. These 10 pins, if knocked down, do not give extra rolls.
    4. Each knocked down pin gives one point.
    5. If a strike is made (all pins knocked down with one roll) in each frame excluding the last one, the player receives one extra point per each pin knocked down in two subsequent rolls when scoring that frame.
    6. If a spare is made (all pins knocked down with two rolls) in each frame excluding the last one, the player receives one extra point per each pin knocked down in one subsequent roll when scoring that frame.

    Input

    A single line contains 10 numbers separated by space — number of pins knocked down by the player in each of 10 frames. The first nine can take values from 0 to 10, the last one — from 0 to 30.

    Output

    Output minimum and maximum points a player could earn based on the game described in the input, separated by space.

    Example

    inputoutput
    10 2 4 8 3 8 1 9 8 7
    
    60 62
    
    2 4 6 8 10 10 8 6 4 2
    
    60 86

    思路:被题意hack,总是少看了点东西。

      求最小时均认为第二球得分,0 10 0 10的得分就可以避免分数加倍,

      最大时认为第一球得分,如10 8 0 6 0

      最后特判下第十个得分就可以了

     1 #include <bits/stdc++.h>
     2 
     3 using namespace std;
     4 
     5 #define MP make_pair
     6 #define PB push_back
     7 typedef long long LL;
     8 typedef pair<int,int> PII;
     9 const double eps=1e-8;
    10 const double pi=acos(-1.0);
    11 const int K=1e6+7;
    12 const int mod=1e9+7;
    13 
    14 
    15 int n,v[40],mx,mi;
    16 
    17 int main(void)
    18 {
    19     for(int i=1;i<=10;i++)
    20     {
    21         cin>>v[i];
    22         if(i!=10)   mi+=v[i],mx+=v[i];
    23         if(i!=10&&i-2>0&&v[i-2]==10&&v[i-1]==10) mx+=v[i];
    24         if(i!=10&&i-1>0&&v[i-1]==10) mx+=v[i];
    25     }
    26     if(v[10]<=10)
    27     {
    28         mi+=v[10],mx+=v[10];
    29         if(v[8]==v[9]&&v[9]==10)mx+=v[10];
    30         if(v[9]==10)mx+=v[10];
    31     }
    32     else
    33     {
    34         if(v[10]<=20)
    35         {
    36             if(v[8]==v[9]&&v[9]==10)mx+=30+(v[10]-10)*2;
    37             else if(v[9]==10)   mx+=20+(v[10]-10)*2;
    38             else    mx+=v[10];
    39         }
    40         else
    41         {
    42             if(v[8]==v[9]&&v[9]==10)mx+=50+v[10]-20;
    43             else if(v[9]==10)   mx+=40+v[10]-20;
    44             else    mx+=v[10];
    45         }
    46         if(v[9]==10)
    47         {
    48             if(v[10]<=20)
    49                 mi+=v[10];
    50             else
    51                 mi+=10+v[10];
    52         }
    53         else
    54             mi+=v[10];
    55     }
    56 
    57     cout<<mi<<" "<<mx<<endl;
    58     return 0;
    59 }

     

  • 相关阅读:
    ubuntu配置服务器环境
    discuz安装与学习资料
    前端面试题总结(一)
    css公共样式,初始化
    js的解析--预处理(三)
    sass的安装与基础
    移动开发学习笔记(一) 移动开发的注意事项
    移动前端一些常用的框架
    JavaScript的构造器与对象(二)
    JavaScript 中的Object的使用详解笔记(一)
  • 原文地址:https://www.cnblogs.com/weeping/p/6375095.html
Copyright © 2011-2022 走看看