编程介的小学生 2017-04-08 14:48 采纳率: 20.5%
浏览 811
已采纳

Gaussian Prime

In number theory, a Gaussian integer is a complex number whose real and imaginary part are both integers. The Gaussian integers, with ordinary addition and multiplication of complex numbers, form an integral domain, usually written as Z[i]. The prime elements of Z[i] are also known as Gaussian primes. Gaussian integers can be uniquely factored in terms of Gaussian primes up to powers of i and rearrangements.

A Gaussian integer a + bi is a Gaussian prime if and only if either:

One of a, b is zero and the other is a prime number of the form 4n + 3 (with n a nonnegative integer) or its negative -(4n + 3), or
Both are nonzero and a2 + b2 is a prime number (which will not be of the form 4n + 3).
0 is not Gaussian prime. 1, -1, i, and -i are the units of Z[i], but not Gaussian primes. 3, 7, 11, ... are both primes and Gaussian primes. 2 is prime, but is not Gaussian prime, as 2 = i(1-i)2.

Your task is to calculate the density of Gaussian primes in the complex plane [x1, x2] × [y1, y2]. The density is defined as the number of Gaussian primes divided by the number of Gaussian integers.

Input

There are multiple test cases. The first line of input is an integer T ≈ 100 indicating the number of test cases.

Each test case consists of a line containing 4 integers -100 ≤ x1 ≤ x2 ≤ 100, -100 ≤ y1 ≤ y2 ≤ 100.

Output

For each test case, output the answer as an irreducible fraction.

Sample Input

3
0 0 0 0
0 0 0 10
0 3 0 3
Sample Output

0/1
2/11
7/16

  • 写回答

1条回答 默认 最新

  • devmiao 2017-04-08 15:04
    关注
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 用土力学知识进行土坡稳定性分析与挡土墙设计
  • ¥70 PlayWright在Java上连接CDP关联本地Chrome启动失败,貌似是Windows端口转发问题
  • ¥15 帮我写一个c++工程
  • ¥30 Eclipse官网打不开,官网首页进不去,显示无法访问此页面,求解决方法
  • ¥15 关于smbclient 库的使用
  • ¥15 微信小程序协议怎么写
  • ¥15 c语言怎么用printf(“\b \b”)与getch()实现黑框里写入与删除?
  • ¥20 怎么用dlib库的算法识别小麦病虫害
  • ¥15 华为ensp模拟器中S5700交换机在配置过程中老是反复重启
  • ¥15 uniapp uview http 如何实现统一的请求异常信息提示?