2011-10-15から1日間の記事一覧

SRM512 Div1 Easy(256), Div2 Medium(512) MysteriousRestaurant

MysteriousRestaurant何日レストランに行くかを決めれば、それぞれの曜日にどの料理を食べるのが最安かが決まる。 #include <string> #include <vector> #include <algorithm> using namespace std; int c2p( char c ) { if ( '0'<=c && c<='9' ) return c-'0'+0; if ( 'A'<=c && c<='Z'</algorithm></vector></string>…

SRM510 Div2 Hard(1000) TheLuckyBasesDivTwo

TheLuckyBasesDivTwoB進数で表したときの桁数ごとに分けて考える。1桁の場合にLuckyとなるのはnが4か7のとき。この場合lucky baseは無数に存在する。2桁の場合は4*B+4=n, 4*B+7=n, 7*B+4=n, 7*B+7=nとなるようなBが存在するかを調べる。3桁以上となる場合、B…

SRM510 Div2 Medium(500) TheLuckyGameDivTwo

TheLuckyGameDivTwoBrusがある区間を選択したときに、Lucky numberの個数がいくつになるかを覚えておけば、TLEにならない。 #include <algorithm> using namespace std; int jLen, bLen; int memo[4748]; bool lucky( int x ) { for ( ; x>0; x/=10 ) if ( x%10!=4 && x</algorithm>…

SRM510 Div2 Easy(250) TheAlmostLuckyNumbersDivTwo

TheAlmostLuckyNumbersDivTwo bool lucky( int x ) { int c = 0; for ( ; x>0; x/=10 ) if ( x%10!=4 && x%10!=7 ) c++; return c<=1; } class TheAlmostLuckyNumbersDivTwo{public: int find( int a, int b ) { int ans = 0; for ( int i=a; i<=b; i++ ) if…