제출 #321002

#제출 시각아이디문제언어결과실행 시간메모리
321002phathnvToys (CEOI18_toy)C++11
59 / 100
5010 ms23560 KiB
#include <bits/stdc++.h> #define mp make_pair #define X first #define Y second #define taskname "Toys" using namespace std; typedef long long ll; typedef pair <int, int> ii; int n; vector <int> divisors; vector < set<int> > res; map <int, int> pos; void readInput(){ cin >> n; } void solve(){ for(int i = 1; i * i <= n; i++){ if (n % i) continue; divisors.push_back(i); if (i * i != n) divisors.push_back(n / i); } sort(divisors.begin(), divisors.end()); res.resize(divisors.size()); for(int i = 0; i < divisors.size(); i++) pos[divisors[i]] = i; for(int i = 0; i < divisors.size(); i++){ res[i].insert(divisors[i] - 1); for(int j = i + 1; j < divisors.size(); j++){ if (divisors[j] % divisors[i]) continue; set <int> tmp = res[i]; for(int x : tmp) for(int y : res[pos[divisors[j] / divisors[i]]]) res[j].insert(x + y); } } cout << res.back().size() << '\n'; for(int x : res.back()) cout << x << ' '; } int main(){ if (fopen(taskname".inp", "r")){ freopen(taskname".inp", "r", stdin); freopen(taskname".out", "w", stdout); } readInput(); solve(); return 0; }

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

toy.cpp: In function 'void solve()':
toy.cpp:33:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   33 |     for(int i = 0; i < divisors.size(); i++)
      |                    ~~^~~~~~~~~~~~~~~~~
toy.cpp:35:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   35 |     for(int i = 0; i < divisors.size(); i++){
      |                    ~~^~~~~~~~~~~~~~~~~
toy.cpp:37:30: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   37 |         for(int j = i + 1; j < divisors.size(); j++){
      |                            ~~^~~~~~~~~~~~~~~~~
toy.cpp: In function 'int main()':
toy.cpp:53:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)', declared with attribute warn_unused_result [-Wunused-result]
   53 |         freopen(taskname".inp", "r", stdin);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~
toy.cpp:54:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)', declared with attribute warn_unused_result [-Wunused-result]
   54 |         freopen(taskname".out", "w", stdout);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#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...