当前位置: 首页 > news >正文

P1166 打保龄球

共可以投 1 局
一局10轮
    在一局中,一共有十个柱,会出现很多种情况。
第1次把10个
   打倒全部   >>
       分数=10+后2次得分 --若是第10轮则还需另加两次滚球;

   没全部打倒 >>
       第2次把剩下的
           打倒   >>
               分数=10+后1次得分
       没全部打倒 >> 
           完蛋/没救了 >>
               分数=共打得分

#include<bits/stdc++.h>
using namespace std;
#define long long long long
inline long long read()
{
    long long x=0;
    char ch=getchar();
    bool f=0;
    for(; !isdigit(ch); ch=getchar()) if(ch=='-') f=1;
    for(; isdigit(ch); ch=getchar()) x=x*10+ch-'0';
    return f?-x:x;
}
void write(long long x)
{
    if(x<0) putchar('-'),x=-x;
    if(x>=10) write(x/10);
    putchar(x%10+'0');
}
void writeln(long long x)
{
    write(x);
    puts("");
}
void writep(long long x)
{
    write(x);
    putchar(' ');
}
int n,cnt,ans,sum[13];
char a[103];
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);cout.tie(0);
    while(cin>>a[++n]);
    int st=1;
    for(int i=1; i<=10; i++)
    {
        int rest=10,flag=1;
        for(int j=st; j<=st+2; j++)
        {
            if(j>n)
            {
                sum[i]=-1;
                break;
            }
            if(rest==0) rest=10,flag=0;
            if(j==st+2 && flag) break;
            if(a[j]=='/') sum[i]+=rest,rest=0;
            else if(a[j]>='0' && a[j]<='9') sum[i]+=a[j]-'0',rest-=a[j]-'0';
        }
        if(sum[i]==-1) break;
        if(a[st]=='/') st++;
        else st+=2;
        writep(sum[i]);
    }
    puts("");
    for(int i=1; i<=10; i++)
    {
        if(sum[i]==-1) break;
        ans+=sum[i];
        writep(ans);
    }
    return 0;
}
 

#include<bits/stdc++.h>
using namespace std;
#define long long long long
inline long long read()
{long long x=0;char ch=getchar();bool f=0;for(; !isdigit(ch); ch=getchar()) if(ch=='-') f=1;for(; isdigit(ch); ch=getchar()) x=x*10+ch-'0';return f?-x:x;
}
void write(long long x)
{if(x<0) putchar('-'),x=-x;if(x>=10) write(x/10);putchar(x%10+'0');
}
void writeln(long long x)
{write(x);puts("");
}
void writep(long long x)
{write(x);putchar(' ');
}
int n,cnt,ans,sum[13];
char a[103];
int main()
{ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);while(cin>>a[++n]);int st=1;for(int i=1; i<=10; i++){int rest=10,flag=1;for(int j=st; j<=st+2; j++){if(j>n){sum[i]=-1;break;}if(rest==0) rest=10,flag=0;if(j==st+2 && flag) break;if(a[j]=='/') sum[i]+=rest,rest=0;else if(a[j]>='0' && a[j]<='9') sum[i]+=a[j]-'0',rest-=a[j]-'0';}if(sum[i]==-1) break;if(a[st]=='/') st++;else st+=2;writep(sum[i]);}puts("");for(int i=1; i<=10; i++){if(sum[i]==-1) break;ans+=sum[i];writep(ans);}return 0;
}

http://www.lryc.cn/news/431738.html

相关文章:

  • [数据集][目标检测]西红柿成熟度检测数据集VOC+YOLO格式3241张5类别
  • 数仓工具—Hive语法之URL 函数
  • c#如何实现触发另外一个文本框的回车事件
  • Vue 中 nextTick 的最主要作用是什么,为什么要有这个 API
  • python科学计算:NumPy 数组的运算
  • SAP B1 基础实操 - 用户定义字段 (UDF)
  • Idea发布springboot项目无法识别到webapp下面的静态资源
  • Redis及其他缓存
  • golang入门
  • Behind the Code:与 Rakic 和 Todorovic 对话 OriginTrail 如何实现 AI 去中心化
  • TS 学习 (持续更新中)
  • el-table使用type=“expand”根据数据条件隐藏展开按钮
  • 9月6日(∠・ω<)⌒☆
  • k8s执行crictl images报错
  • 基于人工智能的音乐情感分类系统
  • MySQL灾难恢复策略:构建稳健的备份与恢复机制
  • docker安装DVWA(巨简单)
  • 使用matplotlab绘制多条形图
  • 五、Selenium操作指南(二)
  • Peewee+Postgresql+PooledPostgresqlDatabase重连机制
  • IIS 反向代理模块: URL Rewrite 和 Application Request Routing (ARR)
  • 企业在选择CRM系统时需要注意哪些问题呼叫系统外呼系统部署搭建
  • 数据库水平分表方案
  • MySQL表操作及约束
  • Redis 键值对操作全攻略
  • 【C语言】---- return的作用
  • 如何制作新生资料收集系统?
  • pyecharts可视化数据大屏
  • uniapp - H5 在 UC 浏览器中返回上一页失效的解决方案
  • 利用KMeans重新计算自己数据集的anchor