Maison > Article > interface Web > TopCoder SAM 631 DIV2_html/css_WEB-ITnose
200: 水题
class TaroGrid {public: int getNumber(vector <string>);};int TaroGrid::getNumber(vector <string> grid){ int ans=0; int black=0,white=0; int N=grid.size(); for(int i=0;i<n black="0;white=0;" if else white for j="1;j<N;j++)" ans="max(ans,black);" return> <br> <br> <p></p> <p><br> </p> <p>500:尽量往左边靠,判断每一团猫能不能平铺</p> <p><br> </p> <p></p> <pre name="code" class="sycode">class CatsOnTheLineDiv2 {public: string getAnswer(vector <int>, vector <int>, int);};struct CAT{ int p,c;}cat[55];bool cmp(CAT x,CAT y){ if(x.p!=y.p) return x.p<y.p else return x.c catsonthelinediv2::getanswer> pos, vector <int> count, int time){ int n=pos.size(); for(int i=0;i<n cat sort bool flag="true;" int left="-(1<<30),right=-(1<<30);" for i="0;i<n;i++)" right="left+cat[i].c-1;" if>time) flag=false; } if(flag) return "Possible"; else return "Impossible";}</n></int></y.p></int></int>
950:记忆化搜索
map<ll> ret;class TaroCoins {public: LL dfs(LL n) { if(ret.count(n)) return ret[n]; LL ans=0; if(n%2LL) ans=dfs(n/2LL); else ans=dfs(n/2LL)+dfs(n/2LL-1LL); ret[n]=ans; return ans; } long long getNumber(long long N) { ret[0]=1; return dfs(N); }};</ll>