blob: 4b94486b5abe7a9e4906695b13f5bc3ce08ec76b (
plain)
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
33
34
35
36
37
38
39
40
41
|
/*
* 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.
*/
#include <stdio.h>
#include <math.h>
#include <stdbool.h>
typedef long long unsigned int t_llu;
int main(void)
{
t_llu n = (t_llu)floor(sqrt(1020304050607080900)) - 1000;
while (true)
{
t_llu s = n * n;
if ((s % 10llu) / 1llu == 0 &&
(s % 1000llu) / 100llu == 9 &&
(s % 100000llu) / 10000llu == 8 &&
(s % 10000000llu) / 1000000llu == 7 &&
(s % 1000000000llu) / 100000000llu == 6 &&
(s % 100000000000llu) / 10000000000llu == 5 &&
(s % 10000000000000llu) / 1000000000000llu == 4 &&
(s % 1000000000000000llu) / 100000000000000llu == 3 &&
(s % 100000000000000000llu) / 10000000000000000llu == 2 &&
(s % 10000000000000000000llu) / 1000000000000000000llu == 1)
{
printf("%llu\n", n);
printf("%llu\n", s);
break;
}
n++;
}
return 0;
}
|