-
Notifications
You must be signed in to change notification settings - Fork 0
/
1008 - Fibsieve`s Fantabulous Birthday.c
executable file
·86 lines (71 loc) · 1.65 KB
/
1008 - Fibsieve`s Fantabulous Birthday.c
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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
#include<stdio.h>
#include<math.h>
int main()
{
int long long bn,bnn,s,n,a,b,i,m;
int long long res1,result,mul;
int cases=1;
scanf("%d",&m);
for(i=0;i<m;i++)
{
scanf("%lld",&n);
result=sqrt(n);
mul=(result)*(result);
s=(result*2)+1;
bn=n-(result*result);
res1=result+1;
if(n==1)
{
a=1;
b=1;
}
else{
if(mul==n)
{
if(result%2==0)
{
a=result;
b=(result*result)-n+1;
}
else
{
a=(result*result)-n+1;
b=result;
}
}
else
{
if(res1%2==0)
{
if(s/2>=bn)
{
a=bn;
b=res1;
}
else
{
a=res1;
bnn=(res1*res1)-n+1;
b=bnn;
}
}
else
{
if(s/2>=bn)
{
a=res1;
b=bn;
}
else
{
bnn=(res1*res1)-n+1;
a=bnn;
b=res1;
}
}
}
}
printf("Case %d: %d %d\n",cases++,a,b);
}
return 0;
}