【2014 Multi-University Training Contest 2 1002】/【HDU 4873】 ZCC Loves Intersection
果然,或滥用零件,啥都不说了。我们欣慰地学习阅读。这两天残疾儿童是数学。
这是求所需的问题,不明确。贴上官方的解题报告。
watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQvbGluMzc1NjkxMDEx/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70/gravity/SouthEast" align="middle" alt="">
留着慢慢研究 。
好吧看到其它人写的发现有自带函数。就再贴一个新的。
就得在最以下:
import java.math.BigInteger;
import java.util.Scanner; public class Main {
static BigInteger [][] c = new BigInteger[110][110];
public static void del() {
for(int i = 0; i <= 105; i ++)
c[i][0] = c[i][i] = BigInteger.ONE;
for(int i = 1; i <= 105; i ++)
{
for(int j = 1; j < i; j ++)
c[i][j] = (c[i-1][j-1] .add(c[i-1][j]));
}
}
public static void main(String[] args) {
Scanner cin = new Scanner(System.in);
int d;
BigInteger n=BigInteger.ZERO,up=BigInteger.ZERO,down=BigInteger.ZERO,temp=BigInteger.ZERO;
del();
while(cin.hasNext())
{
n=cin.nextBigInteger();
d=cin.nextInt();
up=c[d][2].multiply(n.add(BigInteger.valueOf(4)).pow(2));
down=BigInteger.valueOf(9).multiply(n.pow(d));
if(up.compareTo(down)==0)
{
System.out.println(1);
}
else {
temp=up.gcd(down);
System.out.println(up.divide(temp)+"/"+down.divide(temp));
}
}
cin.close();
}
}
以下是代码(旧):
import java.math.BigInteger;
import java.util.Scanner; public class Main {
static BigInteger [][] c = new BigInteger[110][110];
public static void del() {
for(int i = 0; i <= 105; i ++)
c[i][0] = c[i][i] = BigInteger.ONE;
for(int i = 1; i <= 105; i ++)
{
for(int j = 1; j < i; j ++)
c[i][j] = (c[i-1][j-1] .add(c[i-1][j]));
}
}
public static BigInteger gcd(BigInteger a ,BigInteger b) {
if(a .compareTo(b)<0)
return gcd(b,a);
if(a .mod(b).compareTo(BigInteger.ZERO)== 0)
return b;
return gcd(b, a.mod(b));
}
public static BigInteger pow(BigInteger a ,int b) {
BigInteger ans = BigInteger.ONE;
for(int i=1;i<=b;i++)
{
ans=ans.multiply(a);
}
return ans;
}
public static void main(String[] args) {
Scanner cin = new Scanner(System.in);
int d;
BigInteger n=BigInteger.ZERO,up=BigInteger.ZERO,down=BigInteger.ZERO,temp=BigInteger.ZERO;
del();
while(cin.hasNext())
{
n=cin.nextBigInteger();
d=cin.nextInt();
up=c[d][2].multiply(pow(n.add(BigInteger.valueOf(4)),2));
down=BigInteger.valueOf(9).multiply(pow(n, d));
if(up.compareTo(down)==0)
{
System.out.println(1);
}
else {
temp=gcd(up, down);
System.out.println(up.divide(temp)+"/"+down.divide(temp));
}
}
cin.close();
}
}
版权声明:本文博客原创文章。博客,未经同意,不得转载。
【2014 Multi-University Training Contest 2 1002】/【HDU 4873】 ZCC Loves Intersection的更多相关文章
- 2018 Multi-University Training Contest 1 Distinct Values 【贪心 + set】
任意门:http://acm.hdu.edu.cn/showproblem.php?pid=6301 Distinct Values Time Limit: 4000/2000 MS (Java/Ot ...
- HDU 2018 Multi-University Training Contest 1 Triangle Partition 【YY】
传送门:http://acm.hdu.edu.cn/showproblem.php?pid=6300 Triangle Partition Time Limit: 2000/1000 MS (Java ...
- HDU 6351.Beautiful Now-暴力、全排列、思维 (2018 Multi-University Training Contest 5 1002)
2018 Multi-University Training Contest 5 6351.Beautiful Now 题意就是交换任意两个数字,问你交换k次之后的最小值和最大值. 官方题解: 哇塞, ...
- HDU 6333.Problem B. Harvest of Apples-组合数C(n,0)到C(n,m)求和-组合数学(逆元)+莫队 ((2018 Multi-University Training Contest 4 1002))
2018 Multi-University Training Contest 4 6333.Problem B. Harvest of Apples 题意很好懂,就是组合数求和. 官方题解: 我来叨叨 ...
- 【HDU 2014 Multi-University Training Contest 1 1002】/【HDU 4862】Jump
多校训练就这么华丽丽的到了 ,于是乎各种华丽丽的被虐也開始了. 这是多校的1002; 最小费用最大流. 题目大意: 有n*m个方格,每一个方格都一个的十进制一位的数.你能够操作K次. 对于每一次操作, ...
- 【2014 Multi-University Training Contest 3 1002】/【HDU 4888】 Redraw Beautiful Drawings
不easy啊.最终能够补第二个题了.! 顺便说一句:模版写残了就不要怪出题人啊 ~ (这残废模版研究了好长时间才找出错) 题目大意: 有一个n*m的矩阵.每个格子里都将有一个数.给你每一行数字之和和每 ...
- 2015 Multi-University Training Contest 2 1002 Buildings
Buildings Problem's Link: http://acm.hdu.edu.cn/showproblem.php?pid=5301 Mean: n*m列的网格,删除一个格子x,y,用矩形 ...
- 2015 Multi-University Training Contest 1 - 1002 Assignment
Assignment Problem's Link: http://acm.hdu.edu.cn/showproblem.php?pid=5289 Mean: 给你一个数列和一个k,求连续区间的极值之 ...
- hdu6351 2018 Multi-University Training Contest 5 1002 Beautiful Now
题意: 给出一个十进制数,数位两两可以交换,给出最多能交换多少次,以及交换后的数不能有前缀0,问能形成最小和最大的数 * * * 尝试的思路 贪心,将字符串先排出最大以及最小的情况,然后按一定顺序将对 ...
随机推荐
- QT Programming 1
1.控制台输出 helloworld #include<QtCore/QCoreApplication> #include<QDebug> int main(int argc, ...
- shell编程三大神器之awk
- [网络]_[0基础]_[使用putty备份远程数据]
场景: 1. putty是windows上訪问linux服务的免费client之中的一个.用它来ssh到远程server备份数据是常见的做法(在没做好自己主动备份机制前), 通过putty界面尽管也不 ...
- Eclipse 打JAR包,插件FatJar 安装与使用
下载fatJar插件,解压缩后是一个.../plugins/(net...)把plugins下面的(net..)文件夹拷贝到eclipse的plugins下,重新启动Eclipse3.1,Window ...
- 自己实现的Boost库中的lexical_cast随意类型转换
知道了C++的I/O设施之后.这些就变的非常easy了. 假设你常常使用,时间长了就会有感觉.这个事情是多此一举吗?就当是练习吧,知道原理之后,你会认为用起来更舒畅,更喜欢C++了. #include ...
- Android从无知到有知——NO.7
的ip拨号器在监听外拨电话时用的是系统提供的广播事件.而有些时候我们须要自己设定广播事件来满足特定的须要. Ok,今天整一下自己定义广播事件,我们用一个状态监測模块向一个3G模块发送报警信息来实现这一 ...
- SharePoint综合Excel数据与Excel Web Access Web部分
SharePoint综合Excel数据与Excel Web Access Web部分 Excel Web Access Web零件SharePoint于Excel以电子形式提交数据. 1. 打开Exc ...
- hdu3530Subsequence rmq
//使用rmq办,ma[i][j],同i作为一个起点2^j阵列的最大长度值 //启动枚举问最长的子列 //枚举的最大长度2^(j-1)和2^(j)z之间 //然后在该范围内找到 #include< ...
- 【原创】ZOJ_1649 Rescue 解题报告
Rescue Time Limit: 2 Seconds Memory Limit: 65536 KB Angel was caught by the MOLIGPY! He was put ...
- 【LeetCode】Triangle 解决报告
[称号] Given a triangle, find the minimum path sum from top to bottom. Each step you may move to adjac ...