题目链接

思路:

思考一下会发现选择质因子越多的且越小的会使得结果更小,因此预处理前100的质因子,询问直接查询处理数组。需要写大数

ac代码:

import java.util.Scanner;
import java.math.*;
public class Main {public static void main(String[] args) {int N=1000;int pri[]=new int[1005];int vis[]=new int[1005];node ans[]=new node[1005];int cnt=0;int tot=0;for(int i=2;i<=N;i++){if(vis[i]==0) pri[cnt++]=i;for(int j=0;j<cnt&&pri[j]*i<=N;j++){vis[pri[j]*i]=1;if(i%pri[j]==0) continue;}}for(int i=0;i<=1000;i++) {ans[i]=new node();ans[i].p = new BigInteger("0");ans[i].q = new BigInteger("0");ans[i].val = new BigInteger("0");}ans[tot].val=new BigInteger("1");ans[tot].p=new BigInteger("1");ans[tot++].q=new BigInteger("1");for(int i=0;i<=100;i++){ans[tot].val=ans[tot-1].val.multiply(BigInteger.valueOf(pri[i]));ans[tot].p=ans[tot-1].p.multiply(BigInteger.valueOf(pri[i]+1));ans[tot].q=ans[tot-1].q.multiply(BigInteger.valueOf(pri[i]));BigInteger g=ans[tot].p.gcd(ans[tot].q);ans[tot].p=ans[tot].p.divide(g);ans[tot].q=ans[tot].q.divide(g);tot++;}int t;Scanner rd=new Scanner(System.in);t=rd.nextInt();while(t>0){BigInteger n;n=rd.nextBigInteger();for(int i=0;i<tot;i++){
//                System.out.print(ans[i].val+"\n"+n+"\n");if(ans[i].val.compareTo(n)==1){System.out.print(ans[i-1].q+"/"+ans[i-1].p+'\n');
//                  printf("%lld %lld\n",ans[tot].q,ans[tot].p);break;}}t--;}}}
class node{BigInteger p,q,val;
}

【2018焦作-E】Resistors in Parallel(思维+大数)相关推荐

  1. gym102028 problem E Resistors in Parallel (大数)

    链接 题意: 给出一个n,在n里面的ri如上图定义,求找出一个ri,ri的所有因子分之一的和最大.输出的是和的倒数. 思路: 看到这道题就打了下表,发现280以内的素数乘积就可以超过 10100 了, ...

  2. 2018焦作ICPC E - Resistors in Parallel(规律+Java大数)

    2018焦作ICPC E - Resistors in Parallel题目链接 Time limit  2000 ms Memory limit  1048576 kB In this physic ...

  3. 2018焦作ICPC E. Resistors in Parallel(打表+大数)

    E. Resistors in Parallel 题意: 图1: 图2 图3: 选择n以内的一个i,使得Si最大,S_i的值就是说i的所有因子作为下标j,对所有r_j(计算方式见图1)进行图2中的运算 ...

  4. 2018 焦作 onsite E - Resistors in Parallel(数学或规律+大数)

    题目链接:http://codeforces.com/gym/102028/problem/EE. Resistors in Parallel time limit per test 2.0 s me ...

  5. 2018ACM-ICPC焦作站E题Resistors in Parallel

    Resistors in Parallel 题目: ACM-ICPC Jiaozuo Onsite 2018 题解:因为题目数据范围很大,所以猜测应该是一个区间一个固定的最小值.问题转换成了如何求某个 ...

  6. python笔记之1-简单读入+循环、判断+数组+函数调用+题目Resistors in Parallel(18焦作)

    ....本来博主想一心一意搞算法和C++的,但今天的大数用C++写真的...心态爆炸,然后学了一波python...多路周折终于A了这题 python的语言在有了c语言的基础上其实还挺好学的...虽然 ...

  7. ICPC焦作站(E、F)+思维+树上dp

    这场比赛依旧是三道题,E其实比我们出的D难一点,但确实在能力范围之内,出了就保底铜牌了,出的快的话说不定有银.策略很重要 E. Resistors in Parallel 大数+打表找规律. 最后得出 ...

  8. E. Resistors in Parallel

    E. Resistors in Parallel [link](Problem - E - Codeforces) 题意 给你n个电阻,如果第i个电阻可以被一个大于1的完全平方数整除,他的阻值就是无穷 ...

  9. ACM-ICPC 2018 焦作赛区网络预赛 J(二分+JAVA高精)

    传送门 题面: 65536K Jessie and Justin want to participate in e-sports. E-sports contain many games, but t ...

  10. ACM-ICPC 2018 焦作赛区网络预赛 H题 String and Times(SAM)

    Now you have a string consists of uppercase letters, two integers AA and BB. We call a substring won ...

最新文章

  1. 3-unit10 iptables
  2. metaProdigal:宏基因组序列中的基因和翻译起始位点预测
  3. movsb movsw movsd 指令详解
  4. 32 六角oled驱动_Alienware下半年开售55英寸OLED显示器,4K120Hz、95%DCI-P3
  5. 8.12-14 df 、mkswap、swapon、swapoff、sync
  6. 可持续字典树 Perfect Security
  7. 随笔37 JVM内存
  8. 17.PHPDoc 规范,PHPDocumenter 生成
  9. 找回WordPress登录密码的方法
  10. 计算机组成原理课程设计:复杂模型机
  11. 时间都去哪了?BPC电波授时信号的“零成本”伪造
  12. TBODY标签有什么作用
  13. source insight的使用
  14. 学计算机的怎样提升打字速度,想提高打字速度吗?
  15. 使用bat脚本运行python脚本,bat出现闪退,怎么解决?
  16. bindingx 表达式动画
  17. ZBar源码分析(二)
  18. 关闭HttpClient
  19. ctfshow_2021月饼杯记录
  20. 计算机网络--错题集

热门文章

  1. 无线测温装置在变压器中的设计与应用
  2. 如何快速验证你的创业想法是否可行?这里有7大策略
  3. pythondis功能_python中dis的用法
  4. 关于电子科技大学本科生宿舍热水情况调查
  5. pes2017服务器维护时间,PES2017授权详情与球场数据包发布时间
  6. Error creating bean with name xxxxxxx
  7. 互联网应用开发实践:需求分析与数据库设计
  8. Pytorch中的多项分布multinomial.Multinomial().sample()解析
  9. 0x01位运算——a^b
  10. vm安装中标麒麟v7.0