제출 #457886

#제출 시각아이디문제언어결과실행 시간메모리
457886hhhhauraToys (CEOI18_toy)C++14
100 / 100
1641 ms34848 KiB
#define wiwihorz
#pragma GCC optimize("Ofast")
#pragma loop-opt(on)
#include <bits/stdc++.h>

#define rep(i, a, b) for(int i = a; i <= b; i ++)
#define rrep(i, a, b) for(int i = b; i >= a; i--)
#define all(x) x.begin(), x.end()
#define ceil(a, b) ((a + b - 1) / (b))

#define INF 1000000000000000000
#define MOD 1000000007
#define eps (1e-9)

using namespace std;

#define int long long int
#define lld long double
#define pii pair<int, int>
#define random mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count())

#ifdef wiwihorz
#define print(a...) cerr << "Line " << __LINE__ <<": ", kout("[" + string(#a) + "] = ", a)
void kout() {cerr << endl;}
void vprint(auto L, auto R) { cerr << *L << " \n"[next(L) == R], ++L;}
template<class T1, class ... T2> void kout(T1 a, T2 ... e) { cerr << a << " ", kout(e...); }
#else
#define print(...) 0
#define vprint(...) 0
#endif
namespace solver {
	vector<int> ans;
	vector<vector<int>> v(10000, vector<int>());
	map<int, int> mp;
	int ii = 0;
	void solve(int n, int sum, int big) {
		if(n == 1) {
			ans.push_back(sum);
			return;
		}
		if(mp.find(n) == mp.end()) {
			mp[n] = ++ii;
			for(int i = 2; i * i <= n; i ++) {
				if(n % i) continue;
				v[ii].push_back(i);
				v[ii].push_back(n/ i);
			}
			v[ii].push_back(n);
		}
		int id = mp[n];
		for(auto i : v[id]) 
			if(i >= big) solve(n / i, sum + i - 1, i);
		return;
	}
};
using namespace solver;
signed main() {
	ios::sync_with_stdio(false), cin.tie(0);
	int n; 
	cin >> n;
	solve(n, 0, 0);
	sort(all(ans));
	ans.resize(unique(all(ans)) - ans.begin());
	cout << ans.size() << "\n";
	rep(i, 0, signed(ans.size()) - 1) {
		cout << ans[i] << " \n"[i + 1 == ans.size()];
	}
	return 0;
}

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

toy.cpp:3: warning: ignoring '#pragma loop ' [-Wunknown-pragmas]
    3 | #pragma loop-opt(on)
      | 
toy.cpp:25:13: warning: use of 'auto' in parameter declaration only available with '-fconcepts-ts'
   25 | void vprint(auto L, auto R) { cerr << *L << " \n"[next(L) == R], ++L;}
      |             ^~~~
toy.cpp:25:21: warning: use of 'auto' in parameter declaration only available with '-fconcepts-ts'
   25 | void vprint(auto L, auto R) { cerr << *L << " \n"[next(L) == R], ++L;}
      |                     ^~~~
toy.cpp: In function 'int main()':
toy.cpp:66:33: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   66 |   cout << ans[i] << " \n"[i + 1 == ans.size()];
      |                           ~~~~~~^~~~~~~~~~~~~
#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...