1132 Cut Integer

A little bit.

Thought: note that the divisor may be 0, otherwise it will cause floating-point error.

Code:

#include <iostream>
#include <string>
using namespace std;
int main()
{
    int n;
    string str;
    cin>>n;
    while(n--){
        cin>>str;
        string s1=str.substr(0,str.size()/2);
        string s2=str.substr(str.size()/2,str.size()/2);
        int a=stoi(s1),b=stoi(s2),val=stoi(str);
        if(b!=0 && val%(a*b)==0) cout<<"Yes\n";
        else cout<<"No\n";
    }
}

 

Leave a Reply

Your email address will not be published. Required fields are marked *