답안 #912777

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
912777 2024-01-19T22:08:13 Z bobbilyking Toys (CEOI18_toy) C++17
0 / 100
1 ms 348 KB
#pragma GCC target ("avx2")
#pragma GCC optimize ("O3")
#pragma GCC optimize ("unroll-loops")
 
#include<bits/stdc++.h>
#include<math.h>
using namespace std;
 
typedef int ll;
typedef long double ld;
typedef pair<ll, ll> pl;
 
#define K first
#define V second
#define G(x) ll x; cin >> x;
#define GD(x) ld x; cin >> x;
#define GS(s) string s; cin >> s;
#define EX(x) { cout << x << '\n'; exit(0); }
#define A(a) (a).begin(), (a).end()
#define F(i, l, r) for (ll i = (l); i < r; ++i)
 
vector<ll> factors;
map<ll, vector<ll>, greater<ll>> dp;
 
int main(){
//    freopen("a.in", "r", stdin);
//    freopen("a.out", "w", stdout);
 
    ios_base::sync_with_stdio(false); cin.tie(0);
    cout << fixed << setprecision(20);
    G(n)
 
    for (ll i = 2; i * i <=n ; ++i) if (n%i == 0){
        factors.push_back(i);
        if (i*i != n) factors.push_back(n/i);
    }
    factors.push_back(n);
    sort(A(factors));

    dp[n].push_back(0);
    for (auto [k, v]: dp) {
        sort(A(v)); 
        v.erase(unique(A(v)), v.end());
        if (k == 1) break;
        for (auto y: factors) if (k >= y) {
            if (k%y == 0)
            for (auto a: v) dp[k/y].push_back(y + a - 1);
        } else break;
    }
 
    cout << dp[1].size() << '\n';
    for (auto x: dp[1]) cout << x << " "; cout << '\n';
}

Compilation message

toy.cpp: In function 'int main()':
toy.cpp:52:5: warning: this 'for' clause does not guard... [-Wmisleading-indentation]
   52 |     for (auto x: dp[1]) cout << x << " "; cout << '\n';
      |     ^~~
toy.cpp:52:43: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'for'
   52 |     for (auto x: dp[1]) cout << x << " "; cout << '\n';
      |                                           ^~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Incorrect 1 ms 344 KB Output isn't correct
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Incorrect 1 ms 344 KB Output isn't correct
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Incorrect 1 ms 344 KB Output isn't correct
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Incorrect 1 ms 344 KB Output isn't correct
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Incorrect 1 ms 344 KB Output isn't correct
5 Halted 0 ms 0 KB -