公式队友推的啊
题解在这里http://blog.sina.com.cn/s/blog_6bddecdc0102uyex.html
然后java悲剧了 比的时候怎么调怎么烂 然后C++大数模版居然TLE
留个赛后写的在这里 看来比赛的时候还是太无脑了 java大数写法就当提个醒吧
import java.math.BigInteger;
import java.util.Scanner;
public class Main {
static Scanner cin=new Scanner(System.in);
public static void main(String[] args)
{
int n,t;
BigInteger a,b,c,d,e,sum,x,N,two=BigInteger.valueOf(2),one=BigInteger.valueOf(1),eight;
BigInteger fone=BigInteger.valueOf(-1),six=BigInteger.valueOf(6),four=BigInteger.valueOf(4);
int D;
while(cin.hasNext()){
N=cin.nextBigInteger();D=cin.nextInt();
c=BigInteger.valueOf(D*(D-1));
a=N;a=a.add(four);
a=a.multiply(a);
a=a.multiply(c);
b=N;b=b.pow(D);
b=b.multiply(BigInteger.valueOf(18));
d=a.gcd(b);
if(a.equals(b)){
System.out.println("1");
}
else {
System.out.println(a.divide(d)+"/"+b.divide(d));
}
}
}
}
本文分享了一段使用Java进行大数运算的代码实现,针对特定算法问题进行了讨论,并提供了详细的代码解释与赛后总结。文章重点介绍了如何利用BigInteger类进行高效的大数计算,以及在算法竞赛中遇到的问题和解决方案。
788

被折叠的 条评论
为什么被折叠?



