SRM 595 DIV2 1000
数位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的更多相关文章
- Topcoder Srm 673 Div2 1000 BearPermutations2
\(>Topcoder \space Srm \space 673 \space Div2 \space 1000 \space BearPermutations2<\) 题目大意 : 对 ...
- Topcoder Srm 671 Div2 1000 BearDestroysDiv2
\(>Topcoder \space Srm \space 671 \space Div2 \space 1000 \space BearDestroysDiv2<\) 题目大意 : 有一 ...
- SRM 146 DIV2 1000
Problem Statement A well-known riddle goes like this: Four people are crossing an old bridge. T ...
- TC SRM 593 DIV2 1000
很棒的DP,不过没想出,看题解了..思维很重要. #include <iostream> #include <cstdio> #include <cstring> ...
- TC SRM 591 DIV2 1000
很不错的一题,非常巧妙的用DP顺序解决这个问题... 可以发现,只和A里面最小的有关系... #include <cstdio> #include <cstring> #inc ...
- TopCoder SRM 660 Div2 Problem 1000 Powerit (积性函数)
令$f(x) = x^{2^{k}-1}$,我们可以在$O(k)$的时间内求出$f(x)$. 如果对$1$到$n$都跑一遍这个求解过程,时间复杂度$O(kn)$,在规定时间内无法通过. 所以需要优化. ...
- TopCoder SRM 301 Div2 Problem 1000 CorrectingParenthesization(区间DP)
题意 给定一个长度为偶数的字符串.这个字符串由三种括号组成. 现在要把这个字符串修改为一个符合括号完全匹配的字符串,改变一个括号的代价为$1$,求最小总代价. 区间DP.令$dp[i][j]$为把子 ...
- SRM 657 DIV2
-------一直想打SRM,但是感觉Topcoder用起来太麻烦了.题目还是英文,不过没什么事干还是来打一打好了.但是刚注册的号只能打DIV2,反正我这么弱也只适合DIV2了.. T1: 题目大意: ...
- SRM 638 Div2
2333... 因为TC过少的参与者.加上不断fst 我掉了div2该. 幸运的是完成的背div1该.. 250 水的问题 500 水的问题.. 直接bfs扩展即可了 注意判重. 我还用康托展开了真 ...
随机推荐
- 【mysql创建用户|删除用户|修改用户权限|常用命令】
原文链接:http://blog.csdn.net/leili0806/article/details/8573636 1. CREATE USER 语法: CREATE USER 'us ...
- 【openGL】画五角星
#include "stdafx.h" #include <GL/glut.h> #include <stdlib.h> #include <math ...
- Create a Qt Widget Based Application—Windows
This turtorial describes how to use Qt Creator to create a small Qt application, Text Finder. It is ...
- How to use the Visual Studio
推荐一个提供VS配色方案的一个网站:StudioStyles,域名和网站同名:http://studiostyl.es/ 2. 整行剪切:Ctrl + X.光标不要选中任何文字,然后按这个快捷键就可以 ...
- 学习iOS的网站
ios开发者 http://www.codeios.com/ cocoachina http://www.cocoachina.com code4app http://code4app.com ...
- HDU 5213 Lucky 莫队+容斥
Lucky Problem Description WLD is always very lucky.His secret is a lucky number K.k is a fixed odd n ...
- Codeforces Round#250 D. The Child and Zoo(并差集)
题目链接:http://codeforces.com/problemset/problem/437/D 思路:并差集应用,先对所有的边从大到小排序,然后枚举边的时候,如果某条边的两个顶点不在同一个集合 ...
- 汇编学习(四)——算术运算程序
(一)跳转指令 一.无条件跳转指令(不管标志寄存器,执行到这句直接跳转) 1.段内直接跳转指令 (1)指令格式: JMP SHORT short_label; IP<--IP+DB,即代码直接跳 ...
- 非旋转Treap及可持久化[Merge,Split]
http://memphis.is-programmer.com/posts/46317.html http://fanhq666.blog.163.com/blog/static/819434262 ...
- Hibernate的持久化类状态
Hibernate的持久化类状态 持久化类:就是一个实体类 与 数据库表建立了映射. Hibernate为了方便管理持久化类,将持久化类分成了三种状态. 瞬时态 transient (临时态):持久化 ...