-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcalc.cpp
More file actions
46 lines (44 loc) · 744 Bytes
/
Copy pathcalc.cpp
File metadata and controls
46 lines (44 loc) · 744 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
46
#include<iostream>
#include<algorithm>
using namespace std;
int main()
{
long long int n,b,t,ans,y;
cin>>t;
while(t--)
{
cin>>n>>b;
y=n/2;
y=y-(y%b);
ans=0;
while(y<=n/2)
{
ans=max(ans,(n-y)*(y/b));
y=y+b;
}
ans=max(ans,(n-y)*(y/b));
cout<<ans<<endl;
}
}
#include<iostream>
#include<algorithm>
using namespace std;
int main()
{
long long int n,b,t,ans,y;
cin>>t;
while(t--)
{
cin>>n>>b;
y=n/2;
y=y-(y%b);
ans=0;
while(y<=n/2)
{
ans=max(ans,(n-y)*(y/b));
y=y+b;
}
ans=max(ans,(n-y)*(y/b));
cout<<ans<<endl;
}
}