PAT (Basic Level) Practice (中文)1016 部分A+B (15 分)
正整数 A 的“DA(为 1 位整数)部分”定义为由 A 中所有 DA 组成的新整数 PA。例如:给定 8,DA=6,则 A 的“6 部分”PA 是 66,因为 A 中有 2 个 6。
现给定 A、DA、B、DB,请编写程序计算 PA+PB。
输入格式:
输入在一行中依次给出 A、DA、B、DB,中间以空格分隔,其中 0。
输出格式:
在一行中输出 PA+PB 的值。
输入样例 1:
3862767 6 13530293 3
输出样例 1:
399
输入样例 2:
3862767 1 13530293 8
输出样例 2:
0
#include <iostream>
#include <algorithm>
#include <string>
#include <cstring>
using namespace std;
string a,b;
int n,m;
int main()
{
while(cin>>a>>m>>b>>n){
int cnt1=,cnt2=;
for(int i=;i<a.length();i++){
if((a[i]-'')==m){
cnt1++;
}
}
for(int i=;i<b.length();i++){
if((b[i]-'')==n){
cnt2++;
}
}
int sum=;
int t=;
for(int i=;i<=cnt1;i++){
sum+=m*t;
t*=;
}
//cout<<sum<<endl;
t=;
for(int i=;i<=cnt2;i++){
sum+=n*t;
t*=;
}
cout<<sum<<endl;
}
return ;
}
PAT (Basic Level) Practice (中文)1016 部分A+B (15 分)的更多相关文章
- PAT (Basic Level) Practice (中文)1078 字符串压缩与解压 (20 分) 凌宸1642
PAT (Basic Level) Practice (中文)1078 字符串压缩与解压 (20 分) 凌宸1642 题目描述: 文本压缩有很多种方法,这里我们只考虑最简单的一种:把由相同字符组成的一 ...
- PAT (Basic Level) Practice (中文)1070 结绳 (25 分) 凌宸1642
PAT (Basic Level) Practice (中文)1070 结绳 (25 分) 凌宸1642 题目描述 给定一段一段的绳子,你需要把它们串成一条绳.每次串连的时候,是把两段绳子对折,再如下 ...
- PAT (Basic Level) Practice (中文)1065 单身狗 (25 分) 凌宸1642
PAT (Basic Level) Practice (中文)1065 单身狗 (25 分) 凌宸1642 题目描述: "单身狗"是中文对于单身人士的一种爱称.本题请你从上万人的大 ...
- PAT (Basic Level) Practice (中文)1055 集体照 (25 分) 凌宸1642
PAT (Basic Level) Practice (中文)1055 集体照 (25 分) 凌宸1642 题目描述: 拍集体照时队形很重要,这里对给定的 N 个人 K 排的队形设计排队规则如下: 每 ...
- PAT (Basic Level) Practice (中文)1054 求平均值 (20 分) 凌宸1642
PAT (Basic Level) Practice (中文)1054 求平均值 (20 分) 题目描述 本题的基本要求非常简单:给定 N 个实数,计算它们的平均值.但复杂的是有些输入数据可能是非法的 ...
- PAT (Basic Level) Practice (中文) 1050 螺旋矩阵 (25 分) 凌宸1642
PAT (Basic Level) Practice (中文) 1050 螺旋矩阵 (25 分) 目录 PAT (Basic Level) Practice (中文) 1050 螺旋矩阵 (25 分) ...
- PAT (Advanced Level) Practice 1031 Hello World for U (20 分) 凌宸1642
PAT (Advanced Level) Practice 1031 Hello World for U (20 分) 凌宸1642 题目描述: Given any string of N (≥5) ...
- PAT (Advanced Level) Practice 1023 Have Fun with Numbers (20 分) 凌宸1642
PAT (Advanced Level) Practice 1023 Have Fun with Numbers (20 分) 凌宸1642 题目描述: Notice that the number ...
- PAT (Advanced Level) Practice 1002 A+B for Polynomials (25 分) 凌宸1642
PAT (Advanced Level) Practice 1002 A+B for Polynomials (25 分) 凌宸1642 题目描述: This time, you are suppos ...
- PAT (Basic Level) Practice (中文)1057 数零壹 (20 分) (按行输入带空格的字符串)
给定一串长度不超过 1 的字符串,本题要求你将其中所有英文字母的序号(字母 a-z 对应序号 1-26,不分大小写)相加,得到整数 N,然后再分析一下 N 的二进制表示中有多少 0.多少 1.例如给定 ...
随机推荐
- Linux学习1-云服务器上搭建禅道项目管理工具
前言 相信各位测试的小伙伴出去面试总会被问到:测试环境怎么搭建?一个中级测试工程师还是对测试环境一无所知的话,面试官会一脸鄙视的,今天我给大家介绍一下最简单的环境部署-—如何在云服务器部署禅道环境. ...
- ArtiPub:一款开源的一文多发平台
文章来自我的博客:https://blog.ljyngup.com/archives/705.html/ 看到感觉挺有意思的,有空找个空闲的VPS搭建一下. 转自官方Github仓库 ArtiPub ...
- go微服务框架kratos学习笔记八 (kratos的依赖注入)
目录 go微服务框架kratos学习笔记八(kratos的依赖注入) 什么是依赖注入 google wire kratos中的wire Providers injector(注入器) Binding ...
- k8s系列---dns部署
1:首先创建kube-dns和dnsmasq这两个yaml,然后生成相应的pod.svc等. 2:然后在去创建其他的验证pod和svc 3:验证nslookup解析的是其他pod的svc的name,而 ...
- k8s系列---Service之ExternalName用法
需求:需要两个不同的namespace之间的不同pod可以通过name的形式访问 实现方式: A:在其他pod内ping [svcname].[namespace] ping出来到结果就是svc的ip ...
- 前端添加复选框checkbox 提交到django后台处理
根据前端勾选的复选框 提交勾选的数据到后台处理 che.html <!DOCTYPE html> <html lang="en"> <head> ...
- linux硬盘分区、格式化、挂载超详细步骤(fdisk/parted))
- Iperf 网络性能测试
1.iperf安装 1.1将iperf_PC.rar工具解压放在默认的盘目录下即可,无需安装 1.2安装iperf for android 2.06.apk"到手机端. adb instal ...
- 手把手教你搭建 ELK 实时日志分析平台
本篇文章主要是手把手教你搭建 ELK 实时日志分析平台,那么,ELK 到底是什么呢? ELK 是三个开源项目的首字母缩写,这三个项目分别是:Elasticsearch.Logstash 和 Kiban ...
- nginx基础(一)
一.nginx的安装.启动.停止及文件解读 yum -y install gcc gcc-c++ autoconf pcre-devel make automake yum -y install wg ...