ural 1217. Unlucky Tickets
1217. Unlucky Tickets
Memory limit: 64 MB
Input
Output
Sample
input | output |
---|---|
4 |
100 |
Problem Source: The Seventh Ural State University collegiate programming contest
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <deque>
#include <vector>
#include <queue>
#include <iostream>
#include <algorithm>
#include <map>
#include <set>
#include <ctime>
using namespace std;
typedef long long LL;
typedef double DB;
#define For(i, s, t) for(int i = (s); i <= (t); i++)
#define Ford(i, s, t) for(int i = (s); i >= (t); i--)
#define Rep(i, t) for(int i = (0); i < (t); i++)
#define Repn(i, t) for(int i = ((t)-1); i >= (0); i--)
#define rep(i, x, t) for(int i = (x); i < (t); i++)
#define MIT (2147483647)
#define INF (1000000001)
#define MLL (1000000000000000001LL)
#define sz(x) ((int) (x).size())
#define clr(x, y) memset(x, y, sizeof(x))
#define puf push_front
#define pub push_back
#define pof pop_front
#define pob pop_back
#define ft first
#define sd second
#define mk make_pair
inline void SetIO(string Name) {
string Input = Name+".in",
Output = Name+".out";
freopen(Input.c_str(), "r", stdin),
freopen(Output.c_str(), "w", stdout);
} inline int Getint() {
int Ret = ;
char Ch = ' ';
while(!(Ch >= '' && Ch <= '')) Ch = getchar();
while(Ch >= '' && Ch <= '') {
Ret = Ret*+Ch-'';
Ch = getchar();
}
return Ret;
} const int N = , M = ;
int n;
LL Dp[N][M][M*]; inline void Input() {
scanf("%d", &n);
} inline void Solve() {
int m = n*+, Left, Right;
Left = n/+, Right = n/;
Dp[][][m] = ;
Rep(i, n+)
Rep(j, m)
Rep(k, m*)
if(Dp[i][j][k]) {
int x = k-m, _j, y;
Rep(l, ) {
if(i+ >= Left && l > j) break;
if(i+ <= Right) _j = j+l;
else if(i+ >= Left) _j = j-l;
if((i+)&) y = x+l;
else y = x-l;
//printf("%d %d %d %d %d %d\n", i, j, k-m,i+1, _j, y);
Dp[i+][_j][y+m] += Dp[i][j][k];
}
//printf("%d %d %d %d\n", i, j, k-m, Dp[i][j][k]);
} cout<<Dp[n][][m]<<endl;
} int main() {
#ifndef ONLINE_JUDGE
SetIO("B");
#endif
Input();
Solve();
return ;
}
ural 1217. Unlucky Tickets的更多相关文章
- 递推DP URAL 1031 Railway Tickets
题目传送门 /* 简单递推DP:读题烦!在区间内的都更新一遍,dp[]初始化INF 注意:s1与s2大小不一定,坑! 详细解释:http://blog.csdn.net/kk303/article/d ...
- DP+高精度 URAL 1036 Lucky Tickets
题目传送门 /* 题意:转换就是求n位数字,总和为s/2的方案数 DP+高精度:状态转移方程:dp[cur^1][k+j] = dp[cur^1][k+j] + dp[cur][k]; 高精度直接拿J ...
- Ural 1036 Lucky Tickets
Lucky Tickets Time Limit: 2000ms Memory Limit: 16384KB This problem will be judged on Ural. Original ...
- URAL 1031. Railway Tickets(spfa)
题目链接 不知为何会在dp里呢...INF取小了,2Y. #include <cstring> #include <cstdio> #include <string> ...
- URAL DP第一发
列表: URAL 1225 Flags URAL 1009 K-based Numbers URAL 1119 Metro URAL 1146 Maximum Sum URAL 1203 Scient ...
- ural 1070. Local Time
1070. Local Time Time limit: 1.0 secondMemory limit: 64 MB Soon the USU team will go to Vancouver to ...
- URAL(DP集)
这几天扫了一下URAL上面简单的DP 第一题 简单递推 1225. Flags #include <iostream> #include<cstdio> #include< ...
- URAL 1796. Amusement Park (math)
1796. Amusement Park Time limit: 1.0 second Memory limit: 64 MB On a sunny Sunday, a group of childr ...
- URAL 1036(dp+高精度)
Time Limit:2000MS Memory Limit:65536KB 64bit IO Format:%I64d & %I64u Submit Status Pract ...
随机推荐
- php面试题之二——Javascript(基础部分)
二.JavaScript部分 1. JS 表单弹出对话框函数是?获得输入焦点函数是? 弹出对话框函数:alert(), prompt(), confirm() 获得输入焦点函数:focus() 2. ...
- Unity3D研究院之Jenkins的使用(七十八)
长夜漫漫无心睡眠,来一篇嘿嘿.我相信如果已经用Shell脚本完成IOS和Android打包的朋友一定需要Jenkins 怎么才能让策划打包ipa和apk?怎么才能彻底省去程序的时间,只要在同一局域网内 ...
- WinAPI: ExtCreateRegion - 区域变换
转载:http://www.cnblogs.com/del/archive/2008/06/03/1212534.html 相似函数: SetWorldTransform 本例效果图: 代码文件: u ...
- 九度 OJ1008 hdu 3790
#include<stdio.h> #include<string.h> struct node { int d; int p; }g[][]; #define inf 0x3 ...
- Tornaod框架
Tornado 是 FriendFeed 使用的可扩展的非阻塞式 web 服务器及其相关工具的开源版本.这个 Web 框架看起来有些像web.py 或者 Google 的 webapp,不过为了能有效 ...
- [颓废] 改某人的WebGL light mapping demo并9xSSAA
渲染图(4k) 链接: http://pan.baidu.com/s/1bnB4Wqz 密码: 8839 2px高斯模糊+立方缩小AA: 链接: http://pan.baidu.com/s/1mg ...
- 54. 八皇后问题[eight queens puzzle]
[本文链接] http://www.cnblogs.com/hellogiser/p/eight-queens-puzzle.html [题目] 在8×8的国际象棋上摆放八个皇后,使其不能相互攻击,即 ...
- C++基础知识面试精选100题系列(1-10题)[C++ basics]
[原文链接] http://www.cnblogs.com/hellogiser/p/100-interview-questions-of-cplusplus-basics-1-10.html [题目 ...
- 27.二元树的深度[BinaryTreeDepth]
[题目] 输入一棵二元树的根结点,求该树的深度.从根结点到叶结点依次经过的结点(含根.叶结点)形成树的一条路径,最长路径的长度为树的深度. 例如 10 ...
- cocos2dx阴影层的实现
效果图 //ShadowLayer.h class ShadowLayer : public CCLayer { protected: ShadowLayer() :m_pRender(NULL) , ...