2010-09-15から1日間の記事一覧

SRM482 Div2 Medium(500) LockersDivTwo

LockersDivTwoDiv1より問題サイズが小さくなっている。 class LockersDivTwo{public: int lastOpened( int N ) { int ans = 1; for ( int n=0; ; n++ ) { int x=1; for ( int t=n; t>=1; t-- ) x = (x+t-1)/t*t; if ( x > N ) break; ans = x; } return ans;…

SRM482 Div2 Easy(275) AverageAverage

AverageAverage #include <vector> #include <numeric> using namespace std; class AverageAverage{public: double average( vector <int> numList ) { return (double)accumulate(numList.begin(),numList.end(),0) / numList.size(); }};</int></numeric></vector>

SRM482 Div1 Medium(500) HanoiGoodAndBad

HanoiGoodAndBad問題文中のアルゴリズムを実装し、1手動かすごとに各円盤がどの棒にあるかを出力するようにして、法則を探した。 #include <vector> using namespace std; class HanoiGoodAndBad{public: int moves( int N, int Dave ) { vector<int> disk( N ); int d[2]</int></vector>…

SRM482 Div1 Easy(250) LockersDivOne

偶数のみ追加の高速化が無くてもギリギリ通った。LockersDivOne #include <list> using namespace std; class LockersDivOne{public: int lastOpened( int N ) { if ( N == 1 ) return 1; list<int> locker; for ( int i=2; i<=N; i+=2 ) locker.push_back( i ); for ( </int></list>…

SRM482

Easy (250) 107.46 今度は難しく考えすぎた普通に実装すれば間に合うのか。 Medium (500) 0 Hard (1000) 0 Challenge -25, -25, +50 TLEを狙うも失敗。実行時間の見積もりが難しい。 結果 1640 → 1619