UVALive 5984
题目链接:Save the Students!
#include<stdio.h>
#include<string.h>
#include<iostream>
#include<math.h>
using namespace std; bool vis[][]; // 所有数据保证在1到50.那么坐标在-50到100之间。所以。哈希到50到200之间。开始开的200*200的。WA。 double dis(double x1, double y1, double x2, double y2) // 两点间距离。
{
// cout << x1 << "==" << y1 << "==" << x2<< "==" << y2 << "==" << endl;
double xx = (x2-x1)*(x2-x1);
double yy = (y2-y1)*(y2-y1);
double ans = xx+yy+0.0;
return ans;
} int circle(int a, int b, int r) //是否在圆内。
{
int cnt = ;
for (int i=a-r; i<=a+r; ++i)
{
for (int j=b-r; j<=b+r; ++j)
{
if (!vis[i+][j+])
{
if (dis(i, j, a, b) <= r*r)
{
cnt++;
vis[i+][j+] = ;
}
}
}
}
return cnt;
} double area(int x1, int y1, int x2, int y2, int x3, int y3) // 三角形面积。
{
double temp = (x2-x1)*(y3-y1) - (x3-x1)*(y2-y1);
temp /= 2.0;
if (temp < ) temp = -temp;
return temp;
} int triangle(int x1, int y1, int x2, int y2, int x3, int y3) //是否在三角形内。
{
int cnt = ;
int minx = min(x1, min(x2, x3));
int maxx = max(x1, max(x2, x3));
int miny = min(y1, min(y2, y3));
int maxy = max(y1, max(y2, y3)); for (int i=minx; i<=maxx; ++i)
{
for (int j=miny; j<=maxy; ++j)
{
if (!vis[i+][j+])
{
double s1 = area(i, j, x1, y1, x2, y2);
double s2 = area(i, j, x1, y1, x3, y3);
double s3 = area(i, j, x2, y2, x3, y3);
double s = area(x1, y1, x2, y2, x3, y3);
if (s1 + s2 + s3 == s)
{
cnt++;
vis[i+][j+] = ;
}
}
}
}
return cnt;
} int square(int x1, int y1, int l) //正方形直接判断是不是已经被覆盖了。就可以。开始用了一个巨蠢的用距离判断点是不是在正方形内。。呵呵。。。。
{
int cnt = ;
for (int i=x1; i<=x1+l; ++i)
{
for (int j=y1; j<=y1+l; ++j)
{
if (!vis[i+][j+])
{
cnt++;
vis[i+][j+] = ;
}
}
}
return cnt;
} int main()
{
int t, n;
int x1, x2, x3, x4, x5, x6;
scanf("%d", &t);
while(t--)
{
scanf("%d", &n);
memset(vis, , sizeof(vis));
int ans = ;
for (int i=; i<n; ++i)
{
char temp;
getchar();
scanf("%c", &temp);
if (temp == 'C')
{
scanf("%d%d%d", &x1, &x2, &x3);
ans += circle(x1, x2, x3);
}
else if (temp == 'S')
{
scanf("%d%d%d", &x1, &x2, &x3);
ans += square(x1, x2, x3);
}
else if (temp == 'T')
{
scanf("%d%d%d%d%d%d", &x1, &x2, &x3, &x4, &x5, &x6);
ans += triangle(x1, x2, x3, x4, x5, x6);
}
}
printf("%d\n", ans);
}
return ;
}
UVALive 5984的更多相关文章
- UVALive - 4108 SKYLINE[线段树]
UVALive - 4108 SKYLINE Time Limit: 3000MS 64bit IO Format: %lld & %llu Submit Status uDebug ...
- UVALive - 3942 Remember the Word[树状数组]
UVALive - 3942 Remember the Word A potentiometer, or potmeter for short, is an electronic device wit ...
- UVALive - 3942 Remember the Word[Trie DP]
UVALive - 3942 Remember the Word Neal is very curious about combinatorial problems, and now here com ...
- 思维 UVALive 3708 Graveyard
题目传送门 /* 题意:本来有n个雕塑,等间距的分布在圆周上,现在多了m个雕塑,问一共要移动多少距离: 思维题:认为一个雕塑不动,视为坐标0,其他点向最近的点移动,四舍五入判断,比例最后乘会10000 ...
- UVALive 6145 Version Controlled IDE(可持久化treap、rope)
题目链接:https://icpcarchive.ecs.baylor.edu/index.php?option=com_onlinejudge&Itemid=8&page=show_ ...
- UVALive 6508 Permutation Graphs
Permutation Graphs Time Limit:3000MS Memory Limit:0KB 64bit IO Format:%lld & %llu Submit ...
- UVALive 6500 Boxes
Boxes Time Limit:3000MS Memory Limit:0KB 64bit IO Format:%lld & %llu Submit Status Pract ...
- UVALive 6948 Jokewithpermutation dfs
题目链接:UVALive 6948 Jokewithpermutation 题意:给一串数字序列,没有空格,拆成从1到N的连续数列. dfs. 可以计算出N的值,也可以直接检验当前数组是否合法. # ...
- 【暑假】[实用数据结构]UVAlive 3135 Argus
UVAlive 3135 Argus Argus Time Limit: 3000MS Memory Limit: Unknown 64bit IO Format: %lld & %l ...
随机推荐
- 2017.11.11 B201 练习题思路及解题方法
2017.11.11 B201 练习题思路及解题方法 题目类型及涵盖知识点 本次总共有6道题目,都属于MISC分类的题目,涵盖的知识点有 信息隐藏 暴力破解 音轨,摩斯电码 gif修改,base64原 ...
- 【前端】javascript+jQuery实现旋转木马效果轮播图slider
实现效果: 实现原理: 技术栈: javascript+jQuery+html+css 实现步骤: // 0. 获取元素 // 1. 鼠标放置到轮播图上,显示两侧的控制按钮,移开后隐藏 // 2. 为 ...
- Python3基础 os listdir 列举指定的所有文件及文件夹的名字
Python : 3.7.0 OS : Ubuntu 18.04.1 LTS IDE : PyCharm 2018.2.4 Conda ...
- Python3基础 super 子类调用父类的__init__
Python : 3.7.0 OS : Ubuntu 18.04.1 LTS IDE : PyCharm 2018.2.4 Conda ...
- P4113 [HEOI2012]采花 (莫队TLE)
思路 update 11.2 树状数组AC 本题莫队过不去,会TLE ----------------------- 但也是个不错的莫队练手题 ------------------------ 毕竟C ...
- springboot整合mybatis将sql打印到日志(转)
在前台请求数据的时候,sql语句一直都是打印到控制台的,有一个想法就是想让它打印到日志里,该如何做呢? 见下面的mybatis配置文件: <?xml version="1.0" ...
- C#入门经典 第六章 委托
C#入门经典 第六章 6.6 委托的声明非常类似于函数,但不带函数体,且要使用delegate关键字. 委托的声明指定了一个返回类型和一个参数列表. 在定义了委托后,就可以声明该委托类型的变量. 接着 ...
- 【第十六章】 springboot + OKhttp + String.format
模拟浏览器向服务器发送请求四种方式: jdk原生的Http包下的一些类 httpclient(比较原始,不怎么用了):第一章 HttpClient的使用 Okhttp(好用,推荐) retrofit( ...
- hdu 6168 Numbers
Numbers Time Limit: 4000/2000 MS (Java/Others) Memory Limit: 131072/131072 K (Java/Others)Total S ...
- Spooling技术
转自https://blog.csdn.net/weixin_42229896/article/details/80736517 假脱机的概念 SPOOLing技术:利用高速共享设备(通常是磁鼓或 ...