제출 #130041

#제출 시각아이디문제언어결과실행 시간메모리
130041OptxPrimeToys (CEOI18_toy)C++11
59 / 100
5089 ms132048 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 //#define maxn 100005 //map<int,bool> res; map<int, set<int>> sums; int maxn=1000000; vector<int> fac[1000010]; void num( int x ) { sums[x].insert( x-1 ); if( x>maxn ){ ///pravo velik broj, kakvih ima najvise stotinjak 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] ){ sums[x].insert( j+k ); } } } } else{ for( auto i:fac[x] ){ // cout <<x << " " << i << " et " <<endl; if( i>sqrt(x) ) break; 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 << " " << j << " " << k <<endl; sums[x].insert( j+k ); } } } } } int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); int n; cin>>n; for( int i=2;i<=maxn;i++ ){ for( int j=i;j<=maxn;j+=i ){ // cout << j <<endl; fac[j].pb( i ); } } // cout << " bral;e " <<endl; num(n); /// brza faktorizacija? jer za svaki broj mi idemo do korjena pa cak i za 10^9 samo su nam bitni do korjena cout<<sums[n].size()<<endl; for( auto i:sums[n] ) cout<<i<<" "; cout<<endl; return 0; }

컴파일 시 표준 에러 (stderr) 메시지

toy.cpp: In function 'int main()':
toy.cpp:74:9: warning: this 'for' clause does not guard... [-Wmisleading-indentation]
         for( auto i:sums[n] )
         ^~~
toy.cpp:76: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...