UVA 10790
来源:互联网 发布:js移除数组中某个元素 编辑:程序博客网 时间:2024/05/21 14:48
Thinking : It's a quite easy problem if you can find the relationship between P(a,b) and P(a-1,b) or P(a,b-1).
Based on our math knowledge and observation from the picture, we can know that P(a,b) = P(a-1,b) + (a-1)*(b*(b-1)/2).
AC code:
Based on our math knowledge and observation from the picture, we can know that P(a,b) = P(a-1,b) + (a-1)*(b*(b-1)/2).
AC code:
#include<iostream>#include<cstring>#include<cmath>#include<algorithm>#include<queue>#define MIN(a,b) ((a)<(b)?(a):(b))#define epsilon 1.0e-6#define lli long long intusing namespace std;//lli P[20005][20005];lli parent(lli a,lli b){if (a == 1 || b == 1)return 0;return parent(a - 1, b) + (a - 1)*(b*(b - 1)) / 2;}int main(){lli a, b;int T = 0;while (1){T++;scanf("%lld%lld", &a, &b);if (a == 0 && b == 0)break;lli ans = parent(a, b);printf("Case %d: %lld\n", T, ans);}return 0;}
0 0
- Uva 10790
- uva 10790
- UVA 10790
- uva 10790
- uva 10790
- UVA 10790
- UVA 10790
- UVA 10790 (13.08.06)
- uva 10790(数学)
- uva
- UVA
- UVA
- UVA
- uva
- UVA
- UVA
- UVA
- UVA
- Docker 入门教程(九)
- synchronized 修饰在 static方法和 非static方法的区别
- Android 屏幕适配方案(百分比)
- Java中的Random()函数
- 怎么实现ZBrush中复数对象的快速运用
- UVA 10790
- 合格的字符串
- linux进程通信--共享内存
- 常用开源协议
- 三层加密密钥相关名词
- Android-----fragment-----跳转总结
- RMQ与LCA(From TopCoder Algorithm Tutorials)
- 欢迎使用CSDN-markdown编辑器
- ORA-16003: standby database is restricted to read-only access