Submission #536826

#TimeUsernameProblemLanguageResultExecution timeMemory
536826errorgornToys (CEOI18_toy)C++17
100 / 100
654 ms33312 KiB
#include <bits/stdc++.h>
using namespace std;

#define int long long
#define ll long long
#define ii pair<ll,ll>
#define fi first
#define se second
#define endl '\n'

#define puf push_front
#define pof pop_front
#define pub push_back
#define pob pop_back
#define lb lower_bound
#define ub upper_bound

#define rep(x,s,e) for (auto x=(s)-((s)>(e));x!=(e)-((s)>(e));(s)<(e)?x++:x--)
#define all(x) (x).begin(),(x).end()
#define sz(x) (int) (x).size()

mt19937 rng(chrono::system_clock::now().time_since_epoch().count());

int n;
vector<int> divi;
vector<int> ans;

void solve(int i,int lim,int cnt,int val){
	if (i==1){
		ans.pub(val);
		return;
	}
	
	for (auto it:divi){
		if (it>lim) break;
		if (i%it==0) solve(i/it,it,cnt-1,val+it-1);
	}
}

signed main(){
	cin.tie(0);
	cout.tie(0);
	cin.sync_with_stdio(false);
	
	cin>>n;
	
	rep(x,1,100000) if (n%x==0){
		if (x*x>n) break;
		
		if (x>1) divi.pub(x);
		if (x*x!=n) divi.pub(n/x);
	}
	
	sort(all(divi));
	//for (auto it:divi) cout<<it<<" "; cout<<endl;
	
	solve(n,n,4,0);
	
	sort(all(ans));
	ans.erase(unique(all(ans)),ans.end());
	
	cout<<sz(ans)<<endl;
	for (auto it:ans) cout<<it<<" "; cout<<endl;
	
}

Compilation message (stderr)

toy.cpp: In function 'int main()':
toy.cpp:63:2: warning: this 'for' clause does not guard... [-Wmisleading-indentation]
   63 |  for (auto it:ans) cout<<it<<" "; cout<<endl;
      |  ^~~
toy.cpp:63:35: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'for'
   63 |  for (auto it:ans) cout<<it<<" "; 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...