답안 #925314

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
925314 2024-02-11T11:45:46 Z 8pete8 Toys (CEOI18_toy) C++17
0 / 100
2 ms 9820 KB
#include<iostream>
#include<stack>
#include<map>
#include<vector>
#include<string>
#include<unordered_map>
#include <queue>
#include<cstring>
#include<cassert>
#include<limits.h>
#include<cmath>
#include<set>
#include<numeric> //gcd(a,b)
#include<algorithm>
#include<bitset> 
#include<stack>
using namespace std;
#define ll long long
#define f first
#define endl "\n"
#define s second
#define pii pair<int,int>
#define pppiiii pair<pii,pii>
#define ppii pair<int,pii>
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define pb push_back
#define mp make_pair
#define lb lower_bound
#define ub upper_bound
#define fastio ios::sync_with_stdio(false);cin.tie(NULL);
#pragma GCC optimize ("03,unroll-loops")
#define int long long
const int mod=1e9+7,mxn=2e5+5,lg=30,inf=1e18,minf=-1e18,Mxn=100000,root=700;
void setIO(string name){		
	ios_base::sync_with_stdio(0); cin.tie(0);		
	freopen((name+".in").c_str(),"r",stdin);		
	freopen((name+".out").c_str(),"w",stdout);	
}	
int n;
vector<int>getdiv(int a){
	vector<int>ans;
	for(int i=1;i*i<=a;i++)if(a%i==0)ans.pb(i),ans.pb(a/i);
	return ans;
}
unordered_map<int,int>pos;
set<int>ans[mxn+10];
int32_t main(){
	//setIO("redistricting");
	fastio
	int n;cin>>n;
	vector<int>div=getdiv(n);
	sort(all(div));
	for(int i=0;i<div.size();i++)pos[div[i]]=i;
	ans[0].insert(0);
	for(int i=0;i<div.size();i++){
		vector<int>v=getdiv(div[i]);
		for(auto k:v)for(auto j:ans[pos[div[i]/k]])ans[i].insert(j+k-1);
	}
	int k=div.size()-1;
	cout<<ans[k].size()<<'\n';
	for(auto i:ans[k])cout<<i<<" ";
}

Compilation message

toy.cpp: In function 'int32_t main()':
toy.cpp:54:15: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   54 |  for(int i=0;i<div.size();i++)pos[div[i]]=i;
      |              ~^~~~~~~~~~~
toy.cpp:56:15: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   56 |  for(int i=0;i<div.size();i++){
      |              ~^~~~~~~~~~~
toy.cpp: In function 'void setIO(std::string)':
toy.cpp:37:9: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   37 |  freopen((name+".in").c_str(),"r",stdin);
      |  ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
toy.cpp:38:9: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   38 |  freopen((name+".out").c_str(),"w",stdout);
      |  ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 9820 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 9820 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 9820 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 9820 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 9820 KB Output isn't correct
2 Halted 0 ms 0 KB -