I have been working on codeforces recently. I always think I can't move bzoj? -- Meow
Thank you for answering questions in question B of div.2.
Apparently I am not so idle (idle _ idle) idle
I think this question is a wonderful idea ~
You need to give a and B cnt1 and cnt2 numbers respectively.
But a should not be divisible by X, as well as, B should not be divisible by Y
Then find the minimum value of the maximum number to be given --
What is the highest value? Isn't that a typical binary classification?
However, I was not aware of this because of my English question ......
The second answer is V, because a should not be divided by X, so we can
First, divide the number divided by X but not by Y to B,
Then, divide the number divided by Y but not X to.
Then, all the numbers divisible by a * B are excluded.
The remaining number is mutually exclusive with a and B, and you can determine whether the allocation can be well done.
The code is easy to write.
1 #include <cstdio> 2 #include <cstring> 3 4 int cnt1, cnt2, x, y; 5 inline int getint(); 6 inline void putint(long long); 7 inline bool check(long long); 8 9 int main()10 {11 long long l, r, m;12 13 cnt1=getint(), cnt2=getint(), x=getint(), y=getint();14 l=0, r=0x0FFFFFFFFFFFFFFFLL;15 while (l+1<r)16 {17 m=(l+r)>>1;18 if (check(m)) r=m;19 else l=m;20 }21 putint(r);22 23 return 0;24 }25 inline int getint()26 {27 register int num=0;28 register char ch;29 do ch=getchar(); while (ch<‘0‘ || ch>‘9‘);30 do num=num*10+ch-‘0‘, ch=getchar(); while (ch>=‘0‘ && ch<=‘9‘);31 return num;32 }33 inline void putint(long long num)34 {35 char stack[22];36 register int top=0;37 for ( ;num;num/=10) stack[++top]=num%10+‘0‘;38 for ( ;top;top--) putchar(stack[top]);39 putchar(‘\n‘);40 }41 inline bool check(long long num)42 {43 long long u=num/x, v=num/y, w=num/(x*y);44 long long c1=cnt1, c2=cnt2;45 c1-=v-w; c2-=u-w;46 if (c1<0) c1=0; if (c2<0) c2=0;47 if (c1+c2>num-u-v+w) return false;48 return true;49 }
This silly English Sb Series
[Codeforces round #275 (Div. 2)] B-friends and presents