Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

不好意思,没有考虑xi为0的情况。不好意思。。。

Posted by vanguard001 at 2006-05-01 20:09:15 on Problem 1775
In Reply To:想不明白为什么错了呢,有人帮忙看一下吗?相当直观的想法阿。。 Posted by:vanguard001 at 2006-05-01 15:28:11
> #include <iostream>
> #include <set>
> #include <vector>
> using namespace std;
> 
> int factorials[10];
> set<int> s;
> vector<int> v;
> 
> int main(){
> 	int i=0;
>     factorials[0]=1;
> 	for(i=1; i<=9; i++){
>        factorials[i] = factorials[i-1]*i;
> 	}
> 
> 
> 	s.insert(factorials[1]);
> 	set<int>::iterator it;
>     for(i=2; i<=9; i++){
> 		v.clear();
> 		for(it=s.begin(); it!=s.end(); it++){
>             v.push_back(*it+factorials[i]);
> 		}
> 		s.insert(v.begin(),v.end());
> 		s.insert(factorials[i]);
> 	}
> 
> 	int n=0;
>     while(true){
>         cin >> n;
> 		if(n<0) break;
> 		if(n>409113){    //这个是最大的。。9!+。。。+1!
> 			cout << "NO" << endl;
> 			continue;
> 		}
> 		if(s.find(n)!=s.end())
> 			cout << "YES" << endl;
> 		else
> 			cout << "NO" << endl;
> 	}
> 	return 0;
> }

Followed by:

Post your reply here:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator