Submission #130006

#TimeUsernameProblemLanguageResultExecution timeMemory
130006OptxPrimeToys (CEOI18_toy)C++11
59 / 100
5053 ms25016 KiB
#include <iostream>
#include <cmath>
#include<vector>
#include <algorithm>
#include <utility>
#include<stack>
#include<queue>
#include<map>
#include <fstream>
#include<set>

using namespace std;

#define pb push_back
#define mp make_pair
#define ll long long

    //map<int,bool> res;
    map<int, set<int>> sums;

    void num( int x )
    {
        sums[x].insert( x-1 );
        for( int i=2;i<=sqrt(x);i++ ){
                if( ( x%i )!= 0 ) continue;
            if( sums[i].size() == 0 )num(i);
            if( sums[ x/i ].size() == 0 ) num( (x/i) );
           for( auto j:sums[i] ){
                for( auto k:sums[x/i] ){
                    //    cout << x << " " << i << " " <<x/i << " " << j << " "<< k
                     sums[x].insert( j+k );
                }
           }
        }
    }

    int main()
    {
        ios_base::sync_with_stdio(false);
        cin.tie(NULL);

        int n;
        cin>>n;
        num(n);
        cout<<sums[n].size()<<endl;
        for( auto i:sums[n] )
            cout<<i<<" ";
            cout<<endl;

      return 0;
    }



























Compilation message (stderr)

toy.cpp: In function 'int main()':
toy.cpp:46:9: warning: this 'for' clause does not guard... [-Wmisleading-indentation]
         for( auto i:sums[n] )
         ^~~
toy.cpp:48:13: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'for'
             cout<<endl;
             ^~~~
#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...