| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
|---|---|---|---|---|---|---|---|
| 538000 | jamielim | Toys (CEOI18_toy) | C++14 | 3 ms | 860 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define mp make_pair
#define pb emplace_back
#define ALL(x) x.begin(),x.end()
#define SZ(x) (int)x.size()
typedef long long ll;
typedef pair<int,int> ii;
typedef pair<ii,ii> i4;
const int MOD=1000000007;
const int INF=1012345678;
const ll LLINF=1012345678012345678LL;
const double PI=3.1415926536;
const double EPS=1e-14;
bool prime[100005];
int n;
int main(){
prime[0]=0;prime[1]=0;
for(int i=2;i<=100005;i++)prime[i]=1;
for(int i=2;i<=100005;i++){
if(prime[i]==0)continue;
for(int j=2*i;j<=100005;j+=i)prime[j]=0;
}
scanf("%d",&n);
vector<int> pfac;
for(int i=2;i<=100005;i++){
if(prime[i]==0)continue;
while(n%i==0){
pfac.pb(i);
n/=i;
}
}
if(pfac.empty())pfac.pb(n);
vector<vector<vector<int> > > v[2];
vector<int> t;
vector<vector<int> > r; r.pb(t);
v[1].pb(r);
for(int i=0;i<SZ(pfac);i++){
v[i&1].clear();
for(int j=0;j<SZ(v[(i&1)^1]);j++){
int m=SZ(v[(i&1)^1][j]);
for(int k=0;k<m;k++){
vector<vector<int> > newv=v[(i&1)^1][j];
if(k==0||SZ(newv[k])+1<=SZ(newv[k-1])){
newv[k].pb(pfac[i]);
v[i&1].pb(newv);
}
}
vector<vector<int> > newv=v[(i&1)^1][j];
t.clear();t.pb(pfac[i]);newv.pb(t);v[i&1].pb(newv);
}
}
set<ll> ans;
int x=(SZ(pfac)&1)^1;
for(int i=0;i<SZ(v[x]);i++){
ll sum=0;
for(int j=0;j<SZ(v[x][i]);j++){
ll prod=1;
for(int k=0;k<SZ(v[x][i][j]);k++){
//printf("%d ",v[x][i][j][k]);
prod*=(ll)v[x][i][j][k];
}
sum+=prod-1;
//printf("\n");
}
ans.insert(sum);
//printf("\n");
}
printf("%d\n",SZ(ans));
for(ll i:ans)printf("%lld ",i);
}
컴파일 시 표준 에러 (stderr) 메시지
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
