HDU 4305 Lightning
来源:互联网 发布:mac拼音切换快捷键 编辑:程序博客网 时间:2024/06/03 07:30
Problem Description
There 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.
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.
Input
There 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.
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.
Output
One 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
Author
BUPT
Source
2012 Multi-University Training Contest 1
Recommend
zhuyuanchen520
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
行列式求生成树个数~
调到吐血……还是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;}
1 0
- HDU 4305 Lightning
- HDU 4305 Lightning
- HDU 4305 Lightning
- hdu - 4305 - Lightning 生成树计数
- hdu 4305 Lightning 高斯消元 计算几何
- Hdu 4305 Lightning - 生成树计数 - 行列式求值
- hdu 4305 Lightning(生成树计数 取模)
- HDU 4305 Lightning (矩阵行列式求生成树个数+高斯逆元求行列式模板)
- HDU 4305 Lightning (生成树的计数+矩阵树定理+逆元)
- HDU 4305 Lightning (判断点在线段上,生成树计数)
- HDU 4305 Lightning(判断点在线段上+生成树计数)
- HDOJ 4305 Lightning 生成树计数
- hdu4305---Lightning
- MagSafe Lightning
- Lightning 関連
- Salesforce Lightning
- hdu 4035 Lightning(无向图生成树的个数)
- jq之lightning
- Android Screen Monitor 将真机屏幕同步到PC
- 理博软件:web前端学习难吗?
- Processing Notify Callouts
- Java 8 动态类型语言Lambda表达式实现原理分析
- JDBC应用程序连接数据库–插入数据并且获得相应自增长值的列(即主键id)
- HDU 4305 Lightning
- Android Vector
- 使用OpenResty控制CDN回源主机
- Android系统广播大全及开机自启动的Service
- 【设计模式】【六】代理模式
- Jersey 文件下载
- Appium通过xpath定位
- 图文报告模块之需求以及未来涉及到的问题
- Android apk信息获取管理和手机信息获取管理