提高水平

https://nanti.jisuanke.com/t/31436

状压dp。

#include
#include
#include
inline int getint() {
    register char ch;
    while(!isdigit(ch=getchar()));
    register int x=ch^'0';
    while(isdigit(ch=getchar())) x=(((x<<2)+x)<<1)+(ch^'0');
    return x;
}
const int N=20;
int a[N][N],f[1<>23&255)-127;
}
int main() {
    freopen("proficiency.in","r",stdin);
    freopen("proficiency.out","w",stdout);
    const int n=getint(),all=(1<>j)&1) {
                f[i]=std::max(f[i],f[i^(1<

写法二:

#include
#include
#include
#include
#define f(i,l,r) for(i=(l);i<=(r);i++)
using namespace std;
inline int getint() {
    register char ch;
    while(!isdigit(ch=getchar()));
    register int x=ch^'0';
    while(isdigit(ch=getchar())) x=(((x<<2)+x)<<1)+(ch^'0');
    return x;
}
const int N=20;
int a[N][N],f[1<>23&255)-127;
}
int main() {
    freopen("proficiency.in","r",stdin);
    freopen("proficiency.out","w",stdout);
    const int n=getint(),all=(1<>i)&1)==0) continue;
        	if(lg2(lowbit(j))!=i){
               w[i][j]=w[i][j^lowbit(j)]+a[lg2(lowbit(j))][i];
           }
            else if((j^(1<>j)&1) {
                f[i]=std::max(f[i],f[i^(1<

 

你可能感兴趣的:(动态规划)