Submission #1070976

#TimeUsernameProblemLanguageResultExecution timeMemory
1070976YassirSalamaToys (CEOI18_toy)C++17
19 / 100
775 ms262144 KiB
#include<bits/stdc++.h> using namespace std; #define pb push_back template<typename T> ostream& operator << (ostream& out,vector<T> v){ int i=0; out<< " { "; for(auto x:v){ out << x; i++; if(i==v.size()) break; out << " , "; } out << " } "; return out; } template<typename T> void dbg(const T& t){ cout<<t<<"\n"; } template<typename T,typename... Args> void dbg(const T& t,const Args&... args){ cout<<t<<" , "; dbg(args...); } #define dbg(...) cout<<"("<<#__VA_ARGS__<<") : ";dbg(__VA_ARGS__); #define all(v) v.begin(),v.end() set<vector<int>> decomp; set<vector<int>> c; signed main(){ ios_base::sync_with_stdio(0);cin.tie(0); int n; cin>>n; if(n==1){ printf("1\n0");return 0; } vector<int> p; for(int i=2;i*i<=n;i++){ while(n%i==0) p.pb(i),n/=i; } if(n!=1) p.pb(n); vector<int> t(40,1e9); decomp.insert({p[0]}); for(int i=1;i<p.size();i++){ c.clear(); int pp=p[i]; for(auto &x:decomp){ for(int j=0;j<x.size();j++){ if(x[j]==1e9) break; for(int a=0;a<x.size();a++) t[a]=x[a]; t[j]*=pp; sort(all(t)); c.insert(t); } for(int a=0;a<x.size();a++) t[a]=x[a]; t.pb(pp); sort(all(t)); c.insert(t); for(int i=0;i<40;i++) t[i]=1e9; } decomp=c; } set<int> ans; for(auto &x:decomp){ int s=0; for(auto &y:x){ if(y==1e9) break; s+=y-1; } ans.insert(s); } cout<<ans.size()<<"\n"; for(auto x:ans){ cout<<x<<" "; } cout<<"\n"; }

Compilation message (stderr)

toy.cpp: In function 'int main()':
toy.cpp:44:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   44 |     for(int i=1;i<p.size();i++){
      |                 ~^~~~~~~~~
toy.cpp:48:26: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   48 |             for(int j=0;j<x.size();j++){
      |                         ~^~~~~~~~~
toy.cpp:50:30: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   50 |                 for(int a=0;a<x.size();a++) t[a]=x[a];
      |                             ~^~~~~~~~~
toy.cpp:55:26: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   55 |             for(int a=0;a<x.size();a++) t[a]=x[a];
      |                         ~^~~~~~~~~
#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...