Submission

Status:

[PPP][PPP][PPP][PPP][PPPPP]

Subtask/Task Score:

{20/20}{20/20}{20/20}{20/20}{20/20}

Score: 100

User: dddrrrr

Problemset: ปราสาท

Language: cpp

Time: 0.002 second

Submitted On: 2025-10-17 14:26:37

#include <bits/stdc++.h>
using namespace std;

int main(){
	cin.tie(0)->sync_with_stdio(0);
	cout.tie(0)->sync_with_stdio(0);
	
	long long x;
	cin >> x;
	
	long long l=1 ,r=x ,m;
	
	while(l <= r){
		m = l + (r-l)/2;
		long long msq = m*m;
		
		if(msq >= x)r=m-1;
		else l=m+1;
	}
	
	//cout  << l;
	if(l % 2 == 0){
		if(x%2 == 0)cout << 2LL*l - 2;
		else cout << 2LL*l - 3; 
	}
	else{
		if(x%2 == 0)cout << 2*l - 3;
		else cout << 2LL*l - 2; 
	}
	
	return 0;
}