Submission #1122163


Source Code Expand

Copy
#include <iostream>
#include <vector>
#include <cmath>
#include <string>
#include <algorithm>
#include <numeric>
#include <climits>
#define LIM 1000007
#define ll long long
using namespace std;
int main() {
  ll n;
  cin >> n;
  ll x = sqrt(n);
  ll y = x;
  ll rm;
  ll ans = INT_MAX;
  for (int k = x -100; k < x + 100; k++) {
    if (k < 1) continue;
    for (int i = y -100; i < y + 100; i++) {
      if (i < 1) continue;
      ll rm = n - k * i;
      if (rm >= 0) {
        ans = min(abs(k - i) + rm, ans);
      }
    }
  }
  cout << ans << endl;
  return 0;
}

Submission Info

Submission Time
Task B - □□□□□
User yka
Language C++14 (GCC 5.4.1)
Score 100
Code Size 598 Byte
Status
Exec Time 1 ms
Memory 256 KB

Test Cases

Set Name Score / Max Score Test Cases
Sample 0 / 0 sample_01.txt, sample_02.txt, sample_03.txt
All 100 / 100 sample_01.txt, sample_02.txt, sample_03.txt, subtask1_01.txt, subtask1_02.txt, subtask1_03.txt, subtask1_04.txt, subtask1_05.txt, subtask1_06.txt, subtask1_07.txt, subtask1_08.txt, subtask1_09.txt, subtask1_10.txt, subtask1_11.txt, subtask1_12.txt
Case Name Status Exec Time Memory
sample_01.txt 1 ms 256 KB
sample_02.txt 1 ms 256 KB
sample_03.txt 1 ms 256 KB
subtask1_01.txt 1 ms 256 KB
subtask1_02.txt 1 ms 256 KB
subtask1_03.txt 1 ms 256 KB
subtask1_04.txt 1 ms 256 KB
subtask1_05.txt 1 ms 256 KB
subtask1_06.txt 1 ms 256 KB
subtask1_07.txt 1 ms 256 KB
subtask1_08.txt 1 ms 256 KB
subtask1_09.txt 1 ms 256 KB
subtask1_10.txt 1 ms 256 KB
subtask1_11.txt 1 ms 256 KB
subtask1_12.txt 1 ms 256 KB