제출 #536815

#제출 시각아이디문제언어결과실행 시간메모리
536815errorgornToys (CEOI18_toy)C++17
0 / 100
1 ms256 KiB
#include <bits/stdc++.h>
using namespace std;

#define int long long
#define ll long long
#define ii pair<ll,ll>
#define fi first
#define se second
#define endl '\n'

#define puf push_front
#define pof pop_front
#define pub push_back
#define pob pop_back
#define lb lower_bound
#define ub upper_bound

#define rep(x,s,e) for (auto x=(s)-((s)>(e));x!=(e)-((s)>(e));(s)<(e)?x++:x--)
#define all(x) (x).begin(),(x).end()
#define sz(x) (int) (x).size()

mt19937 rng(chrono::system_clock::now().time_since_epoch().count());

int n;
vector<int> divi;
vector<int> ans;

void solve(int i,int lim,int cnt,int val){
	if (cnt==1){
		if (i<=lim) ans.pub(val+i);
		return;
	}
	
	for (auto it:divi) if (it<=lim && i%it==0) solve(i/it,it,cnt-1,val+it);
}

signed main(){
	cin.tie(0);
	cout.tie(0);
	cin.sync_with_stdio(false);
	
	cin>>n;
	
	rep(x,1,100000) if (n%x==0){
		if (x*x>n) break;
		
		divi.pub(x);
		if (x*x!=n) divi.pub(n/x);
	}
	
	sort(all(divi));
	
	solve(n,n,4,0);
	
	sort(all(ans));
	ans.erase(unique(all(ans)),ans.end());
	
	cout<<sz(ans)<<endl;
	for (auto it:ans) cout<<it-4<<" "; cout<<endl;
}

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

toy.cpp: In function 'int main()':
toy.cpp:59:2: warning: this 'for' clause does not guard... [-Wmisleading-indentation]
   59 |  for (auto it:ans) cout<<it-4<<" "; cout<<endl;
      |  ^~~
toy.cpp:59:37: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'for'
   59 |  for (auto it:ans) cout<<it-4<<" "; cout<<endl;
      |                                     ^~~~
#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...