Test on 01/19/2019

LZDFDSMLL吃批萨(easy)

Description

LZDFDSMLL最近收到了一个批萨,这个批萨可以表示成n行m列的矩形,已知这个批萨上有k块被吃掉了。

LZDFDSMLL一定要吃一块完整的正方形的批萨,请问他有多少种不同的批萨可以吃。

不同批萨的定义:

两个正方形批萨只要左上角的点不一样, 或者正方形批萨的边长不一样就算不同。

Input

第一行两个正数n,m, k, 分别表示矩阵的行数、矩阵的列数、被吃掉的块数。

接下来有k行,每行有两个数x, y, 表示在x行y列的那块批萨被吃掉了。

(1 <= n, m <= 500, k <= min(500, n*m))

output

一个整数表示LZDFDSMLL有多少种不同的正方形批萨可以吃。

Examples

Input

3 3 0

Output

14

Input

3 3 1
2 2

Output

8

正确解法:

f[i][j]=min(f[i-1][j],f[i][j-1],f[i-1][j-1])+1;

 1 #include<iostream>
 2 #include<cstdio>
 3 #include<cmath>
 4 #include<algorithm>
 5 #include<string>
 6 #include<cstring>
 7 using namespace std;
 8 long long a[5100][5100],f[5100][5100];
 9 int main()
10 {
11     int n,m,k,xx,yy;
12     long long ans=0;
13     scanf("%d %d %d",&n,&m,&k);
14     while(k--)
15     {
16         scanf("%d %d",&xx,&yy);
17         a[xx][yy]=1;
18     }
19     for(int i=1;i<=n;i++)
20         for(int j=1;j<=m;j++)
21         {
22             if(!a[i][j])
23             {
24                 f[i][j]=min(min(f[i-1][j],f[i][j-1]),f[i-1][j-1])+1;
25                 ans+=f[i][j];
26             }
27         }
28     printf("%d
",ans);
29     return 0;
30 }
View Code

duxing201606玩游戏

Description

duxing201606喜欢看一款叫sc2的游戏,他发现在zvt时,经常会有拉狗引雷的操作,但是他自己操作不来,所有他想问问你:假设每颗雷的爆炸范围可能不一样,但是都是一个圆,只要狗走到圆内雷就会爆炸,最少需要拉几条狗引雷才能使雷全部爆炸?注意:因为两圆可能相交,所以有时候一条狗能引好几颗雷,雷和雷之间不会相互引爆.数据采用如下代码生成(rand()会产生一个0到2147483647的随机数):

2019-01-13 15-19-42屏幕截图.png

第i个雷坐标为(xi,yi),爆炸范围是ri,n为地雷数.

Input

多组测试,一个数n(n<=1000).接下来n行,每行三个数x,y,z,表示坐标(x,y)和半径r

output

最少的小狗数

Examples

Input

2
692314992 977213841 56
2140129659 884284570 108

Output

2

正确解法:

暴力真厉害。

 1 #include<iostream>
 2 #include<cstdio>
 3 #include<cmath>
 4 #include<algorithm>
 5 #include<string>
 6 #include<cstring>
 7 using namespace std;
 8 int n,ans=1;
 9 struct student
10 {
11     int x,y,r;
12 }a[1010];
13 int cmp(student a,student b)
14 {
15     if((a.x-b.x)*(a.x-b.x)+(a.y-b.y)*(a.y-b.y)<=(a.r+b.r)*(a.r+b.r))
16         return 1;
17     return 0;
18 }
19 int main()
20 {
21     while(scanf("%d",&n)!=EOF)
22     {
23         ans=1;
24     for(int i=1;i<=n;i++)
25         scanf("%d %d %d",&a[i].x,&a[i].y,&a[i].r);
26     for(int i=2;i<=n;i++)
27     {
28         int flag=1;
29         for(int j=1;j<i;j++)
30             if(cmp(a[i],a[j]))
31                 flag=0;
32         ans+=flag;
33     }
34     printf("%d
",ans);
35     }
36     return 0;
37 }
View Code
No matter how you feel, get up , dress up , show up ,and never give up.
原文地址:https://www.cnblogs.com/Kaike/p/10294014.html