-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathguess.cpp
More file actions
45 lines (42 loc) · 722 Bytes
/
Copy pathguess.cpp
File metadata and controls
45 lines (42 loc) · 722 Bytes
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
#include <iostream>
using namespace std;
typedef long long int LL;
LL GCD (LL a, LL b)
{
/*if(b==0)
return a;
else
return GCD(b,a%b);*/
while(b) b ^= a ^= b ^= a %= b;
return a;
}
main()
{
LL t;
cin>>t;
while(t--)
{
LL n,m,total=0;
cin>>n>>m;
total = ((n+1)/2)*(m/2) + (n/2)*((m+1)/2);
/*if(n%2==0)
{
if(m%2==0)
total= (n*m)/4;
else
total= ((n/2)*((m/2)+1)) + ((n/2)*(m/2));
}
else
{
if(m%2==0)
total= (((n/2)+1)*(m/2)) + ((n*m)/4);
else
total= (((n/2)+1)*(m/2)) + ((n/2)*((m/2)+1));
}*/
//cout<<total<<endl;
LL den=n*m;
LL hcf=GCD(total,den);
cout<<hcf<<endl;
cout<<total/hcf<<"/"<<den/hcf<<endl;
}
}