PE 206 Concealed Square (暴力)
Concealed Square
Problem 206
Find the unique positive integer whose square has the form 1_2_3_4_5_6_7_8_9_0,
where each “_” is a single digit.
题解:
被遮挡的平方数
找出唯一一个其平方形如1_2_3_4_5_6_7_8_9_0的正整数,
其中每个“_”表示一位数字。
题解:
额….暴力呗…
代码:
#include<bits/stdc++.h>
int check(long long num)
{
num = num * num;
num /= 100;
for (int i = 9; i >= 1; i--)
{
if (num % 10 == i) num /= 100;
else return 0;
}
return 1;
}
int main()
{
for (long long i = 1000000070; i < 2000000000; i += 100)
{
if (check(i))
{
printf("%lld\n", i);
break;
}
}
return 0;
}
还没有评论,来说两句吧...