답안 #654054

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
654054 2022-10-29T16:56:37 Z MasterTaster Toys (CEOI18_toy) C++14
컴파일 오류
0 ms 0 KB
#include <iostream>
#include <vector>
#include <algorithm>

#define ll long long
#define pb push_back

using namespace std;

ll n;
vector<ll> svi, ress;

void dfs(ll x, vector<ll> &d, ll i, ll sum)
{
    if (x==1) return;
    ress.pb(sum+x-1);

    vector<ll> dd;
    while (i<d.size())
    {
        if (x%d[i]==0) dd.pb(d[i]);
        i++;
    }

    for (int i=0; i<dd.size(); i++)
    {
        if (x/dd[i]>=dd[i])
            dfs(x/dd[i], dd, i, sum+dd[i]-1);
    }
}

map<ll, bool> bio;
int main() {
    cin>>n;

    if (n==1) { cout<<1<<endl<<0; exit(0); }

    for (ll i=2; i*i<=n; i++)
        if (n%i==0) svi.pb(i);

    dfs(n, svi, 0, 0);

    vector<ll> r;
    for (int i=0; i<ress.size(); i++) if (!bio[ress[i]]) { bio[ress[i]]=true; r.pb(ress[i]); }

    cout<<r.size()<<endl;
    sort(r.begin(), r.end());
    for (int i=0; i<r.size(); i++) cout<<r[i]<<" ";
}

Compilation message

toy.cpp: In function 'void dfs(long long int, std::vector<long long int>&, long long int, long long int)':
toy.cpp:19:13: 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]
   19 |     while (i<d.size())
      |            ~^~~~~~~~~
toy.cpp:25:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   25 |     for (int i=0; i<dd.size(); i++)
      |                   ~^~~~~~~~~~
toy.cpp: At global scope:
toy.cpp:32:1: error: 'map' does not name a type
   32 | map<ll, bool> bio;
      | ^~~
toy.cpp: In function 'int main()':
toy.cpp:44:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   44 |     for (int i=0; i<ress.size(); i++) if (!bio[ress[i]]) { bio[ress[i]]=true; r.pb(ress[i]); }
      |                   ~^~~~~~~~~~~~
toy.cpp:44:44: error: 'bio' was not declared in this scope
   44 |     for (int i=0; i<ress.size(); i++) if (!bio[ress[i]]) { bio[ress[i]]=true; r.pb(ress[i]); }
      |                                            ^~~
toy.cpp:48:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   48 |     for (int i=0; i<r.size(); i++) cout<<r[i]<<" ";
      |                   ~^~~~~~~~~