本文共 1387 字,大约阅读时间需要 4 分钟。
状态的枚举还需多多练习啊
#include #include #include #include #include #include #include #include #include #include #include #include #define rep(i,j,k) for(register int i=j;i<=k;i++)#define rrep(i,j,k) for(register int i=j;i>=k;i--)#define erep(i,u) for(register int i=head[u];~i;i=nxt[i])#define iin(a) scanf("%d",&a)#define lin(a) scanf("%lld",&a)#define din(a) scanf("%lf",&a)#define s0(a) scanf("%s",a)#define s1(a) scanf("%s",a+1)#define print(a) printf("%lld",(ll)a)#define enter putchar('\n')#define blank putchar(' ')#define println(a) printf("%lld\n",(ll)a)#define IOS ios::sync_with_stdio(0)using namespace std;const int maxn = 5e4+11;const int oo = 0x3f3f3f3f;const double eps = 1e-7;typedef long long ll;ll read(){ ll x=0,f=1;register char ch=getchar(); while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();} while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();} return x*f;}ll dp[18][130][130],a[18],n;int main(){ while(cin>>n){ rep(i,1,n) a[i]=read(); memset(dp,0,sizeof dp); dp[0][0][0]=1; rep(i,1,n){ rep(j,0,128){ rep(k,0,128){ dp[i][j][k]+=dp[i-1][j][k]; dp[i][j^a[i]][k]+=dp[i-1][j][k];//zuo na dp[i][j][k^a[i]]+=dp[i-1][j][k];//you na } } } ll ans=0; rep(i,0,128){ rep(j,i,128){ ans+=dp[n][i][j]; } } println(ans); } return 0;}
转载于:https://www.cnblogs.com/caturra/p/8683889.html