| ||||||||||
| Online Judge | Problem Set | Authors | Online Contests | User | ||||||
|---|---|---|---|---|---|---|---|---|---|---|
| Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest | |||||||||
Re:0ms STL 一次AC 爽!In Reply To:0ms STL 一次AC 爽! Posted by:zhu_yifan at 2010-06-06 01:20:55 > #include<list>
> #include<iostream>
> using namespace std;
>
> int count = 0;
> list<long long> queue;
> long long table[1500];
>
> void pushback(long long val)
> {
> for(list<long long>::iterator it = queue.begin(); it != queue.end(); ++it)
> if((*it) == val) return;
> queue.push_back(val);
> }
>
> int main()
> {
> long long min;
> list<long long>::iterator index;
> queue.push_back(1);
> while(count != 1500)
> {
> min = (*queue.begin());
> index = queue.begin();
> for(list<long long>::iterator it = queue.begin(); it != queue.end(); ++it)
> {
> if((*it) < min)
> {
> min = (*it);
> index = it;
> }
> }
> queue.erase(index);
> table[count] = min;
> ++count;
> pushback(min * 2);
> pushback(min * 3);
> pushback(min * 5);
> }
> int num;
> while(cin>>num && num != 0)
> cout<<table[num - 1]<<endl;
> return 0;
> }
Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator