답안 #536871

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
536871 2022-03-14T06:30:39 Z chicken337 Toys (CEOI18_toy) C++14
0 / 100
1 ms 212 KB
#include <bits/stdc++.h>
using namespace std;

set<pair<int, int>> vis;

void backtrack(int n, int sum){
    if(vis.find({n, sum}) != vis.end())
        return;
    vis.insert({n, sum});
    bool isprime = (n != 1);
    for(int k = 2; k <= sqrt(n); k ++)
        if(n % k == 0)
            backtrack(n / k, sum + k - 1),
            backtrack(k, sum + (n/k) - 1),
            isprime = false;
    if(isprime)
        backtrack(1, sum + n - 1);
}

signed main(){
    ios::sync_with_stdio(0);
    cin.tie(0);

    int n; cin >> n;
    backtrack(n, 0);

    set<int> unique;
    for(auto &[num, sum] : vis)
        if(num == 1)
            unique.insert(sum);
    cout << unique.size() << '\n';
    for(int it : unique)
        cout << it << ' ';
}

Compilation message

toy.cpp: In function 'int main()':
toy.cpp:28:15: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17'
   28 |     for(auto &[num, sum] : vis)
      |               ^
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Incorrect 1 ms 212 KB Output isn't correct
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Incorrect 1 ms 212 KB Output isn't correct
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Incorrect 1 ms 212 KB Output isn't correct
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Incorrect 1 ms 212 KB Output isn't correct
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Incorrect 1 ms 212 KB Output isn't correct
5 Halted 0 ms 0 KB -