제출 #1260807

#제출 시각아이디문제언어결과실행 시간메모리
1260807Bui_Quoc_CuongToys (CEOI18_toy)C++20
100 / 100
2061 ms86480 KiB
#include <bits/stdc++.h>
using namespace std;
template <class A, class B>
    bool maximize(A &a, const B b) {
        if (a < b) {
            a = b;
            return true;
        } return false;
    }
template <class A, class B>
    bool minimize(A &a, const B b) {
        if (a > b) {
            a = b;
            return true;
        } return false;
    }
#define pb push_back
#define FOR(i, a, b) for(int i = a; i <= (int)b; i++)
#define FORD(i, a, b) for(int i = a; i >= (int)b; i--)
#define fi first
#define se second
#define ALL(A) A.begin(), A.end()

typedef vector<int> vi;
typedef pair<int, int> ii;
typedef long long ll;

const int N = 3e5 + 5;
const int oo = 2e9 + 29032008;
const ll INF = 1e18 + 29032008;

int n;
map <int, int> dp[1360];
// int newpos[1360][1360];

void solve() {
	cin >> n;
	vector <int> v;
	for (int i = 1; i * i <= n; i++) if (n % i == 0) {
		v.push_back(i);
		if (n / i != i) v.push_back(n / i);
	}
	sort(ALL(v));
	// memset(newpos, - 1, sizeof newpos);
	// for (int i = 0; i < (int)v.size(); i++) {
	// 	for (int j = 0; j < (int)v.size(); j++) {
	// 		if (1LL * v[i] * v[j] > n) break;
	// 		if (n % (v[i] * v[j]) != 0) continue;
	// 		int pos = lower_bound(ALL(v), v[i] * v[j]) - v.begin();
	// 		newpos[i][j] = newpos[j][i] = pos;
	// 	}
	// }
	dp[0][0] = 1;
	for (int i = 0; i < (int)v.size(); i++) {
		for (int j = 0; j < (int)i; j++) {
			if (v[i] % v[j] == 0) {
				for (auto &x : dp[j]) {
					dp[i][x.first + v[i] / v[j] - 1] = 1;
				}
			}
		}
	}
	cout << dp[(int)v.size() - 1].size() << "\n";
	for (auto &x : dp[(int)v.size() - 1]) cout << x.first << " ";
}

signed main() {
    ios_base::sync_with_stdio(false); cin.tie(nullptr);
    #define ko "kieuoanh"
    if (fopen(ko".inp", "r")) { 
        freopen(ko".inp", "r", stdin); 
        freopen(ko".out", "w", stdout);
    }

    int NTEST = 1; // cin >> NTEST;
    while (NTEST--) solve();
    
    cerr << "\n[Time Elapsed] " << 0.001 * clock() << "s\n";
    return 0;
}

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

toy.cpp: In function 'int main()':
toy.cpp:71:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   71 |         freopen(ko".inp", "r", stdin);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~
toy.cpp:72:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   72 |         freopen(ko".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...