部分A+B (15) pow(x,y) x的y次方 A、DA、B、DB,A中DA出现的次数对应-》 1111 * 4=pa 求PA+PB
来源:互联网 发布:数据库表结设计例子 编辑:程序博客网 时间:2024/06/06 12:20
/*
正整数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 < 10^10。
输出格式:
在一行中输出PA + PB的值。
输入样例1:
3862767 6 13530293 3
输出样例1:
399
输入样例2:
3862767 1 13530293 8
*/
#include<iostream>
#include<string>
#include<math.h> //x 的y次方 pow(x,y)
using namespace std;
int main()
{
string str1,str2;
int a,b;
int x=0,y=0;
cin>>str1>>a>>str2>>b;
for(int i=0;i<str1.length();i++) // string 字符串 长度yong str.length();
//注意 ()没写就会 有没有参数的错误
{
if(str1[i]-'0'==a){x++;}
}
for(int i=0;i<str2.length();i++)
{
if(str2[i]-'0'==b)y++;
}
int temp=1;
if(x==0){temp=0;}
for(int i=2;i<=x;i++)
{
temp=temp+pow( 10,(i-1) );
}
temp=temp*a;
cout<<"x是"<<x<<"temp是"<<temp;
int tempy=1;
if(y==0){tempy=0;}
for(int i=2;i<=y;i++)
{
tempy=tempy+pow( 10,(i-1) );
}
tempy=tempy*b;
cout<<"y是"<<y<<"tempy是"<<tempy;
//cout<<temp*tempy;
cout<<"和是"<<temp+tempy;
return 0;
正整数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 < 10^10。
输出格式:
在一行中输出PA + PB的值。
输入样例1:
3862767 6 13530293 3
输出样例1:
399
输入样例2:
3862767 1 13530293 8
*/
#include<iostream>
#include<string>
#include<math.h> //x 的y次方 pow(x,y)
using namespace std;
int main()
{
string str1,str2;
int a,b;
int x=0,y=0;
cin>>str1>>a>>str2>>b;
for(int i=0;i<str1.length();i++) // string 字符串 长度yong str.length();
//注意 ()没写就会 有没有参数的错误
{
if(str1[i]-'0'==a){x++;}
}
for(int i=0;i<str2.length();i++)
{
if(str2[i]-'0'==b)y++;
}
int temp=1;
if(x==0){temp=0;}
for(int i=2;i<=x;i++)
{
temp=temp+pow( 10,(i-1) );
}
temp=temp*a;
cout<<"x是"<<x<<"temp是"<<temp;
int tempy=1;
if(y==0){tempy=0;}
for(int i=2;i<=y;i++)
{
tempy=tempy+pow( 10,(i-1) );
}
tempy=tempy*b;
cout<<"y是"<<y<<"tempy是"<<tempy;
//cout<<temp*tempy;
cout<<"和是"<<temp+tempy;
return 0;
}
阅读全文
0 0
- 部分A+B (15) pow(x,y) x的y次方 A、DA、B、DB,A中DA出现的次数对应-》 1111 * 4=pa 求PA+PB
- 扩展欧几里得 a*x+b*y=c的解
- BZOJ 2301 Problem B(x属于[a,b],y属于[c,d]满足gcd(x,y)=k的(x,y)的有序对数)
- Java编程机试:获取某一字符串中(只要字母),每一个字母出现的次数输出格式为a(x)b(y)c(z).....m(n)
- BZOJ 1101([POI2007]Zap-满足x<=a&&y<=b&&gcd(x,y)=d的数对个数)
- 求x的y次方
- pow计算x的y次方
- pow() 函数返回 x 的 y 次方
- 解不定方程a*x+b*y=c
- 解不定方程a*x+b*y=c
- 最大公约数,最小公倍数,a*x+b*y=n
- (a,b)=1 ax+by x>0 y>0的最大不能表示数
- 求解次方的次方。pow(a,pow(b,c))%p
- POJ 3243 Clever Y 求A^X = B (mod C) / BabyStep_GiantStep
- POJ 3243: Clever Y 求A^X = B (mod C) / BabyStep_GiantStep
- 给你5个数a,b,c,d,k。x属于[a,b]y属于[c,d]。 问你有多少对(x,y)的公约数为k
- 1 / x + 1 / y = b / a(已知a,b)
- My first blog entry also is my first english math proof ( GCD(a,b)=min{a*x+b*y, a*x+b*y>0} )
- 购物车angularJS删除和模糊查询还有排序
- 内部类操作
- HDU4185 Oil Skimming
- Android中GOT表HOOK手动实现
- Oozie安装
- 部分A+B (15) pow(x,y) x的y次方 A、DA、B、DB,A中DA出现的次数对应-》 1111 * 4=pa 求PA+PB
- 项目3-1用电路做加法
- SVN 使用文档
- tf.argmax (API r1.3)
- 张鑫旭慕课之——深入理解absolute(上)
- js计算时间为刚刚、几分钟前、几小时前、几天前··
- 递推
- 链表的归并排序
- Python使用PyQt5库 一、Designer界面的使用——终于出界面了。****************