# UVA 10790

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:

#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 int
using 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;

}

#### uva-10790-How Many Points of Intersection?

2012-07-17 09:34:32

#### uva 10790

2015-10-24 15:29:56

#### Uva 10790

2013-06-01 20:30:38

#### UVa 10790 多少个交点?

2014-02-14 14:40:27

#### uva 10790(数学)

2014-07-16 17:25:03

#### UVA 10790 多少个交点

2012-09-04 09:58:41

#### UVA 10790 (13.08.06)

2013-08-06 21:22:12

#### uva最全ac代码

2013年07月04日 4.18MB 下载

#### 100 - The 3n + 1 problem.c

2014年01月26日 936B 下载

#### UVA10474 Where is the Marble?

2016年04月29日 146KB 下载