Home PAT 1132 Cut Integer
Post
Cancel

PAT 1132 Cut Integer

Link

Hmmmmmm 浮点错误什么原因大家心里都清楚.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <string>
#include <string.h>
#include <vector>
#include <cmath>
using namespace std;
typedef long long ll;
int n;
ll z;
inline ll getLen(ll x){
    int cnt=0;
    while(x){
        x/=10;
        cnt++;
    }
    return (ll)pow(10,cnt>>1);
}
int main() {
    scanf("%d",&n);
    while(n--){
        scanf("%lld",&z);
        ll modLen=getLen(z);
        ll left=z/modLen,right=z%modLen;
        if(!left||!right) printf("No\n");
        else if(z%left==0&&(z/left)%right==0) printf("Yes\n");
        else printf("No\n");
    }
    return 0;
}
This post is licensed under CC BY 4.0 by the author.