제출 #650130

#제출 시각아이디문제언어결과실행 시간메모리
650130idasToys (CEOI18_toy)C++11
79 / 100
5063 ms185100 KiB
#include <bits/stdc++.h>
#define f first
#define s second
#define pb push_back
#define sz(x) ((int)((x).size()))
#define le(vec) vec[vec.size()-1]
#define all(x) (x).begin(), (x).end()
#define TSTS int ttt; cin >> ttt; while(ttt--) solve()
#define FAST_IO ios_base::sync_with_stdio(0); cin.tie(nullptr)
#define FOR(i, begin, end) for(int i = (begin); i < (end); i++)

using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef map<int, int> mii;
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;
typedef pair<long double, long double> pdd;

const int INF=1e9, MOD=1e9+7, mod=998244353;
const ll LINF=1e18;

void setIO()
{
    FAST_IO;
}

void setIO(string s)
{
    FAST_IO;
    freopen((s+".txt").c_str(), "r", stdin);
    freopen((s+".out").c_str(), "w", stdout);
}

set<pair<int,pii>> vis;
set<int> ans;
void rec(int n, int x, int l)
{
    if(vis.count({n,{x,l}})) return;
    vis.insert({n,{x,l}});
    if(n==1){
        ans.insert(x);
//        return;
    }
    for(int i=1; i*i<=n; i++){
        if(n%i==0){
            if(i>=l) rec(n/i, x+i-1, i);
            if(n/i>=l) rec(i, x+n/i-1, n/i);
        }
    }
}

int main()
{
    setIO();
    int n;
    cin >> n;
    rec(n, 0, 2);
    cout << sz(ans) << '\n';
    for(auto x : ans) cout << x << " ";
}

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

toy.cpp: In function 'void setIO(std::string)':
toy.cpp:32:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   32 |     freopen((s+".txt").c_str(), "r", stdin);
      |     ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
toy.cpp:33:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   33 |     freopen((s+".out").c_str(), "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...