1016. 部分A+B (15)
时间限制
100 ms
内存限制
65536 kB
代码长度限制
8000 B
判题程序
Standard
作者
CHEN, Yue
正整数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 main(){ int a=0,b=0,i=0,j=0,e,x,y; int c1=0,c2=0,p[10000],q[10000]; long long int m,n,sum; scanf("%lld %d %lld %d",&m,&x,&n,&y); while(m!=0){ p[i] = m%10; m = m/10; i++; } while(n!=0){ q[j] = n%10; n = n/10; j++; } for(e=0;e<i;e++){ if(p[e]==x) c1++; } for(e=0;e<j;e++){ if(q[e]==y) c2++; } for(e=0;e<c1;e++){ a = a+x*pow(10,e); } for(e=0;e<c2;e++){ b = b+y*pow(10,e); } sum = a+b; printf("%lld\n",sum); return 0; }