U E D R , A S I H C RSS

금고/하기웅

~
만... .. ..
만..^^ 내믹...; 뭐 면 뭐 .. 머리 ..

..ㅡㅡ; 를 떨 ..
대 복..ㅡㅡ;
...ㅡㅡ;

는데 ~??
f s 면 s-1는 f , 보면
데 부 보면 는데.
floor/2^(s-1)+s-1~

floor/2^s 1보 는 s번
s를 며 floor/2^s 1보 s+1.

s() 보면...
7, 7 면 4 번 6 번 7 면 3번 는데.
8, 8 면 4 번 6 번 7 번 8 번 4번 .
2 .
8 2^3 1 4번 .
9 9 4 (16 )

, floor/2^s 1보 s+1 .

~cpp
#include <iostream> 
#include <cmath> 
using namespace std; 

int testcase, nFloor, nSaver; 

int calculate(int f, int s) 
{ 
	if(f/pow(2,s)<1)
	{
		while(s--)
		{
			if(f/pow(2,s)>=1)
				return s+1;
		}
	}
    return f/pow(2,s-1)+s-1;   // f/pow(2,s-1) =>s-1번      
} 

int main() 
{ 
    cin>>testcase; 
    while(testcase--) 
    { 
        cin>>nFloor>>nSaver; 
        cout << calculate(nFloor, nSaver) <<endl; 
    } 
    return 0; 
} 
Valid XHTML 1.0! Valid CSS! powered by MoniWiki
last modified 2021-02-07 05:28:46
Processing time 0.0106 sec