답안 #934313

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
934313 2024-02-27T07:03:36 Z tamir1 Toys (CEOI18_toy) C++14
0 / 100
1 ms 600 KB
#include<bits/stdc++.h>
#define ll int
using namespace std;
ll n,i,j,m,x,y;
vector<ll> a,b;
unordered_map<ll,ll> mp;
set<ll> s[1100];
int main(){
	/*ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);*/
	//cin >> n;
	scanf("%d",&n);
	for(i=1;i*i<=n;i++){
		if(n%i!=0) continue;
		if(i*i==n){
			a.push_back(i);
			continue;
		}
		a.push_back(i);
		b.push_back(n/i);
	}
	m=b.size();
	for(i=m-1;i>=0;i--) a.push_back(b[i]);
	m=a.size();
	for(i=0;i<m;i++){
		mp[a[i]]=i;
		x=a[i];
		s[i].insert(x-1);
		for(j=1;a[j]*a[j]<=x;j++){
			y=a[j];
			if(x%y!=0) continue;
			for(ll l:s[mp[y]]){
				for(ll r:s[mp[x/y]]){
					s[i].insert(l+r);
				}
			}
		}
	}
	//cout << s[m-1].size() << "\n";
	printf("%d\n",s[m-1].size());
	for(ll i:s[m-1]) printf("%d ",i);
	//cout << i << " ";
}

Compilation message

toy.cpp: In function 'int main()':
toy.cpp:41:11: warning: format '%d' expects argument of type 'int', but argument 2 has type 'std::set<int>::size_type' {aka 'long unsigned int'} [-Wformat=]
   41 |  printf("%d\n",s[m-1].size());
      |          ~^    ~~~~~~~~~~~~~
      |           |               |
      |           int             std::set<int>::size_type {aka long unsigned int}
      |          %ld
toy.cpp:13:7: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   13 |  scanf("%d",&n);
      |  ~~~~~^~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Runtime error 1 ms 600 KB Execution killed with signal 8
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 1 ms 600 KB Execution killed with signal 8
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 1 ms 600 KB Execution killed with signal 8
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 1 ms 600 KB Execution killed with signal 8
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 1 ms 600 KB Execution killed with signal 8
2 Halted 0 ms 0 KB -