답안 #490997

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
490997 2021-11-30T03:06:43 Z baokhue232005 Toys (CEOI18_toy) C++14
0 / 100
1 ms 204 KB
/*
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#pragma GCC optimize("unroll-loops")
*/
// lethal option

#include<bits/stdc++.h>
using namespace std;

#define all(flg) flg.begin(), flg.end()
#define int long long
#define pb push_back
#define fi first
#define se second
// #define endl "\n"
#define eb emplace_back
#define ii pair<int, int>
#define PI 3.141592653589793238462643383279502884
#define ll long long
#define for1(i, ff, gg) for(int i = ff; i <= gg; ++i)
#define for2(i, ff, gg) for(int i = ff; i >= gg; --i)
const ll mod = 1e9 + 7;
const int maxN = 300005;
const ll oo = 1e18 + 7;
int n, a[maxN];
int x, y, z, k;

vector<int> ans;

vector<int> back(int god, int dnlim, int sum){
    vector<int> buo;
    int db = sqrt(god);
    if(dnlim > god) return buo;
    buo.pb(sum + god - 1);
    for1(i, dnlim, db) if(god % i == 0){
        auto cm = back(god / i, i, sum + i - 1);

        buo.insert(buo.end(), all(cm));
    }
    // cout << god << " " << dnlim << ' ' << sum << "\n";
    // for(int cc : buo) cout << cc << " ";
    // cout << endl;
    return buo;
}

signed main(){
    ios_base::sync_with_stdio(0);
    cin.tie(NULL);
    cout.tie(NULL);
    cin >> n;
    if(n == 1){
        cout << "0\n\n"; return 0;
    }
    ans = back(n, 2, 0);
    sort(all(ans));
    int vl = 0;
    for1(i, 0, ans.size() - 1){
        if(i == 0 || ans[i] != ans[i - 1]) ++vl;
    }
    cout << vl << endl;
    for1(i, 0, ans.size() - 1){
        if(i == 0 || ans[i] != ans[i - 1]) cout << ans[i] << " ";
    }
    cout << endl;
}

Compilation message

toy.cpp: In function 'int main()':
toy.cpp:21:43: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   21 | #define for1(i, ff, gg) for(int i = ff; i <= gg; ++i)
......
   58 |     for1(i, 0, ans.size() - 1){
      |          ~~~~~~~~~~~~~~~~~~~~              
toy.cpp:58:5: note: in expansion of macro 'for1'
   58 |     for1(i, 0, ans.size() - 1){
      |     ^~~~
toy.cpp:21:43: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   21 | #define for1(i, ff, gg) for(int i = ff; i <= gg; ++i)
......
   62 |     for1(i, 0, ans.size() - 1){
      |          ~~~~~~~~~~~~~~~~~~~~              
toy.cpp:62:5: note: in expansion of macro 'for1'
   62 |     for1(i, 0, ans.size() - 1){
      |     ^~~~
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 204 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 204 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 204 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 204 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 204 KB Output isn't correct
2 Halted 0 ms 0 KB -