제출 #1070999

#제출 시각아이디문제언어결과실행 시간메모리
1070999YassirSalamaToys (CEOI18_toy)C++17
100 / 100
1932 ms87124 KiB
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
template<typename T> 
ostream& operator << (ostream& out,vector<T> v){
    int i=0;
    for(auto x:v){
        out << x;
        i++;
        if(i==v.size()) break;
        out << " , ";
    }
    out << endl;
    return out;
}
template<typename T> 
void dbg(const T& t){
    cout<<t<<"\n";
}
template<typename T,typename... Args>
void dbg(const T& t,const Args&... args){
    cout<<t<<" , ";
    dbg(args...);
}
#define dbg(...) cout<<"("<<#__VA_ARGS__<<") : ";dbg(__VA_ARGS__);
#define all(v) v.begin(),v.end()
set<vector<int>> decomp;
set<vector<int>> c;
signed main(){
    int n;
    cin>>n;
    int x=n;
    vector<int> d;
    for(int i=1;i*i<=n;i++){
        if(n%i==0){
            d.pb(i);
            if(i*i==n) continue;
            d.pb(n/i);
        }
    }
    sort(all(d));
    // dbg(d)
    vector<set<int>> dp(d.size());
    dp[0] = {0};//for 1 ans is 0;
    for(int i=1;i<d.size();i++){
        for(int j=0;j<i;j++){
            int a=d[i];
            int b=d[j];
            if(a%b==0){
                for(auto x:dp[j]){
                    dp[i].insert(x+a/b-1);
                }
            }
        }
    }
    vector<int> ans(all(dp.back()));
    cout<<ans.size()<<"\n";
    for(auto x:ans){
        cout<<x<<" ";
    }
    cout<<"\n";
}
/*
so hna khass nakhdu ans mn haduk li 9bel
sooo if we have like ans for n = 5 and we have chi prime divisor b7al db 2
then we get the ans for n=10 ig
yep yep true
enft we can even nduzu wakha machi prime number
like la kan 3ndna 4 rah it's possible to pass to 20
mais khass labuda ykun divisor 
so ig formula atkun like this
dp[n]=dp[j]+n/j-1
euuuh ig hiya hadik
*/

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

toy.cpp: In function 'int main()':
toy.cpp:45:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   45 |     for(int i=1;i<d.size();i++){
      |                 ~^~~~~~~~~
toy.cpp:32:9: warning: unused variable 'x' [-Wunused-variable]
   32 |     int x=n;
      |         ^
#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...