ITSA [C_MM115-中] 奇妙數列

Problem

http://e-tutor.itsa.org.tw/e-Tutor/mod/programming/view.php?id=2969

Thinking

TODO

Solution

#include 
#include 

using namespace std;

int main(){
    int num;
    while(cin >> num){
        set S;
        S.insert(1);
        for(int T = 2 ; S.size() != num ;T++ ){
            set::iterator search = S.find(T);
            if(search == S.end()){
                S.insert(*S.rbegin() + T);
            }
        }
        cout << *S.rbegin() << endl;
    }
}

你可能感兴趣的:(ITSA [C_MM115-中] 奇妙數列)