Submission #1010193

# Submission time Handle Problem Language Result Execution time Memory
1010193 2024-06-28T12:56:16 Z andecaandeci Toys (CEOI18_toy) C++17
Compilation error
0 ms 0 KB
#include <bits/stdc++.h>
 
#define ll long long
#define en "\n"
#define pb push_back
#define mp make_pair
#define pii pair<ll,ll>
#define fi first
#define se second
#define rep(i, a, b) for(ll i = a; i <= b; ++i)
#define per(i, a, b) for(ll i = a; i >= b; --i)
#define kaizokuO ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define r0 return 0
#define all(v) v.begin(), v.end()
#define gcd(a,b) __gcd(a,b);
#define lcm(a,b) (a*b)/ __gcd(a, b)
#define bitt(x) __builtin_popcount(x)
#define fill1(arr, i, n) for(ll a = 0; a <= n; ++a) arr[a] = i;
#define fill2(arr, i, n, m) for(ll a = 0; a <= n; ++a) for(ll b = 0; b <= m; ++b) arr[a][b] = i;
#define flsh fflush(stdout)
#define ext exit(0)
#define inp freopen("input.txt","r",stdin)
#define outp freopen("output.txt","w",stdout)
 
using namespace std;
 
//const ll mod = 1e9 + 7;
//const ll mod = 998244353;
//const ll mod = 26101991;
//const ll mod = 1e8;
//const double pi = 3.14159;
pii dir[4] = {{1, 0}, {-1, 0}, {0, 1}, {0, -1}};

vector<ll> ans;
map<ll,ll> vis;
void dfs(ll x, ll sum){
    bool valid = 0;
    for(ll i = 2; i*i <= x; ++i){
        if(x%i!=0) continue;
        if(x/i==1) continue;
        if(!vis[sum+i-1+(x/i)-1]){
            ans.pb(sum+i-1+(x/i)-1);
            vis[sum+i-1+(x/i)-1] = true;
        }
        dfs(x/i, sum + i - 1, i);
        valid = 1;
    }



}
void solve(){
    ll n; cin >> n;
    dfs(n, 0);
    ans.pb(n-1);
    sort(ans.begin(), ans.end());
    cout << ans.size() << en;
    for(ll i : ans) cout << i << " ";
    cout << en;
}
 

int main() {
    kaizokuO;
 
    ll t = 1; //cin >> t;
    while(t--){
        solve();
    }
}

//erase last element multiset -> multiset.erase(--multiset.end());
//max sum of contiguos subarray -> dp
// imos method -> https://imoz.jp/algorithms/imos_method.html
//chicken mcnugget theorem

Compilation message

toy.cpp: In function 'void dfs(long long int, long long int)':
toy.cpp:45:32: error: too many arguments to function 'void dfs(long long int, long long int)'
   45 |         dfs(x/i, sum + i - 1, i);
      |                                ^
toy.cpp:36:6: note: declared here
   36 | void dfs(ll x, ll sum){
      |      ^~~