-
Notifications
You must be signed in to change notification settings - Fork 0
/
PYTRIP.cpp
61 lines (55 loc) · 920 Bytes
/
PYTRIP.cpp
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
#include<stdio.h>
#include<math.h>
#include<map>
using namespace std;
long abs(long number)
{
if(number<0)
return -number;
else
return number;
}
int main()
{
long t,a,b,c,n,m,counter=0,temp,i;
bool found=false;
scanf("%ld",&t);
while(t--)
{
scanf("%ld",&n);
scanf("%ld",&m);
for(i=n;i<=m;i++)
{
if(i%2!=0)
{
a=i;
b=(a*a-1)/2;
c=b+1;
printf("i,a,b,c are %ld,%ld,%ld,%ld\n",i,a,b,c);
if(a<c && b<c && c<=m && a>=1 && b>=1)
{
counter++;
printf("Counter: %ld\n",counter);
}
if(abs(a-b)==abs(b-c) && a>b && b<n)
counter--;
}
else
{
a=i;
b=((a/2)*(a/2))-1;
c=b+2;
printf("i,a,b,c are %ld,%ld,%ld,%ld\n",i,a,b,c);
if(a<c && b<c && c<=m && a>=1 && b>=1)
{
counter++;
printf("Counter: %ld\n",counter);
}
if(a>b && b<n)
counter++;
}
}
printf("Counter is: %ld\n",counter);
}
return 0;
}