답안 #654049

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
654049 2022-10-29T16:46:50 Z MasterTaster Toys (CEOI18_toy) C++14
0 / 100
0 ms 212 KB
#include <bits/stdc++.h>

#define ll long long
#define pb push_back

using namespace std;

int n;
vector<ll> svi, ress;

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

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

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

bool bio[100010];

int main() {
    int n; cin>>n;

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

    dfs(n, svi, 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(int, std::vector<long long int>&, int)':
toy.cpp:17:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   17 |     for (int i=0; i<d.size(); i++) if (x%d[i]==0) dd.pb(d[i]);
      |                   ~^~~~~~~~~
toy.cpp:19:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   19 |     for (int i=0; i<dd.size(); i++)
      |                   ~^~~~~~~~~~
toy.cpp: In function 'int main()':
toy.cpp:37:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   37 |     for (int i=0; i<ress.size(); i++) if (!bio[ress[i]]) { bio[ress[i]]=true; r.pb(ress[i]); }
      |                   ~^~~~~~~~~~~~
toy.cpp:41:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   41 |     for (int i=0; i<r.size(); i++) cout<<r[i]<<" ";
      |                   ~^~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -