PAT 甲级 1132 Cut Integer (20 分)

思路:

1.字符串求子串、转整数;
2.分母上的数不能为0;

代码:

#include<iostream>
#include<string>
using namespace std;
int main(){
	int n;
	cin>>n;
	string s;
	for(int i=0;i<n;i++){
		cin>>s;
		int a=stoi(s.substr(0,s.length()/2));
		int b=stoi(s.substr(s.length()/2,s.length()/2));
		if(a==0||b==0||stoi(s)%(a*b)) printf("No\n");
		else printf("Yes\n");
	}
	return 0;
}
posted @ 2019-08-16 11:22  YuhanのBlog  阅读(60)  评论(0编辑  收藏  举报