답안 #70505

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
70505 2018-08-23T04:54:25 Z 아기상수(#2194) Toys (CEOI18_toy) C++11
0 / 100
2 ms 376 KB
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <memory.h>
#include <math.h>
#include <assert.h>
#include <queue>
#include <map>
#include <set>
#include <string>
#include <algorithm>
#include <iostream>
#include <functional>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <bitset>

using namespace std;
typedef long long ll;
#define Fi first
#define Se second
#define pb(x) push_back(x)
#define szz(x) ((int)(x).size())
#define rep(i, n) for(int i=0;i<n;i++)
#define all(x) (x).begin(), (x).end()
typedef tuple<int, int, int> t3;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef long double ldouble;

vector <pii> V;
vector <int> L;

void dfs(int x, int y = 1) {
	if(x == szz(V)) { L.pb(y); return; }
	rep(i, V[x].Se + 1) {
		dfs(x + 1, y);
		y = y * V[x].Fi;
	}
}

vector <int> ans[1550];

int main() {
	int n; scanf("%d", &n);
	int tn = n;
	for(int i=2;i*i<=tn;i++) {
		if(tn % i != 0) continue;
		int cnt = 0;
		while(tn % i == 0) ++cnt, tn /= i;
		V.emplace_back(i, cnt);
	}
	if(tn > 1) V.emplace_back(tn, 1);
	dfs(0);
	sort(all(L));
	for(int i=1;i<szz(L);i++) {
		ans[i].pb(L[i] - 1);
		for(int j=1;j<i;j++) if(L[i] % L[j] == 0) {
			int k = (int)(lower_bound(all(L), L[i] / L[j]) - L.begin());
			for(int e : ans[k]) ans[i].pb(e + L[j] - 1);
		}
		sort(all(ans[i]));
		ans[i].resize(unique(all(ans[i])) - ans[i].begin());
	}
	printf("%d\n", szz(ans[szz(L)-1]));
	for(int e : ans[szz(L)-1]) printf("%d ", e); puts("");
	return 0;
}

Compilation message

toy.cpp: In function 'int main()':
toy.cpp:67:2: warning: this 'for' clause does not guard... [-Wmisleading-indentation]
  for(int e : ans[szz(L)-1]) printf("%d ", e); puts("");
  ^~~
toy.cpp:67:47: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'for'
  for(int e : ans[szz(L)-1]) printf("%d ", e); puts("");
                                               ^~~~
toy.cpp:46:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  int n; scanf("%d", &n);
         ~~~~~^~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 376 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 376 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 376 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 376 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 376 KB Output isn't correct
2 Halted 0 ms 0 KB -