1132 Cut Integer (20 分)
作者:互联网
问题描述:将一个数分为两半A,B,判断这个数能否被A*B整除。
解题思路:按字符串输入,并分为两半,注意B可能等于0
AC代码:
#include<iostream>
#include<string>
using namespace std;
void judge(string &s)
{
long long c=0,a=0,b=0;
int n=s.length(),i,x;
x=n/2;
for(i=0;i<n;++i){
int y=s[i]-'0';
if(i<x)a=a*10+y;
else b=b*10+y;
c=c*10+y;
}
if(!b||c%(a*b))printf("No\n");
else printf("Yes\n");
}
int main()
{
freopen("test.txt","r",stdin);
int N;
scanf("%d",&N);
while(N--){
string str;
cin>>str;
judge(str);
}
return 0;
}
标签:Cut,20,1132,long,str,judge,两半,include 来源: https://blog.csdn.net/lianwaiyuwusheng/article/details/87890544