Submission #459298

# Submission time Handle Problem Language Result Execution time Memory
459298 2021-08-08T11:43:18 Z Killer2501 Toys (CEOI18_toy) C++14
0 / 100
5000 ms 4940 KB
#include <bits/stdc++.h>
using namespace std;
#define ll int
#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;
ll cal(ll n, ll lst, ll sum)
{
    if(n >= lst)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

toy.cpp: In function 'int cal(int, int, int)':
toy.cpp:79:1: warning: no return statement in function returning non-void [-Wreturn-type]
   79 | }
      | ^
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 time Memory Grader output
1 Execution timed out 5057 ms 4940 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 5057 ms 4940 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 5057 ms 4940 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 5057 ms 4940 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 5057 ms 4940 KB Time limit exceeded
2 Halted 0 ms 0 KB -