国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 學(xué)院 > 開發(fā)設(shè)計 > 正文

HDU 4305 Lightning

2019-11-08 18:37:16
字體:
供稿:網(wǎng)友
PRoblem DescriptionThere are N robots standing on the ground (Don't know why. Don't know how).
Suddenly the sky turns into gray, and lightning storm comes! Unfortunately, one of the robots is stuck by the lightning!
So it becomes overladen. Once a robot becomes overladen, it will spread lightning to the near one.
The spreading happens when:   Robot A is overladen but robot B not.  The Distance between robot A and robot B is no longer than R.  No other robots stand in a line between them.In this condition, robot B becomes overladen. We assume that no two spreading happens at a same time and no two robots stand at a same position.
The problem is: How many kind of lightning shape if all robots is overladen? The answer can be very large so we output the answer modulo 10007. If some of the robots cannot be overladen, just output -1. InputThere are several cases.The first line is an integer T (T < = 20), indicate the test cases.For each case, the first line contains integer N ( 1 < = N < = 300 ) and R ( 0 < = R < = 20000 ), indicate there stand N robots; following N lines, each contains two integers ( x, y ) ( -10000 < = x, y < = 10000 ), indicate the position of the robot. OutputOne line for each case contains the answer. Sample Input
33 2-1 00 11 03 2-1 00 01 03 1-1 00 11 0 Sample Output
31-1 AuthorBUPT Source2012 Multi-University Training Contest 1 Recommendzhuyuanchen520~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~行列式求生成樹個數(shù)~調(diào)到吐血……還是WA……歡迎神犇幫忙查錯……
#include<cstdio>#include<cstring>#include<iostream>#include<cmath>using namespace std;#define zero(u) (u>0 ? u:-u)<1e-15int t,n;bool b[301][301];double a[301][301],r,x[301],y[301];bool che(int u,int v){	if((x[u]-x[v])*(x[u]-x[v])+(y[u]-y[v])*(y[u]-y[v])>r*r) return 0;	if(x[u]>x[v]) swap(u,v);	for(int i=1;i<=n;i++)	  if(i!=u && i!=v)	  {	  	if((x[i]-x[u])*(y[i]-y[v])-(x[i]-x[v])*(y[i]-y[u])) continue;	  	if(x[i]<x[u] || x[i]>x[v]) continue;	  	return 0;	  }	return 1;}double cal(){	int i,j,k,opi=0;double ans=1;	for(i=1;i<=n;i++)	{		if(zero(a[i][i]))		{			for(j=i+1;j<=n;j++) if(!zero(a[j][i])) break;			if(j==n+1) return -1;			for(k=i;k<=n;k++) swap(a[i][k],a[j][k]);			opi++;		}		ans*=a[i][i];ans=fmod(ans,10007);		for(k=i+1;k<=n;k++) a[i][k]/=a[i][i];		for(j=i+1;j<=n;j++)		  for(k=i+1;k<=n;k++) a[j][k]-=a[j][i]*a[i][k];	}	if(opi&1) ans=-ans;	return ans;}int main(){	scanf("%d",&t);	while(t--)	{		memset(a,0,sizeof(a));		memset(b,0,sizeof(b));		scanf("%d%lf",&n,&r);		for(int i=1;i<=n;i++) scanf("%lf%lf",&x[i],&y[i]);		for(int i=1;i<n;i++)		  for(int j=i+1;j<=n;j++)		    if(che(i,j)) b[i][j]=b[j][i]=1;		for(int i=1;i<=n;i++)		  for(int j=1;j<=n;j++) if(b[i][j]) a[i][i]+=1;		for(int i=1;i<=n;i++)		  for(int j=1;j<=n;j++) if(b[i][j]) a[i][j]=-1;		n--;		printf("%0.0lf/n",cal());	}	return 0;}
發(fā)表評論 共有條評論
用戶名: 密碼:
驗(yàn)證碼: 匿名發(fā)表
主站蜘蛛池模板: 东阳市| 甘泉县| 万载县| 云龙县| 科技| 徐闻县| 洱源县| 嘉黎县| 广德县| 茶陵县| 巴彦淖尔市| 定远县| 密山市| 长兴县| 安义县| 达尔| 双峰县| 湖州市| 安塞县| 临高县| 曲沃县| 塔城市| 资源县| 浦北县| 普安县| 襄垣县| 鄂伦春自治旗| 图片| 大庆市| 天津市| 轮台县| 和田市| 广汉市| 武邑县| 喀喇沁旗| 札达县| 吉木乃县| 韶山市| 绥芬河市| 清徐县| 河南省|