爱撸猫的青菜 - normal version
题号:NC231163
时间限制:C/C++/Rust/Pascal 1秒,其他语言2秒
空间限制:C/C++/Rust/Pascal 256 M,其他语言512 M
64bit IO Format: %lld

题目描述

上师大人都知道, 上师大的猫猫非常多, 而且都很聪明. 2020年, 上师大出现了一名大一新生 - 青菜, 他十分喜欢撸猫猫, 并且会给一些猫猫带上奇怪的项圈.

喜欢简约风格的青菜拥有的项圈只有两个种类: 黑色或白色. 青菜特别喜欢黑色, 所以每次系项圈时总有猫猫会被系上黑色项圈, 猫猫自己看不到自己脖子上的颜色.

他给猫猫戴上项圈后的每天晚上都会给每一只猫一次猜自己脖子上项圈颜色的机会.

如果猜中, 他会给这些猫猫做记录, 被记录的猫猫会在第二天早上得到从大面包中平均分出的小面包, 猫猫喜欢吃面包, 并且想要吃得多 (因此猫猫不会告诉别的猫猫对方项圈的颜色). 但是, 如果猜错一次项圈的颜色, 猫猫脖子上的项圈就会被解开, 并且记性超好的青菜永远也不会再给他系上项圈 (所有的猫猫都不希望在没有确定自己的项圈颜色的时候就去碰运气从而失去以后获取面包的权利).

当所有的猫猫都获得面包的时候, 青菜会解下所有的项圈, 并且会再给所有猫猫的一部分系上项圈, 如此往复. 问: 青菜每次给 n 只猫猫系上黑色项圈, 给 m 只猫猫系上白色项圈后的多少天, 所有猫猫都会得到面包?

As every SHNUer know, there are many cats and they are all very smart.

In 2020, Vege, a freshman at Shanghai Normal University, likes to masturbate cats and puts strange collars on some of them.

Vege, who like simplicity, have only two types of collars: black or white, and Vege are known to love the color black, which is why cats are always wearing black collars.

Cats can't see the color on their own necks. He gave each cat a chance to guess the color of its collar once a night after he put it on.

If he was right, he recorded the cats, who were given smaller loaves of bread the next morning, divided equally among the larger loaves. Cats liked the loaves and wanted to eat more of them (so one cat didn't tell the others about their collar color). One wrong guess, however, unlocks the collar and Vege, who has a good memory, never puts it back on (all cats don't want to take a chance and lose the right to a loaf of bread later).

When all the cats got the bread, Vege would remove all the collars and put some more collars on all the cats, and so on. Q: How many days after Vege put a black collar on n cats and a white collar on M cats will all cats get bread?

输入描述:

多组输入, 每组输入一行.

第一行输入两个整数 n, m, 分别表示带上黑色项圈的猫猫个数和白色项圈的猫猫个数.

Multiple groups of input, each group has only contain one lines.

First line input two integer n, m, denote the number of black collar cat and white collar cat.

输出描述:

对于每组输出样例输出一行. 

第一行输出一个整数 d, 表示自系项圈起 d 天后所有的猫猫都会得到面包

For each case contain one line.

First line output a integer d, denote all cats will receive bread after d days since the collar was attached
示例1

输入

复制
1 0
1 1
2 1

输出

复制
1
2
3

说明

来自青菜的提示

(觉得自己贼厉害的同学可以不用看提示自己想噢i)

这是关于样例的生动讲解啦啦啦:

    第一次系项圈的时候,只有两只猫分别戴着两种不同颜色的项圈,戴黑项圈猫猫看到只有一只戴着白色项圈的猫猫,就知道自己戴的肯定是黑色项圈了(看题干黑体字),所以后1天早上就吃上了面包,这被戴着白色项圈的猫猫看见了,于是他当晚也能说出自己戴的是白色项圈,于是在第2天也吃上了面包,所以答案是2.

    第二次系项圈的时候,有三只猫A、B、C,其中A、B被系上了黑色项圈,C被系上了白色项圈,刚系上时,A和B看对方都有黑色项圈所以不确定自己的项圈是什么颜色,C更是一脸懵逼(因为他看到了俩黑色帽子),所以当晚没猫猫去猜自己项圈的颜色,第一天早上也就没有猫猫吃到面包,这时候A和B想,如果自己戴的是白色项圈,那么对方看见的都只有白色项圈,那么他昨天晚上就会猜出自己的项圈颜色今早就有面包吃,而事情却并非如此,所以他们立马明白了自己戴的是黑色项圈,而看到了俩黑色项圈的C依旧一脸懵逼;第二天早上A、B自然吃上了面包,而机智的C也发觉到了事情的真相,自己戴的是白项圈,于是在第三天也吃上了面包~

Tips from the Vege  

(Students who think they are a good thief can think oh I without looking at the prompt)  

Here's a lively explanation of the sample la la la la:  

 Is a collar for the first time, only two cats were wearing two different colors of collar, wearing a black collar cat saw only one wearing white collars cat cat, is certainly knew their wearing black collar (see dry bolded text), so after 1 day morning eat the bread, it was wearing white collars cat cat saw,  So he was able to say that he was wearing a white collar that night, so he ate bread the next day, so the answer is 2.  

Department of the second collar, there are three cats A, B, C, among them A and B are tied on the black collar, C was tied on the white collar, first, A and B look at each other with A black collar so not sure what color are his collar, but also A face of meng C (because he saw two black hat), so the evening didn't cat cat to guess the color of the collar,  First day in the morning there would be no cat cat to eat bread, then A and B, if I wore A white collar, then each other to see only A white collar, then yesterday evening he will guess his collar color today have bread to eat, and things are not, so they immediately understand oneself wore A black collar,  C, who saw two black collars, was still confused;  The next morning, A and B ate bread of course, but C also found out the truth of the matter, wearing A white collar, so on the third day also ate bread ~  


备注:

对于所有测试点有:

For all test points there are: