Your ways (动态规划)ACM-ICPC Asia Phuket Regional Programing Contest 2009
来源:互联网 发布:华西村黑暗真相知乎 编辑:程序博客网 时间:2024/06/05 15:40
F. Your Ways
You live in a small well-planned rectangular town in Phuket. The size of the central area of the town is H kilometers x W kilometers. The central area is divided into HW unit blocks, each of size 1 x 1 km2. There are H + 1 streets going in the West to East direction, and there are W + 1 avenue going in the North-South direction. The central area can be seen as a rectangle on the plane, as shown below.
Input
The first line contains an integer T, the number of test cases (1 <= T <= 5). Each test case is in the following format.
Output
For each test case, for each day, your program must output the number of ways to go to the universitymodulo 2552 on a separate line. i.e., the output for each test case must contains K lines.
Sample Input
22 2 31 0 0 0 12 1 0 2 0 0 2 1 21 1 1 2 1100 150 21 99 150 100 1502 99 150 100 150 100 149 100 150
Sample Output
34415620
Hint
The amount of I/O for this task is quite large. Therefore, when reading input, you should avoid using java.io.Scanner which is much slower than using java.io.BufferedReader.
题意: 给你一个 w*h 的矩阵 k天 每天有q条路不通 问你从左下角走到右上角有多少方案
Orz。。。比赛被这题坑到了
直接暴力找超时
最后想出来 思路是用 cnt = 最大方案数 - 不通路的方案数
比赛时间结束!55...
#include<bits/stdc++.h>using namespace std;int Map[1003][1003];int main(){ int T; scanf("%d",&T); for(int xi=0; xi<=1001; xi++) Map[xi][0]=Map[0][xi]=1; for(int xi=1; xi<=1001; xi++) for(int yi=xi; yi<=1001; yi++) { Map[xi][yi]+=Map[xi-1][yi]; Map[xi][yi]+=Map[xi][yi-1]; Map[yi][xi]=Map[xi][yi]%=2552; }// for(int i=0;i<10;i++,puts(""))// for(int j=0;j<10;j++)// printf("%d ",Map[i][j]); while(T--) { int x,y,t,sum; scanf("%d%d%d",&x,&y,&t); for(int i=0; i<t; i++) { sum=Map[x][y]; int tt; scanf("%d",&tt); for(int j=0; j<tt; j++) { int x1,x2,y1,y2; scanf("%d%d%d%d",&x1,&y1,&x2,&y2); sum-=Map[x-x2][y-y2]*Map[x1][y1];// printf("%d %d %d %d\n",x-x2,y-y2,Map[x-x2][y-y2],Map[x1][y1]); sum+=2552*100000; sum%=2552; } printf("%d\n",sum); } }}
- Your ways (动态规划)ACM-ICPC Asia Phuket Regional Programing Contest 2009
- ACM-ICPC Asia Phuket Regional Programing Contest 2009----F: Your Ways
- ACM-ICPC Asia Phuket Regional Programing Contest 2009---C:In-circles Again
- ACM-ICPC Asia Phuket Regional Programing Contest 2009----J: Nowhere Money
- ACM-ICPC 2011 Asia Phuket Regional [J] Consecutive Sums
- The 2016 ACM-ICPC Asia Dalian Regional Contest(汇总)
- 2014 ACM/ICPC Asia Regional Contest - B
- Asia Regional Contest 第35届ACM/ICPC亚洲赛区
- The 2010 ACM-ICPC Asia Chengdu Regional Contest
- The 2012 ACM-ICPC Asia Changchun Regional Contest(problem E)
- The 2012 ACM-ICPC Asia Changchun Regional Contest(problem B)
- The 2013 ACM-ICPC Asia Changsha Regional Contest KPocket Cube
- The 2013 ACM-ICPC Asia Changsha Regional Contest - A
- The 2013 ACM-ICPC Asia Changsha Regional Contest
- The 2013 ACM/ICPC Asia Changchun Regional Contest题解
- The 2014 ACM-ICPC Asia Mudanjiang Regional Contest 【部分题解】
- The 2014 ACM-ICPC Asia Mudanjiang Regional Contest - A
- The 2014 ACM-ICPC Asia Mudanjiang Regional Contest - I
- C++ 继承
- Preliminary understanding of bagging and boosting
- 电力系统软件应用
- Web 开发中很实用的10个效果【附源码下载】
- 特殊sql语句
- Your ways (动态规划)ACM-ICPC Asia Phuket Regional Programing Contest 2009
- Leetcode: Permutations II
- 几种优秀的大数库总结
- [台剧]《倚天屠龙记》永远的经典——孙兴版杨逍
- 统计1的个数
- Android开发之ProgressDialog的使用
- JSTSC2015第二轮省队选拔赛 后记
- 第一篇博客
- liunx下可以嵌套创建多少文件夹