Initial commit
This commit is contained in:
BIN
2022/republic/d0/problem05/problem05 (ru).pdf
Normal file
BIN
2022/republic/d0/problem05/problem05 (ru).pdf
Normal file
Binary file not shown.
52
2022/republic/d0/problem05/problem05.cpp
Normal file
52
2022/republic/d0/problem05/problem05.cpp
Normal file
@@ -0,0 +1,52 @@
|
||||
#include <iostream>
|
||||
#include <set>
|
||||
#include <cmath>
|
||||
using namespace std;
|
||||
|
||||
|
||||
int main() {
|
||||
int64_t N;
|
||||
cin >> N;
|
||||
|
||||
|
||||
set<int64_t> factors;
|
||||
|
||||
int64_t stop = sqrt(N);
|
||||
int factorsFound = 0;
|
||||
for (int64_t i = 2; i <= stop; i++) {
|
||||
if (N % i == 0) {
|
||||
factors.insert(i);
|
||||
factors.insert(N / i);
|
||||
factorsFound++; // Does not represent the size of the set, but the amount of highest factors
|
||||
if (factorsFound >= 6) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int64_t power = 0;
|
||||
string result = "DBVJKM";
|
||||
int charactersUsed = 0;
|
||||
|
||||
auto it = factors.rbegin();
|
||||
auto end = factors.rend();
|
||||
|
||||
while (power < N && charactersUsed < 6) {
|
||||
if (it != end) {
|
||||
power += *it;
|
||||
it++;
|
||||
} else {
|
||||
power += 1;
|
||||
}
|
||||
charactersUsed++;
|
||||
}
|
||||
|
||||
if (power < N) {
|
||||
cout << "NO" << endl;
|
||||
} else {
|
||||
result = result.substr(0, charactersUsed);
|
||||
cout << result << endl;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
Reference in New Issue
Block a user