-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathDATAPIPE.cpp
More file actions
51 lines (47 loc) · 1.06 KB
/
DATAPIPE.cpp
File metadata and controls
51 lines (47 loc) · 1.06 KB
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
#include<bits/stdc++.h>
using namespace std;
int main()
{
int t,start=0,ending=0;
cin>>t;
while(t--)
{
int m,noe,nof,k;
cin>>m>>noe>>nof;
int beg=1,last=m,mid;
while(beg<=last)
{
mid=(beg+last)/2;
k=(int)ceil(mid/noe);
int no=mid/k;
if(mid%k!=0)
no++;
if(no<nof)
last=mid-1;
if(no>nof)
beg=mid+1;
if(no==nof)
{beg=mid;
start=beg;
}
}
beg=1,last=m,mid;
while(beg<=last)
{
mid=(beg+last)/2;
k=(int)ceil(mid/noe);
int no=mid/k;
if(mid%k!=0)
no++;
if(no<nof)
last=mid-1;
if(no>nof)
beg=mid+1;
if(no==nof)
{ last=mid;
ending=last;
}
}
cout<<ending-start+1<<"\n";
}
}