1132 Cut Integer (20分)

#include<cstdio>
#include<string>
#include<iostream>
#include<vector>
#include <algorithm>//fill()在里面 
#include <cmath>
#include<queue>
#include<unordered_set>
#include<set> 
#include <cstdlib>//貌似是free,malloc等函数的头文件 
using namespace std;


const int INF=1e9; //fill(map[0],map[0]+maxn*maxn,INF); 
const int maxn=110;

int main(){
	int n;
	string z;
	//z的位数保证是偶数 
 	scanf("%d",&n);
 	while(n--){
 		cin>>z;
 		//将z(k位数)切成两份(k/2位数)的数a,b 且a*b可以整除z 
 		//判断输入的z满足上述条件就print yes,否则no
		//分析:用string比较方便,直接从中间拆分,因为k保证是偶数 
		int number=stoi(z);
		int len=z.length();
		int a=stoi(z.substr(0,len/2));
		int b=stoi(z.substr(len/2,len));
//		cout<<"a="<<a<<"b="<<b<<endl;
		int product=a*b;
		if(product!=0&&number%product==0){//要有product!=0否则会报浮点错误
			//如果能整除说明是因数
			cout<<"Yes"<<endl; 
		}else{
			cout<<"No"<<endl;
		}
	 }

	 
	return 0;
} 

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值