ACM: FZU 2110 Star - 数学几何 - 水题
Description
Input
The first line of the input contains an integer T (T≤10), indicating the number of test cases.
For each test case:
The first line contains one integer n (1≤n≤100), the number of stars.
The next n lines each contains two integers x and y (0≤|x|, |y|≤1,000,000) indicate the points, all the points are distinct.
Output
Sample Input
1
3
0 0
10 0
5 1000
Sample Output
1 求锐角三角形的个数; 数学结论 : 锐角三角形 任意边满足 a^2<b^2+c^2 ; AC代码:
#include"algorithm"
#include"iostream"
#include"cstring"
#include"cstdlib"
#include"cstdio"
#include"string"
#include"vector"
#include"stack"
#include"queue"
#include"cmath"
#include"map"
using namespace std;
typedef long long LL ;
#define lson l,m,rt<<1
#define rson m+1,r,rt<<1|1
#define FK(x) cout<<"["<<x<<"]\n"
#define memset(x,y) memset(x,y,sizeof(x))
#define memcpy(x,y) memcpy(x,y,sizeof(x))
#define bigfor(T) for(int qq=1;qq<= T ;qq++) struct Star {
LL x;
LL y;
} st[200]; bool cmp(LL a,LL b) {
return a>b;
} bool check(int i,int j,int k) {
LL s[3];
s[0]=(st[i].x-st[j].x)*(st[i].x-st[j].x)+(st[i].y-st[j].y)*(st[i].y-st[j].y);
s[1]=(st[i].x-st[k].x)*(st[i].x-st[k].x)+(st[i].y-st[k].y)*(st[i].y-st[k].y);
s[2]=(st[k].x-st[j].x)*(st[k].x-st[j].x)+(st[k].y-st[j].y)*(st[k].y-st[j].y);
// FK(s[0]);
// FK(s[1]);
// FK(s[2]);
sort(s,s+3,cmp);
if(s[0]<s[1]+s[2])return 1;
return 0;
} int main() {
int T;
int n;
scanf("%d",&T);
bigfor(T) {
scanf("%d",&n);
for(int i=0; i<n; i++) {
scanf("%I64d%I64d",&st[i].x,&st[i].y);
}
LL ans=0;
for(int i=0; i<n; i++) {
for(int j=i+1; j<n; j++) {
for(int k=j+1; k<n; k++) {
if(check(i,j,k)) ans++;
}
}
}
printf("%I64d\n",ans);
}
return 0;
}
ACM: FZU 2110 Star - 数学几何 - 水题的更多相关文章
- nyoj--1011--So Easy[II](数学几何水题)
So Easy[II] 时间限制:1000 ms | 内存限制:65535 KB 难度:2 描述 这是一道基础的计算几何问题(其实这不提示大家也都看的出).问题描述如下: 给你一个N边形.且N边形 ...
- ACM :漫漫上学路 -DP -水题
CSU 1772 漫漫上学路 Time Limit: 1000MS Memory Limit: 131072KB 64bit IO Format: %lld & %llu Submit ...
- HDU 2674 N!Again(数学思维水题)
题目 //行开始看被吓一跳,那么大,没有头绪, //看了解题报告,发现这是一道大大大的水题,,,,,//2009 = 7 * 7 * 41//对2009分解,看它有哪些质因子,它最大的质因子是41,那 ...
- HDU ACM 1073 Online Judge ->字符串水题
分析:水题. #include<iostream> using namespace std; #define N 5050 char a[N],b[N],tmp[N]; void Read ...
- UVa 12230 && HDU 3232 Crossing Rivers (数学期望水题)
题意:你要从A到B去上班,然而这中间有n条河,距离为d.给定这n条河离A的距离p,长度L,和船的移动速度v,求从A到B的时间的数学期望. 并且假设出门前每条船的位置是随机的,如果不是在端点,方向也是不 ...
- ACM: FZU 2102 Solve equation - 手速题
FZU 2102 Solve equation Time Limit:1000MS Memory Limit:32768KB 64bit IO Format:%I64d & ...
- ACM: POJ 1401 Factorial-数论专题-水题
POJ 1401 Factorial Time Limit:1500MS Memory Limit:65536KB 64bit IO Format:%lld & %llu ...
- FZU 2110 Star
简单暴力题,读入%lld会WA,%I64d能过. #include<cstdio> #include<cstring> #include<cmath> #inclu ...
- C 几何水题 求不同斜率的数目 枚举+set
Description Master LU 非常喜欢数学,现在有个问题:在二维空间上一共有n个点,LU每连接两个点,就会确定一条直线,对应有一个斜率.现在LU把平面内所有点中任意两点连线,得到的斜率放 ...
随机推荐
- 直接操作 SDL_Overlay YUV叠加上的像素
根据这篇解码出yuv数据后 海思h264解码库 y,u,v数据全部存进数组内, IntPtr y = _decodeFrame.pY; IntPtr ...
- Shell入门教程:流程控制(5)for 循环
for循环的运作方式,是将 串行 的元素的元素一一取出,依序放入制定的变量中,然后重复执行含括的命令区域(在 do 与 done 之间),直到所有元素取尽为止. 其中,串行是一些字符串的组合,彼此用 ...
- 【Android学习】android:layout_weight的用法实例
对于android:layout_weight的用法,用下面的例子来说明: <LinearLayout xmlns:android="http://schemas.android.co ...
- mount -t nfs 的使用
服务安装:1. 在VMware Ubuntu中安装NFS服务: sudo apt-get install nfs-kernel-server2. 安装成功会出现配置文件/etc/exports. ls ...
- Linux使用手册-时区和时间设置
1. #vi /etc/sysconfig/clockZONE=”Asia/Shanghai”UTC=false2.#vi /usr/share/zoneinfo/Asia/Shanghai,如果结尾 ...
- WORDPRESS点击标题或图片无法链接到文章页面
在设置出更改固定连接设置
- java基本算法之冒泡排序
冒泡排序:是一种较简单的排序算法.它会遍历若干次要排序的数列,每次遍历时,它都会从前往后依次的比较相邻两个数的大小:如果前者比后者大,则交换它们的位置.这样,一次遍历之后,最大的元素就在数列的末尾! ...
- Android错误
1. [2016-09-16 14:25:45 - X_Card] Found 2 versions of android-support-v4.jar in the dependency list, ...
- Effective Python2 读书笔记1
Item 2: Follow the PEP 8 Style Guide Naming Naming functions, variables, attributes lowercase_unders ...
- [转] ImageView的android:adjustViewBounds属性
原文链接:http://blog.csdn.net/pingchuanyang/article/details/9252689 取值为true时: Adjust the ImageView's b ...