답안 #917913

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
917913 2024-01-29T05:11:43 Z PM1 Toys (CEOI18_toy) C++17
0 / 100
1 ms 348 KB
#include <bits/stdc++.h>
using namespace std;
#define ll long long
int n;
ll sum=1,res=0;
vector<int>v,ans;
void solve(int p=0){
	if(sum==n){
		ans.push_back(res);
		return ;
	}
	for(;p<v.size();p++){
		if(sum*v[p]>n)return;
		sum*=v[p];
		res+=v[p]-1;
		solve(p);
		sum/=v[p];
		res-=v[p]-1;
	}
}
int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	cin>>n;
	int num=n;
	for(int i=2;i*i<=n;i++){
		if(num%i)continue;
		v.push_back(i);
		if(i*i<n)
			v.push_back(n/i);
	}
	v.push_back(n);
	sort(v.begin(),v.end());
	solve();
	sort(ans.begin(),ans.end());
	ans.resize(unique(v.begin(),v.end())-v.begin());
	cout<<ans.size()<<'\n';
	for(auto i:ans)
		cout<<i<<" ";
	return 0;
}

Compilation message

toy.cpp: In function 'void solve(int)':
toy.cpp:12:8: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   12 |  for(;p<v.size();p++){
      |       ~^~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Incorrect 0 ms 348 KB Output isn't correct
7 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Incorrect 0 ms 348 KB Output isn't correct
7 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Incorrect 0 ms 348 KB Output isn't correct
7 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Incorrect 0 ms 348 KB Output isn't correct
7 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Incorrect 0 ms 348 KB Output isn't correct
7 Halted 0 ms 0 KB -