Submission #1797122
Source Code Expand
#include <bits/stdc++.h> #define rep(i,n) for(int i=0;i<(n);++i) #define ALL(A) A.begin(), A.end() #define INF 1<<28 using namespace std; typedef long long ll; typedef pair<int, int> P; int main() { ios_base::sync_with_stdio(0); cin.tie(0); int n; cin >> n; int res = INF; for (int i = 1; i <= n; ++i){ cerr << "i: " << i << endl; for (int j = 1; j <= (int)(sqrt(i)+0.5); ++j){ if (i % j == 0){ int curr = n - i + abs(i/j - j); // cerr << "i/j: " << i/j << " j: " << j << " curr: " << curr << endl; res = min(res, curr); } // end if } // end for } // end for cout << res << endl; return 0; }
Submission Info
Submission Time | |
---|---|
Task | B - □□□□□ |
User | ty70 |
Language | C++14 (GCC 5.4.1) |
Score | 100 |
Code Size | 663 Byte |
Status | AC |
Exec Time | 196 ms |
Memory | 256 KB |
Judge Result
Set Name | Sample | All | ||||
---|---|---|---|---|---|---|
Score / Max Score | 0 / 0 | 100 / 100 | ||||
Status |
|
|
Set Name | Test Cases |
---|---|
Sample | sample_01.txt, sample_02.txt, sample_03.txt |
All | 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 | AC | 1 ms | 256 KB |
sample_02.txt | AC | 1 ms | 256 KB |
sample_03.txt | AC | 196 ms | 256 KB |
subtask1_01.txt | AC | 1 ms | 256 KB |
subtask1_02.txt | AC | 1 ms | 256 KB |
subtask1_03.txt | AC | 1 ms | 256 KB |
subtask1_04.txt | AC | 189 ms | 256 KB |
subtask1_05.txt | AC | 190 ms | 256 KB |
subtask1_06.txt | AC | 181 ms | 256 KB |
subtask1_07.txt | AC | 120 ms | 256 KB |
subtask1_08.txt | AC | 188 ms | 256 KB |
subtask1_09.txt | AC | 135 ms | 256 KB |
subtask1_10.txt | AC | 4 ms | 256 KB |
subtask1_11.txt | AC | 106 ms | 256 KB |
subtask1_12.txt | AC | 81 ms | 256 KB |