Submission #78131

#TimeUsernameProblemLanguageResultExecution timeMemory
78131igziToys (CEOI18_toy)C++17
100 / 100
981 ms51980 KiB
#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> resi(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=resi(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=(resi(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 (stderr)

toy.cpp: In function 'std::vector<long long int> resi(int, int)':
toy.cpp:15:20: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
       for(int j=0;j<tmp.size();j++){
                   ~^~~~~~~~~~~
toy.cpp: In function 'int main()':
toy.cpp:32:14: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for(i=1;i<s.size();i++){
             ~^~~~~~~~~
toy.cpp:37:14: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for(i=1;i<s.size();i++){
             ~^~~~~~~~~
toy.cpp: In function 'std::vector<long long int> resi(int, int)':
toy.cpp:20:1: warning: control reaches end of non-void function [-Wreturn-type]
 }
 ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...