编程介的小学生 2017-08-21 15:05 采纳率: 20.5%
浏览 954
已采纳

How I Wonder What You Are!

Description

One of the questions children often ask is “How many stars are there in the sky?” Under ideal conditions, even with the naked eye, nearly eight thousands are observable in the northern hemisphere. With a decent telescope, you may find many more, but as the sight field will be limited, you may find much less at a time.

Children may ask the same questions to their parents on a planet of some solar system billions of light-years away from the Earth. Their telescope are similar to ours with circular sight fields, but alien kids have many eyes and ca look into different directions at a time through may telescopes.

Given a set of positions of stars, a set of telescopes and the directions the are looking to, your task is to count up how many stars can be seen through these telescopes.

Input

The input consists of one or more datasets. The number of datasets is less than 50. Each dataset describes stars and the parameters of the telescopes used.

The first line of a dataset contains a positive integer n not exceeding 500, meaning the number of stars. Each of the n lines following it contains three decimal fractions, sx, sy, and sz. They give the position (sx, sy, sz) of the star described in Euclidean coordinates. You may assume −1000 ≤ sx ≤ 1000, −1000 ≤ sy ≤ 1000, −1000 ≤ sz ≤ 1000, and (sx, sy, sz) ≠ (0, 0, 0).

Then comes a line containing a positive integer m not exceeding 50, meaning the number of telescopes. Each of the following m lines contains four decimal fractions, tx, ty, tz and ψ, describing a telescope.

The first three numbers represent the direction of the telescope. All the telescopes are at the origin of the coordinate system (0, 0, 0) (we ignore the size of the planet). The three numbers give the point (tx, ty, tz) which can be see in the center of the sight through the telescope. You may assume −1000 ≤ tx ≤ 1000, −1000 ≤ ty ≤ 1000, −1000 ≤ tz ≤ 1000, and (tx, ty, tz) ≠ (0, 0, 0).

The fourth number ψ (0 ≤ ψ ≤ π ⁄ 2) gives the angular radius, radians, of the sight field of the telescope. Let us define that θi,j is the angle between the direction of the i-th star and the center direction of the j-th telescope and ψj is the angular radius of the sight field of the j-th telescope. the i-th star is observable through the j-th telescope if and only if θi,j is less than ψj. You may assume that |θi,j − ψj| > 0.00000001 for all pairs of i and j.

Figure 1: Direction and angular radius of a telescope

The end of the input is indicated with a line containing a single zero.

Output

For each dataset, one line containing an integer meaning the number of stars observable through the telescope should be output. No other characters should be contained in the output. Note that stars that can be seen through more than one telescope should not be counted twice or more.

Sample Input

3
100 0 500
-500.243 -200.1 -300.5
0 300 200
2
1 1 1 0.65
-1 0 0 1.57
3
1 0 0
0 1 0
0 0 1
4
1 -1 -1 0.9553
-1 1 -1 0.9554
-1 -1 1 0.9553
-1 1 -1 0.9554
3
1 0 0
0 1 0
0 0 1
4
1 -1 -1 0.9553
-1 1 -1 0.9553
-1 -1 1 0.9553
-1 1 -1 0.9553
0
Sample Output

2
1
0

  • 写回答

4条回答 默认 最新

  • threenewbee 2017-09-03 14:30
    关注
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(3条)

报告相同问题?

悬赏问题

  • ¥15 matlab数字图像处理频率域滤波
  • ¥15 ELGamal和paillier计算效率谁快?
  • ¥15 file converter 转换格式失败 报错 Error marking filters as finished,如何解决?
  • ¥15 ubuntu系统下挂载磁盘上执行./提示权限不够
  • ¥15 Arcgis相交分析无法绘制一个或多个图形
  • ¥15 关于#r语言#的问题:差异分析前数据准备,报错Error in data[, sampleName1] : subscript out of bounds请问怎么解决呀以下是全部代码:
  • ¥15 seatunnel-web使用SQL组件时候后台报错,无法找到表格
  • ¥15 fpga自动售货机数码管(相关搜索:数字时钟)
  • ¥15 用前端向数据库插入数据,通过debug发现数据能走到后端,但是放行之后就会提示错误
  • ¥30 3天&7天&&15天&销量如何统计同一行