Submission #112405

# Submission time Handle Problem Language Result Execution time Memory
112405 2019-05-19T15:55:03 Z reda Toys (CEOI18_toy) C++14
Compilation error
0 ms 0 KB
#include <bits/stdc++.h>
using namespace std;
int n;
vector <int> v;
vector <int>  ans;
set <int> r;
void dfs (int a, vector <int> v, int s=0 )
{
	ans.push_back(s+a-1);
	for (int m:v)
	{
		if (a%m == 0)
			dfs(a/m,v,s+m-1);
	}
}
int main()
{
	cin >> n;
	for (int i=2; i*i<=n;i++)
	{
		if (n%i!=0) continue;
		v.push_back(i);
		if (i!=n/i)
			v.push_back(n/i);
	}
	dfs(n, v);
	for (auto  i : ans)
		r.insert(i);
	cout << res.size() << endl;
	for (auto it : res)
      cout<<it<<' ';
}

Compilation message

toy.cpp: In function 'int main()':
toy.cpp:29:10: error: 'res' was not declared in this scope
  cout << res.size() << endl;
          ^~~
toy.cpp:30:17: error: unable to deduce 'auto&&' from 'res'
  for (auto it : res)
                 ^~~