PAT (Advanced Level) Practise 1132 Cut Integer (20)
2017-11-08 15:55
274 查看
1132. Cut Integer (20)
时间限制400 ms
内存限制
65536 kB
代码长度限制
16000 B
判题程序
Standard
作者
CHEN, Yue
Cutting an integer means to cut a K digits long integer Z into two integers of (K/2) digits long integers A and B. For example, after cutting Z = 167334, we have A = 167 and B = 334. It is interesting to see that Z can be devided by the product of A and B,
as 167334 / (167 x 334) = 3. Given an integer Z, you are supposed to test if it is such an integer.
Input Specification:
Each input file contains one test case. For each case, the first line gives a positive integer N (<= 20). Then N lines follow, each gives an integer Z (10<=Z<=231). It is guaranteed that the number of digits of Z is an even
number.
Output Specification:
For each case, print a single line "Yes" if it is such a number, or "No" if not.
Sample Input:
3 167334 2333 12345678
Sample Output:
Yes No No
#include<stdio.h> int main(){ int T; for (scanf("%d",&T);T--;){ char s[20]; scanf("%s",s); int n = 0; while (s ) ++n; long long a,b,c; sscanf(s, "%lld", &a); sscanf(s + n / 2,"%lld", &b); s[n/2] = 0; sscanf(s, "%lld", &c); puts(!b || a%(b*c)?"No":"Yes"); } return 0; }
相关文章推荐
- PAT (Advanced Level) Practise 1128 N Queens Puzzle (20)
- PAT (Advanced Level) Practise 1108 Finding Average (20)
- 1005. Spell It Right (20)——PAT (Advanced Level) Practise
- 1054. The Dominant Color (20)【水题】——PAT (Advanced Level) Practise
- PAT-Advanced-Level-Practise-1084. Broken Keyboard (20)
- PAT (Advanced Level) Practise 1054 The Dominant Color (20)
- 1081. Rational Sum (20)【模拟】——PAT (Advanced Level) Practise
- PAT (Advanced Level) Practise 1092 To Buy or Not to Buy (20)
- PAT (Advanced Level) Practise 1112 Stucked Keyboard (20)
- PAT (Advanced Level) Practise 1015. Reversible Primes (20)
- PAT (Advanced Level) Practise 1023. Have Fun with Numbers (20)
- 1092. To Buy or Not to Buy (20)【水题】——PAT (Advanced Level) Practise
- 1041. Be Unique (20)【水题】——PAT (Advanced Level) Practise
- 1050. String Subtraction (20)【字符串处理】——PAT (Advanced Level) Practise
- PAT (Advanced Level) Practise 1031. Hello World for U (20)
- PAT (Advanced Level) Practise 1120 Friend Numbers (20)
- PAT (Advanced Level) Practise 1015. Reversible Primes (20) 素数筛法 进制转换
- PAT (Advanced Level) Practise 1054 The Dominant Color (20)
- PAT (Advanced Level) Practise - 1005. Spell It Right (20)
- PAT (Advanced Level) Practise 1005 Spell It Right (20)