Submission #459307

#TimeUsernameProblemLanguageResultExecution timeMemory
459307Killer2501Toys (CEOI18_toy)C++14
100 / 100
885 ms9104 KiB
#include <bits/stdc++.h> using namespace std; #define ll long long #define pll pair<ll, ll> #define fi first #define se second #define pb push_back const int N = 1e5+5; const long long mod = 1e9+7; const long double pi = acos(-1); const int base = 300; ll k, t; ll a[N], ans, m, n, b[N], tong, d[N], c[N], lab[N], cnt, h[N], P[N][20]; vector<pll> val[N]; vector<ll> adj[N], res; ll pw(ll k, ll n) { ll total = 1; for(; n; n >>= 1) { if(n & 1)total = total * k % mod; k = k * k % mod; } return total; } template<typename T> void read(T&x) { bool Neg=false; char c; for(c= getchar();c<'0'||c>'9';c=getchar()) if(c=='-') Neg =!Neg; x = c-'0'; for (c=getchar();c>='0'&&c<='9';c=getchar()) x=x*10+c-'0'; if(Neg&&x>0) x=-x; } ll findp(ll u) { return lab[u] < 0 ? u : lab[u] = findp(lab[u]); } bool hop(ll u, ll v) { u = findp(u); v = findp(v); if(u == v)return false; if(lab[u] > lab[v])swap(u, v); lab[u] += lab[v]; lab[v] = u; return true; } string s; void dfs(ll u, ll p) { d[u] = ++t; for(ll i : adj[u]) { ll v = a[i] + b[i] - u; if(v == p)continue; c[v] = i; P[v][0] = u; h[v] = h[u] + 1; for(int i = 1; i <= 18; i ++)P[v][i] = P[P[v][i-1]][i-1]; dfs(v, u); } } set<ll> st; void cal(ll n, ll lst, ll sum) { st.insert(sum+n-1); for(int i = lst; i <= n / i; i ++) { if(n % i == 0) { cal(n/i, i, sum+i-1); } } } void sol() { cin >> n; cal(n, 2, 0); cout << st.size() << '\n'; for(ll x : st)cout << x <<" "; } int main() { cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0); #define task "testss" if(fopen(task".inp", "r")) { freopen(task".inp", "r", stdin); freopen(task".out", "w", stdout); } int ntest = 1; //cin >> ntest; while(ntest -- > 0) sol(); } /* 10 4 5 4 3 2 -1 0 0 0 0 0 */

Compilation message (stderr)

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