답안 #70610

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
70610 2018-08-23T07:29:11 Z cs(#2192) Toys (CEOI18_toy) C++11
0 / 100
5 ms 3372 KB
#include<stdio.h>
#include<vector>
#include<map>
#include<algorithm>
using namespace std;
int mn;
map<int, int>M;
vector<int>L[121212];
void get_ans(int n) {
	if (M.find(n) != M.end())return;
	int now = M[n] = ++mn; L[mn].push_back(n - 1);
	int i, j, w;
	for (i = 2; i*i <= n; i++) {
		if (n%i == 0) {
			get_ans(i), get_ans(n / i);
			w = M[i];
			for (j = 0; j < L[w].size(); j++)
				L[now].push_back(L[w][j] + (i - 1));
			w = M[n/i];
			for (j = 0; j < L[w].size(); j++)
				L[now].push_back(L[w][j] + (i - 1));
		}
	}
	sort(L[now].begin(),L[now].end());
	L[now].erase(unique(L[now].begin(), L[now].end()), L[now].end());
}

int main() {
	long long n, i, j; scanf("%d", &n);
	get_ans(n);
	int w = M[n];
	printf("%d\n", L[w].size());
	for (i = 0; i < L[w].size(); i++) {
		printf("%d ", L[w][i]);
	}
	return 0;
}

Compilation message

toy.cpp: In function 'void get_ans(int)':
toy.cpp:17:18: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
    for (j = 0; j < L[w].size(); j++)
                ~~^~~~~~~~~~~~~
toy.cpp:20:18: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
    for (j = 0; j < L[w].size(); j++)
                ~~^~~~~~~~~~~~~
toy.cpp: In function 'int main()':
toy.cpp:29:35: warning: format '%d' expects argument of type 'int*', but argument 2 has type 'long long int*' [-Wformat=]
  long long n, i, j; scanf("%d", &n);
                                 ~~^
toy.cpp:32:28: warning: format '%d' expects argument of type 'int', but argument 2 has type 'std::vector<int>::size_type {aka long unsigned int}' [-Wformat=]
  printf("%d\n", L[w].size());
                 ~~~~~~~~~~~^
toy.cpp:33:16: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for (i = 0; i < L[w].size(); i++) {
              ~~^~~~~~~~~~~~~
toy.cpp:29:18: warning: unused variable 'j' [-Wunused-variable]
  long long n, i, j; scanf("%d", &n);
                  ^
toy.cpp:29:26: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  long long n, i, j; scanf("%d", &n);
                     ~~~~~^~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 3068 KB Output is correct
2 Correct 5 ms 3176 KB Output is correct
3 Correct 4 ms 3248 KB Output is correct
4 Correct 5 ms 3372 KB Output is correct
5 Correct 5 ms 3372 KB Output is correct
6 Incorrect 5 ms 3372 KB Output isn't correct
7 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 3068 KB Output is correct
2 Correct 5 ms 3176 KB Output is correct
3 Correct 4 ms 3248 KB Output is correct
4 Correct 5 ms 3372 KB Output is correct
5 Correct 5 ms 3372 KB Output is correct
6 Incorrect 5 ms 3372 KB Output isn't correct
7 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 3068 KB Output is correct
2 Correct 5 ms 3176 KB Output is correct
3 Correct 4 ms 3248 KB Output is correct
4 Correct 5 ms 3372 KB Output is correct
5 Correct 5 ms 3372 KB Output is correct
6 Incorrect 5 ms 3372 KB Output isn't correct
7 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 3068 KB Output is correct
2 Correct 5 ms 3176 KB Output is correct
3 Correct 4 ms 3248 KB Output is correct
4 Correct 5 ms 3372 KB Output is correct
5 Correct 5 ms 3372 KB Output is correct
6 Incorrect 5 ms 3372 KB Output isn't correct
7 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 3068 KB Output is correct
2 Correct 5 ms 3176 KB Output is correct
3 Correct 4 ms 3248 KB Output is correct
4 Correct 5 ms 3372 KB Output is correct
5 Correct 5 ms 3372 KB Output is correct
6 Incorrect 5 ms 3372 KB Output isn't correct
7 Halted 0 ms 0 KB -