Submission #920774

#TimeUsernameProblemLanguageResultExecution timeMemory
920774Faisal_SaqibToys (CEOI18_toy)C++17
100 / 100
3082 ms90312 KiB
#pragma GCC optimize ("Ofast") #pragma GCC optimize ("unroll-loops") #include <iostream> #include <map> #include <set> using namespace std; map<int,set<int>> mp; void pos(long long&x) { auto it=mp.find(x); if(it!=mp.end()) return; set<int> cur={x-1}; for(long long d=2;(d*d)<=x;d++) { if(x%d==0) { long long rem=x/d; pos(rem); auto nxt=mp[rem]; for(auto j:nxt) cur.insert(j+(d-1)); if((d*d)!=x) { d=x/d; long long rem=x/d; pos(rem); auto nxt=mp[rem]; for(auto j:nxt) cur.insert(j+(d-1)); d=x/d; } } } mp[x]=cur; } int main() { cin.tie(0); cout.tie(0); ios::sync_with_stdio(0); long long n; cin>>n; pos(n); auto tlp=mp[n]; cout<<tlp.size()<<endl; for(auto j:tlp) { cout<<j<<' '; } cout<<endl; }

Compilation message (stderr)

toy.cpp: In function 'void pos(long long int&)':
toy.cpp:14:17: warning: narrowing conversion of '(x - 1)' from 'long long int' to 'int' [-Wnarrowing]
   14 |  set<int> cur={x-1};
      |                ~^~
toy.cpp:14:17: warning: narrowing conversion of '(x - 1)' from 'long long int' to 'int' [-Wnarrowing]
#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...