Submission #1070954

# Submission time Handle Problem Language Result Execution time Memory
1070954 2024-08-22T21:46:26 Z YassirSalama Toys (CEOI18_toy) C++17
0 / 100
1 ms 348 KB
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
template<typename T> 
ostream& operator << (ostream& out,vector<T> v){
    int i=0;
    for(auto x:v){
        out << x;
        i++;
        if(i==v.size()) break;
        out << " , ";
    }
    out << endl;
    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(){
    int n;
    cin>>n;
    int x=n;
    vector<int> p;
    for(int i=2;;i++){
        if(i*i>n) break;
        while(n%i==0){
            p.pb(i);
            n/=i;
        }
    }
    if(n!=1) p.pb(n);
    // dbg(p)
    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++){
                vector<int> t=x;
                t[j]*=pp;
                sort(all(t));
                c.insert(t);
            }
            vector<int> t=x;
            t.pb(pp);
            sort(all(t));
            c.insert(t);
        }
        decomp=c;
    }
    vector<int> ans;
    for(auto &x:decomp){
        long long s=0;
        for(auto &y:x){
            s+=y-1;
        }
        ans.pb(s);
    }
    sort(all(ans));
    ans.erase(unique(all(ans)),ans.end());
    cout<<ans.size()<<"\n";
    for(auto x:ans){
        cout<<x<<" ";
    }
    cout<<"\n";
}

Compilation message

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:32:9: warning: unused variable 'x' [-Wunused-variable]
   32 |     int x=n;
      |         ^
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 348 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 348 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 348 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 348 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 348 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -