Submission #8150759


Source Code Expand

Copy
#include <bits/stdc++.h>
using namespace std;
using Int = int_fast64_t;

Int n;

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cin >> n;
	Int ans = 1e18;
	for(Int i=1; i*i<=n; ++i){
		if(n % i != 0) continue;
		ans = min(ans, i-1 + n/i-1);
	}
	cout << ans << "\n";
}

Submission Info

Submission Time
Task C - Walk on Multiplication Table
User Power730
Language C++14 (GCC 5.4.1)
Score 300
Code Size 292 Byte
Status AC
Exec Time 12 ms
Memory 256 KB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 300 / 300
Status
AC × 3
AC × 41
Set Name Test Cases
Sample sample_01, sample_02, sample_03
All hand_01, hand_02, hand_03, hand_04, hand_05, hand_06, hand_07, hand_08, large_01, large_02, large_03, large_04, large_05, large_06, large_07, large_08, prime_01, prime_02, prime_03, random_01, random_02, random_03, random_04, random_05, random_06, random_07, random_08, sample_01, sample_02, sample_03, small_01, small_02, small_03, small_04, small_05, small_06, small_07, small_08, square_01, square_02, square_03
Case Name Status Exec Time Memory
hand_01 AC 11 ms 256 KB
hand_02 AC 1 ms 256 KB
hand_03 AC 12 ms 256 KB
hand_04 AC 9 ms 256 KB
hand_05 AC 6 ms 256 KB
hand_06 AC 12 ms 256 KB
hand_07 AC 12 ms 256 KB
hand_08 AC 11 ms 256 KB
large_01 AC 11 ms 256 KB
large_02 AC 10 ms 256 KB
large_03 AC 10 ms 256 KB
large_04 AC 9 ms 256 KB
large_05 AC 11 ms 256 KB
large_06 AC 10 ms 256 KB
large_07 AC 9 ms 256 KB
large_08 AC 11 ms 256 KB
prime_01 AC 9 ms 256 KB
prime_02 AC 9 ms 256 KB
prime_03 AC 9 ms 256 KB
random_01 AC 11 ms 256 KB
random_02 AC 8 ms 256 KB
random_03 AC 6 ms 256 KB
random_04 AC 6 ms 256 KB
random_05 AC 3 ms 256 KB
random_06 AC 7 ms 256 KB
random_07 AC 7 ms 256 KB
random_08 AC 11 ms 256 KB
sample_01 AC 1 ms 256 KB
sample_02 AC 1 ms 256 KB
sample_03 AC 2 ms 256 KB
small_01 AC 1 ms 256 KB
small_02 AC 1 ms 256 KB
small_03 AC 1 ms 256 KB
small_04 AC 1 ms 256 KB
small_05 AC 1 ms 256 KB
small_06 AC 1 ms 256 KB
small_07 AC 1 ms 256 KB
small_08 AC 1 ms 256 KB
square_01 AC 9 ms 256 KB
square_02 AC 5 ms 256 KB
square_03 AC 11 ms 256 KB