Submission #385647

#TimeUsernameProblemLanguageResultExecution timeMemory
385647igziToys (CEOI18_toy)C++17
100 / 100
793 ms50956 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> 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); return ans; } 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 (stderr)

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:33: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]
   33 |     for(i=1;i<s.size();i++){
      |             ~^~~~~~~~~
toy.cpp:38: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]
   38 |     for(i=1;i<s.size();i++){
      |             ~^~~~~~~~~
#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...