数位DP的感觉,但是跟模版不是一个套路的,看的题解,代码好理解,但是确实难想。

 #include <cstdio>
#include <cstring>
#include <iostream>
using namespace std;
#define LL long long
LL dp[][][][];
int a[],b[],c[];
void fun(int *p,int x)
{
int i;
for(i = ; i <= ; i ++)
{
if(x&(<<i))
p[i] = ;
else
p[i] = ;
}
}
LL dfs(int pos,int ta,int tb,int tc)
{
if(pos == -)
return ;
LL & res = dp[pos][ta][tb][tc];
int x,y,z;
if(res == -)
{
res = ;
for(x = ; x < ; x ++)
{
for(y = ; y < ; y ++)
{
z = x^y;
if((!ta||(x <= a[pos]))&&(!tb||(y <= b[pos]))&&(!tc||(z <= c[pos])))
{
res += dfs(pos-,ta&&(x == a[pos]),tb&&(y == b[pos]),tc&&(z == c[pos]));
}
}
}
}
return res;
}
class LittleElephantAndXor
{
public :
LL getNumber(int A, int B, int C)
{
memset(dp,-,sizeof(dp));
fun(a,A);
fun(b,B);
fun(c,C);
return dfs(,,,);
}
};

SRM 595 DIV2 1000的更多相关文章

  1. Topcoder Srm 673 Div2 1000 BearPermutations2

    \(>Topcoder \space Srm \space 673 \space Div2 \space 1000 \space BearPermutations2<\) 题目大意 : 对 ...

  2. Topcoder Srm 671 Div2 1000 BearDestroysDiv2

    \(>Topcoder \space Srm \space 671 \space Div2 \space 1000 \space BearDestroysDiv2<\) 题目大意 : 有一 ...

  3. SRM 146 DIV2 1000

    Problem Statement      A well-known riddle goes like this: Four people are crossing an old bridge. T ...

  4. TC SRM 593 DIV2 1000

    很棒的DP,不过没想出,看题解了..思维很重要. #include <iostream> #include <cstdio> #include <cstring> ...

  5. TC SRM 591 DIV2 1000

    很不错的一题,非常巧妙的用DP顺序解决这个问题... 可以发现,只和A里面最小的有关系... #include <cstdio> #include <cstring> #inc ...

  6. TopCoder SRM 660 Div2 Problem 1000 Powerit (积性函数)

    令$f(x) = x^{2^{k}-1}$,我们可以在$O(k)$的时间内求出$f(x)$. 如果对$1$到$n$都跑一遍这个求解过程,时间复杂度$O(kn)$,在规定时间内无法通过. 所以需要优化. ...

  7. TopCoder SRM 301 Div2 Problem 1000 CorrectingParenthesization(区间DP)

    题意  给定一个长度为偶数的字符串.这个字符串由三种括号组成. 现在要把这个字符串修改为一个符合括号完全匹配的字符串,改变一个括号的代价为$1$,求最小总代价. 区间DP.令$dp[i][j]$为把子 ...

  8. SRM 657 DIV2

    -------一直想打SRM,但是感觉Topcoder用起来太麻烦了.题目还是英文,不过没什么事干还是来打一打好了.但是刚注册的号只能打DIV2,反正我这么弱也只适合DIV2了.. T1: 题目大意: ...

  9. SRM 638 Div2

    2333... 因为TC过少的参与者.加上不断fst 我掉了div2该. 幸运的是完成的背div1该.. 250 水的问题 500 水的问题.. 直接bfs扩展即可了 注意判重.  我还用康托展开了真 ...

随机推荐

  1. 重温WCF之WCF传输安全(十三)(4)基于SSL的WCF对客户端采用证书验证(转)

    转载地址:http://www.cnblogs.com/lxblog/archive/2012/09/20/2695397.html 前一篇我们演示了基于SSL的WCF 对客户端进行用户名和密码方式的 ...

  2. MYSQL建表语法(主键,外键,联合主键)

    在看<Learning SQL>第二版, 慢慢打实SQL的基础. 建表一: ), lname ), gender ENUM(), city ), state ), country ), p ...

  3. .Net Ioc Unity

    Unity 的接口IUnityContainer public interface IUnityContainer : IDisposable IUnityContainer RegisterType ...

  4. thinkphp分页样式

    html代码: <div class="pages">{$page}</div> css代码: .pages{ width:100.5%; text-ali ...

  5. php获取当前页面的完整url

    javascript实现: top.location.href 顶级窗口的地址 this.location.href 当前窗口的地址 php实现: //测试网址: http://localhost/b ...

  6. MongoDB3.0新特性

    3月3日,MongoDB3.0终于发布了. 主要特点包括了对之前收购的WiredTiger存储引擎的支持,插件式存储引擎API,SCRAM-SHA-1认证机制,并改进了解释功能.此外,包含了自动化.备 ...

  7. Arduino101学习笔记(九)—— 中断函数

    1.设置中断函数 //***************************************************************************************** ...

  8. 智能车学习(六)——OLED屏幕使用

    一.代码展示 1.头文件: #ifndef OLED_H_ #define OLED_H_ extern unsigned char Draw[]; extern const unsigned cha ...

  9. Linux学习笔记(6)Linux常用命令之帮助命令与用户管理命令

    (1)man man命令用于获得命令或配置文件的帮助信息,英文原意为manual,所在路径为/usr/bin/man,其语法格式为: man [命令或配置文件] 注意:查看配置文件的帮助信息时无需绝对 ...

  10. 一定要学会paxos算法!

    paxos算法 http://blog.csdn.net/dellme99/article/details/14162159