1016. 部分A+B (15)

正整数A的“DA(为1位整数)部分”定义为由A中所有DA组成的新整数PA。例如:给定A = 3862767,DA = 6,则A的“6部分”PA是66,因为A中有2个6。

现给定A、DA、B、DB,请编写程序计算PA + PB

输入格式:

输入在一行中依次给出A、DA、B、DB,中间以空格分隔,其中0 < A, B < 1010

输出格式:

在一行中输出PA + PB的值。

输入样例1:

3862767 6 13530293 3

输出样例1:

399

输入样例2:

3862767 1 13530293 8

输出样例2:

0

 #include <stdio.h>
#include <stdlib.h>
#include <math.h> int number(int a, int b);
int newNum(int num, int repeatTime);
int main()
{
int a,b, la, lb;
scanf("%d%d%d%d", &la,&a,&lb,&b); int a1 = number(la,a);
int b1 = number(lb, b); int new_a = newNum(a, a1);
int new_b = newNum(b,b1);
printf("%d",new_a +new_b); return ;
} int number(int a, int b){
int cnt = ;
while( a != ){
if(a % == b) cnt++;
a /= ;
}
if ( a == b) cnt ++;
return cnt;
} int newNum(int num, int repeatTime){
int result = ,i = ;
for(; i < repeatTime; i++){
result += num * (pow(,i));
} return result;
}

PAT 1016 部分A+B C语言的更多相关文章

  1. PAT 1016

    1016. Phone Bills (25) A long-distance telephone company charges its customers by the following rule ...

  2. PAT 1016 部分A+B(15)(C++&JAVA&&Python)

    1016 部分A+B(15 分) 正整数 A 的"D​A​​(为 1 位整数)部分"定义为由 A 中所有 D​A​​ 组成的新整数 P​A​​.例如:给定 A=3862767,D​ ...

  3. PAT 1016 Phone Bills[转载]

    1016 Phone Bills (25)(25 分)提问 A long-distance telephone company charges its customers by the followi ...

  4. PAT——1016. 部分A+B

    正整数A的“DA(为1位整数)部分”定义为由A中所有DA组成的新整数PA.例如:给定A = 3862767,DA = 6,则A的“6部分”PA是66,因为A中有2个6. 现给定A.DA.B.DB,请编 ...

  5. PAT 1016 Phone Bills(模拟)

    1016. Phone Bills (25) 时间限制 400 ms 内存限制 65536 kB 代码长度限制 16000 B 判题程序 Standard 作者 CHEN, Yue A long-di ...

  6. PAT 1016. 部分A+B (15)

    正整数A的"DA(为1位整数)部分"定义为由A中所有DA组成的新整数PA.例如:给定A = 3862767,DA = 6,则A的"6部分"PA是66,因为A中有 ...

  7. PAT 1016. Phone Bills

    A long-distance telephone company charges its customers by the following rules: Making a long-distan ...

  8. PAT 1016 部分A+B

    https://pintia.cn/problem-sets/994805260223102976/problems/994805306310115328 正整数A的“D~A~(为1位整数)部分”定义 ...

  9. PAT(B) 1030 完美数列 - C语言 - 滑动窗口 & 双指针

    题目链接:1030 完美数列 (25 point(s)) 给定一个正整数数列,和正整数 \(p\),设这个数列中的最大值是 \(M\),最小值是 \(m\),如果 \(M≤mp\),则称这个数列是完美 ...

随机推荐

  1. dns之缓存。

    1.浏览器缓存.这里以chrome为例.在chrome上输入:chrome://net-internals/#dns 可以查看chrome浏览器的dns缓存信息. 这样. 2.windows系统缓存. ...

  2. supervisor安装及其配置

    一.supervisor概述 supervisor是一个c/s系统,被用来在类Unix系统中监控进程状态.supervisor使用python开发. 服务端进程为supervisord,主要负责启动自 ...

  3. oracle中 start with .. connect by prior.. 用法简介

    我们经常会将一个比较复杂的目录树存储到一个表中.或者将一些部门存储到一个表中,而这些部门互相有隶属关系.这个时候你就会用到connect by prior start with.oracle 提供了s ...

  4. 20145319 《网络对抗》逆向与Bof基础

    20145319 逆向与Bof实验 1 实验内容 本次实验以可执行文件pwn1为例,将对pwn1进行反汇编的基础上进行功能上的解读,并进行缓冲区溢出攻击 可执行文件pwn1的正常流程是主函数调用foo ...

  5. A8几种内存

    1.SD卡(程序可写入,当成最次硬盘来用) 2.nandflash(程序可写入,当成一般硬盘来用) 3.DDR2(当A8板子的内存条来用)

  6. 【找不到符号】Maven打包找不到符号的问题排查

    当碰到maven错误:找不到符号问题时,通常第一反应应该是执行eclipse的Project -> Clean … -> Clean all projects,然后再执行maven cle ...

  7. 数据库常见的三种join方式

    数据库常见的join方式有三种:inner join, left outter join, right outter join(还有一种full join,因不常用,本文不讨论).这三种连接方式都是将 ...

  8. 51Nod 1557 两个集合(二分)

    http://www.51nod.com/onlineJudge/questionCode.html#!problemId=1557 题意: 小X有n个互不相同的整数: p1,p2,...,pn .他 ...

  9. /etc/rc.local 与 /etc/profile

    1.用户自己源码安装的软件组要自启动,可以在/etc/rc.local中配置,rc.loacl 是rc.d/rc.local的一个软连接.rc.local -> rc.d/rc.local 2. ...

  10. 带宽检测工具iftop

    1.安装 # yum install iftop –y 2.使用 # iftop -i eth0 -n # iftop -i eth0 -P 说明: 中间的<= =>这两个左右箭头,表示的 ...