状态的枚举还需多多练习啊

#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<cmath>
#include<string>
#include<vector>
#include<stack>
#include<queue>
#include<set>
#include<map>
#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;
}

UESTC - 878的更多相关文章

  1. UESTC - 878 温泉旅店 二维费用背包问题

    http://acm.uestc.edu.cn/#/problem/show/878 设dp[i][j][k]表示在前i个数中,第一个得到的异或值是j,第二个人得到的异或值是k的方案数有多少种. 因为 ...

  2. UESTC 878 温泉旅馆 --性质+枚举

    设FA为A的牌中数字异或和,FB为B的. 则有性质: ans = (所有的(A&B=0)个数 + (FA=FB且A&B=0)的个数)/2.即所有的FA>FB的个数(除2是因为这里 ...

  3. BUPT2017 wintertraining(15) #3 题解

    我觉得好多套路我都不会ヘ(;´Д`ヘ) 题解拖到情人节后一天才完成,还有三场没补完,真想打死自己.( ˙-˙ ) A - 温泉旅店 UESTC - 878  题意 ​ 有n张牌,两人都可以从中拿出任意 ...

  4. ACM:UESTC - 649 括号配对问题 - stack

      UESTC - 649  括号配对问题 Time Limit: 1000MS   Memory Limit: 65535KB   64bit IO Format: %lld & %llu ...

  5. UESTC 1015 Lweb and pepper --前,后缀最值

    题意: n种食物,每种含花椒的概率为Pi,现在已经选择了[L,R]这个区间(下标)的食物,要再选一个,使总的食物只有一种含花椒的概率最大,问选哪个最好,相同的选下标小的. 解法: 就不写解法了.此处有 ...

  6. UESTC 1852 Traveling Cellsperson

    找规律水题... Traveling Cellsperson Time Limit: 1000ms Memory Limit: 65535KB This problem will be judged ...

  7. UESTC 1851 Kings on a Chessboard

    状压DP... Kings on a Chessboard Time Limit: 10000ms Memory Limit: 65535KB This problem will be judged ...

  8. UESTC 30 最短路,floyd,水

    最短路 Time Limit: 3000/1000MS (Java/Others)     Memory Limit: 65535/65535KB (Java/Others) Submit Statu ...

  9. uestc oj 1218 Pick The Sticks (01背包变形)

    题目链接:http://acm.uestc.edu.cn/#/problem/show/1218 给出n根木棒的长度和价值,最多可以装在一个长 l 的容器中,相邻木棒之间不允许重叠,且两边上的木棒,可 ...

随机推荐

  1. IE浏览器和Firefox浏览器兼容性问题及解决办法

    IE浏览器和Firefox浏览器兼容性问题及解决办法 为了方便大家阅读代码,以下以 IE 代替 Internet Explorer,以 MF/FF 代替 Mozzila Firefox : 1.//w ...

  2. MVC5应用程序生命周期lifecycle

  3. Dapper多表查询

    1对1 //文章 public class Post { public int ID { get; set; } public string Title { get; set; } public st ...

  4. java IO Nio 文件拷贝工具类Files

    public static void main(String[] args) throws Exception { Files.copy(Paths.get("file/text.txt&q ...

  5. 编写高质量代码改善C#程序的157个建议——建议56:使用继承ISerializable接口更灵活地控制序列化过程

    建议56:使用继承ISerializable接口更灵活地控制序列化过程 接口ISerializable的意义在于,如果特性Serializable,以及与其像配套的OnDeserializedAttr ...

  6. Max Sum(动态规划)

    原创 http://acm.hdu.edu.cn/showproblem.php?pid=1003 题目要求求出一个序列里面的最大序列和,序列要求是连续的,给出最大序列和,序列首元素下标和尾元素下标, ...

  7. HTML <area> 标签区域map标签

    1.距形:(左上角顶点坐标为(x1,y1),右下角顶点坐标为(x2,y2)) <area shape="rect" coords="x1,y1,x2,y2" ...

  8. SICP练习1.6的解答

    cond和if有着同样的效果,为啥用cond实现的new-if不能用于一些函数? 我自己没想明白,在网上搜集了一下答案,部分解答觉得有道理,整理如下: 解答1: if和cond都是特定的求值顺序, 即 ...

  9. Expression表单式树

    余于项目中逢Expression(表达式树),然今未明其用途也,记之以温. using System; using System.Collections.Generic; using System.L ...

  10. EIP权限工作流平台-升级说明(2018-12-04)

    表单生成器,文本框新增验证(默认验证及正则表达式) 列表查询支持复杂查询,支持文本框,下拉框,时间查询