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:啊我用了个递推,也很容易。但没想到推公式,太高估这题了,呵呵In Reply To:啊我用了个递推,也很容易。但没想到推公式,太高估这题了,呵呵 Posted by:zhangjb at 2005-03-21 12:10:44 > #include <iostream> > #include <vector> > #include <algorithm> > using namespace std; > > struct Times > { > long rTime; > long lTime; > Times() { rTime = lTime =0; } > }; > > void main() > { > int n; cin >> n; > vector<int> input(n); > for (int i=0; i<input.size(); i++) > cin >> input[i]; > int persons = *(max_element(input.begin(), input.end())); > > vector<Times> times(persons+1); > times[2].lTime = 1; > for (n=3; n<times.size(); n++) > { > int a = n/2, b = n-a; > times[n].rTime = times[a].lTime+times[b].lTime; > times[n].lTime = a*b+times[n].rTime; > } > for (i=0; i<input.size(); i++) > cout << times[input[i]].rTime << endl; > } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator