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 ...
随机推荐
- VirtualBox 安装XP虚拟机需要注意的问题
1.首先要有xp系统的镜像文件 http://pan.baidu.com/s/1i4xrwdJ 2.新建虚拟机,并安装 http://www.pczhishi.cn/shipin/107.html 3 ...
- Java DecimalFormat 用法(数字格式化)
我们经常要将数字进行格式化,比如取2位小数,这是最常见的.Java 提供 DecimalFormat 类,帮你用最快的速度将数字格式化为你需要的样子.下面是常用的例子: import java.tex ...
- [Redis] - 高并发下Redis缓存穿透解决
高并发情况下,可能都要访问数据库,因为同时访问的方法,这时需要加入同步锁,当其中一个缓存获取后,其它的就要通过缓存获取数据. 方法一: 在方法上加上同步锁 synchronized //加同步锁,解决 ...
- MYSQL语句:创建、授权、查询、修改、统计分析等 一 用户的创建、权限设置、删除等
MYSQL语句:创建.授权.查询.修改.统计分析.. 一.用户的创建.权限设置.删除等 1.首先链接MySQL操作 连接格式:mysql -h 主机地址 -u 用户名 -p 用户密码 (注-u与roo ...
- 使用JavaScript / JQuery导出 html table 数据至 Excel 兼容IE/Chrome/Firefox
function fnExcelReport() { var tab_text="<table border='2px'><tr bgcolor='#87AFC6'> ...
- go变量赋初值
package main import "fmt" func variableinitial(){ , var s string="abc" fmt.Print ...
- package 'orocos-bfl' not found CMake Error at /usr/share/cmake-2.8/Modules/FindPkgConfig.cmake:283 (message):
#没有数字 sudo apt-get install ros-indigo-bfl
- 使用R内置函数操作数据框
我们已经学习了数据框的基础,这里回顾一下用于筛选数据框的内置函数.尽管数据框本质上是一个由向量构成的列表,由于各列长度相同,所以可以将其看作矩阵进行访问和操作.选择满足特定条件的行,需要为 [ ] 的 ...
- [原][OSG][osgBullet][osgworks][bullet]编译osgBullet尝试物理引擎
相关网址: 类似文章:http://blog.csdn.net/lh1162810317/article/details/17475297 osgBullet官网:http://osgbullet.v ...
- 在centos下解决 “致命错误:curses.h:没有那个文件或目录”
当在centos下编译带有头文件<curses.h> 的程序时,出现以下错误: “致命错误:curses.h:没有那个文件或目录” ,最后在“https://zhidao.baidu.co ...