Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // OK greedy Timus 1014 https://acm.timus.ru/problem.aspx?space=1&num=1014
- # include <iostream>
- # include <vector>
- using namespace std;
- int main() {
- int32_t q;
- cin >> q;
- if (q == 1) {
- cout << 1;
- return 0;
- }
- if (q == 0) {
- cout << 10;
- return 0;
- }
- vector<int32_t> res(10, 0);
- for (int32_t i = 9; i > 1 && q != 1; i--) {
- while (q % i == 0) {
- res[i]++;
- q /= i;
- }
- }
- if (q != 1) {
- cout << -1;
- }
- else {
- for (size_t i = 1; i < 10; i++) {
- for (size_t j = 0; j < res[i]; j++) {
- cout << i;
- }
- }
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement