热搜:NVER node 开发 php

TopCoder SAM 631 DIV2_html/css_WEB-ITnose

2024-11-22 23:05:01
TopCoder SAM 631 DIV2_html/css_WEB-ITnose


200: 水题


class TaroGrid {public:	int getNumber(vector );};int TaroGrid::getNumber(vector  grid){    int ans=0;    int black=0,white=0;    int N=grid.size();    for(int i=0;i


500:尽量往左边靠,判断每一团猫能不能平铺


class CatsOnTheLineDiv2 {public:	string getAnswer(vector , vector , int);};struct CAT{    int p,c;}cat[55];bool cmp(CAT x,CAT y){    if(x.p!=y.p)        return x.p pos, vector  count, int time){    int n=pos.size();    for(int i=0;itime)            flag=false;    }    if(flag) return "Possible";    else return "Impossible";}


950:记忆化搜索


map 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);	}};