Your Ways
来源:互联网 发布:linux 查看组信息 编辑:程序博客网 时间:2024/05/16 09:10
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.
The blocking is done in such a way that it is not possible to reach parts of the streets or avenues which is blocked from some other part which is blocked as well through any paths containingonly West-to-East and South-to-North walks.
这句话的意思是每条不能走的道路不会相互影响!所以可以用总数 - 两个端点所能到达的情况数!
<span style="font-size:14px;color:#ff0000;">#include<iostream>#include<stack>#include<algorithm>#include<string.h>#include<math.h>#include<stdio.h>using namespace std;struct node{ int x1,y1,x2,y2;}N[305];int dp[1005][1005];int main(){ int t; cin>>t; while(t--) { int m,n,k; cin>>m>>n>>k; for(int i=0;i<=(m>n?m:n);i++) dp[i][0] = dp[0][i] = 1; for(int i=1;i<=n;i++) for(int j=1;j<=m;j++) { dp[i][j] = (dp[i-1][j] + dp[i][j-1])%2552; } while(k--) { int ans = dp[n][m]; int a; cin>>a; for(int i=0;i<a;i++) { cin>>N[i].x1>>N[i].y1>>N[i].x2>>N[i].y2; ans -= dp[N[i].y1][N[i].x1] * dp[n-N[i].y2][m-N[i].x2]; ans = (ans+2552)%2552; } if(ans < 0) ans += 2552; cout<<ans<<endl; } } return 0;}</span>
- Your Ways
- Notice your ways of studing
- WAYS TO UPDATE YOUR DEVICE
- Three ways to get your MAC address
- 5 ways to optimize your design
- QTP: Ways to Launch your application
- 20 ways to Secure your Apache Configuration
- 10 ways to Improve Your Programming Productivity
- 101 Ways to Promote Your Web Site
- 9 Ways to Gain Your Visitors Respect
- Three ways to get your MAC address
- Ways to Make Your IT Staff Unpoachable
- 12 Effective Ways To Improve Your Programming
- 9 ways you can boost your memory
- 10 ways to improve your programming skills
- 9 Ways to Instantly Strengthen Your Brain
- Effective C# : 50 Specific Ways to Improve Your C#
- Seven Ways to Reduce Your Stress at Work
- isalpha和isdigit和isupper和islower
- USB接口类设备的分类
- PDF转换成word的给力软件推荐
- Spark开发环境的配置
- MyEclipse向main方法中的args添加参数
- Your Ways
- 数据结构:数制转换
- 【BZOJ4007】【JLOI2015】战争调度 war 搜索
- android apk 防止反编译技术第四篇-对抗JD-GUI
- Swift App状态恢复-State Restoration(一)
- jQuery学习笔记4——A flipboard 剪贴板实例
- 通过结局红米无法绑定百度云推送的问题,分析解决问题的方法。
- iOS:模拟器错误 An error was encountered while running (Domain = FBSOpenApplicationErrorDomain, Code = 4)
- JAVA_Warning: at org.eclipse.jetty.server.handler.HandlerWrapper.handle