Let's assume that

  • v(n) is the largest prime number, that does not exceed n;
  • u(n) is the smallest prime number strictly greater than n.

Find .

Input

The first line contains integer t (1 ≤ t ≤ 500) — the number of testscases.

Each of the following t lines of the input contains integer n (2 ≤ n ≤ 109).

Output

Print t lines: the i-th of them must contain the answer to the i-th test as an irreducible fraction "p/q", where p, q are integers, q > 0.

Sample test(s)
input
2
2
3
output
1/6
7/30

分析:把公式分解1/(p*q)=1/(p-q) *  (1/q-1/p) 然后求和发现公式:ans=(-2q+2*n-2*p+2+2*q*q)/(2*u*v);

 1 #include<cstdio>
 2 #include<cmath>
 3 #include<algorithm>
 4 using namespace std;
 5 bool isprime(unsigned long long x)
 6 {
 7     int idx=sqrt(x);
 8     for(int i=; i<=idx; ++i)
 9         if(x%i==)
             return false;
     return true;
 }
 int main()
 {
     int t;
     unsigned long long n;
     scanf("%d",&t);
     while(t--)
     {
         scanf("%I64u",&n);
         unsigned long long v=n,u=n+;
         while(!isprime(v))
             --v;
         while(!isprime(u))
             ++u;
         unsigned long long p=v*u-*u+*n-*v+,q=*v*u,tmp=__gcd(p,q);
         printf("%I64u/%I64u\n",p/tmp,q/tmp);
     }
 }

最新文章

  1. 分享“12306 P2P平台”创业Idea
  2. JS实现常用排序算法—经典的轮子值得再造
  3. 弱省互测#0 t1
  4. Max批量导出工具
  5. 二 J2EE 概述
  6. py继续
  7. 在VS中快速查看文件被谁签出
  8. Deep Learning and Shallow Learning
  9. [转]LoadRunner脚本录制常见问题整理
  10. 独木舟上的旅行--nyoj题目71
  11. HDU 1018-Big Number(数学)
  12. Android系统APN配置具体解释
  13. SQL Profile (总结4)--使用演示示例
  14. CodeForces 662D International Olympiad
  15. 新入门的小白,整理一下特别简单实用的div+css兼容性的问题。
  16. x&amp;(x-1)
  17. 10个用于处理日期和时间的 Python 库
  18. mysql免安装版的下载与安装
  19. MongoDB高可用集群+MMS集群监控搭建
  20. 选择排序Java版

热门文章

  1. HTML5移动Web开发
  2. tp5增加验证的自定义规则
  3. linux学习之路7 linux下获取帮助
  4. 贪心/思维题 UVA 11292 The Dragon of Loowater
  5. ora-20000 unable to analyze
  6. python调用chrome ie等浏览器
  7. RaspberryPi cProfile使用
  8. 《从Paxos到ZooKeeper 分布式一致性原理与实践》阅读【Leader选举】
  9. CMD命令行提示被禁用的情况下如何继续使用命令行工具执行命令
  10. codeforces_305C_STLset