답안 #385644

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
385644 2021-04-04T16:29:03 Z igzi Toys (CEOI18_toy) C++17
0 / 100
1 ms 492 KB
#include <bits/stdc++.h>
 
using namespace std;
 
long long n,k,r,i,j,a[200],b[200],p,m;
vector <pair<long long,long long>> v;
vector <long long> s;
 
vector <long long> dp(int n,int p){
  vector <long long> ans,tmp;
  if(p>n) return ans;
  for(int i=p;i*i<=n;i++){
      if(n%i) continue;
      tmp=dp(n/i,i);
      for(int j=0;j<tmp.size();j++){
          ans.push_back(tmp[j]+i-1);
      }
  }
  ans.push_back(n-1);
}
 
 
int main() {
    cin>>n;
    if(n==1){
        cout<<1<<endl<<0;
        return 0;
    }
    s=(dp(n,2));
    sort(s.begin(),s.end());
    r=1;
    for(i=1;i<s.size();i++){
        if(s[i]!=s[i-1]) r++;
    }
    cout<<r<<endl;
    cout<<s[0]<<" ";
    for(i=1;i<s.size();i++){
        if(s[i]!=s[i-1]) cout<<s[i]<<" ";
    }
    return 0;
}

Compilation message

toy.cpp: In function 'std::vector<long long int> dp(int, int)':
toy.cpp:15:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   15 |       for(int j=0;j<tmp.size();j++){
      |                   ~^~~~~~~~~~~
toy.cpp: In function 'int main()':
toy.cpp:32:14: 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]
   32 |     for(i=1;i<s.size();i++){
      |             ~^~~~~~~~~
toy.cpp:37:14: 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]
   37 |     for(i=1;i<s.size();i++){
      |             ~^~~~~~~~~
toy.cpp: In function 'std::vector<long long int> dp(int, int)':
toy.cpp:10:26: warning: control reaches end of non-void function [-Wreturn-type]
   10 |   vector <long long> ans,tmp;
      |                          ^~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 KB Output is correct
2 Runtime error 1 ms 492 KB Execution killed with signal 6
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 KB Output is correct
2 Runtime error 1 ms 492 KB Execution killed with signal 6
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 KB Output is correct
2 Runtime error 1 ms 492 KB Execution killed with signal 6
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 KB Output is correct
2 Runtime error 1 ms 492 KB Execution killed with signal 6
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 KB Output is correct
2 Runtime error 1 ms 492 KB Execution killed with signal 6
3 Halted 0 ms 0 KB -