HDU 4762 Cut the Cake (高精度 + 公式)
2015-09-09 19:23
393 查看
可得公式: n / (m^(n-1))
import java.io.*; import java.math.*; import java.util.*; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int t = sc.nextInt(); for (int i = 0; i < t; ++i) { int m = sc.nextInt(); int n = sc.nextInt(); BigInteger s = BigInteger.valueOf(n); BigInteger a = BigInteger.valueOf(m).pow(n - 1); BigInteger g = a.gcd(s); //System.out.println(g); System.out.println(s.divide(g) + "/" + a.divide(g)); } } }
相关文章推荐
- 我很愚蠢
- Linux命令之write调用的原子性
- cocos2dx中的坐标系和锚点
- hdu1166敌兵布阵(线段树模板)
- 简单举例说明C++中break和continue语句的用法
- 指数循环节
- 监听套接字 连接套接字
- 图片按钮ImageButton
- 饿了么面试
- 每一个程序员需要了解的10个Linux命令
- 基于centos7最小化安装的openstack环境搭建(1)
- 文章索引-跨平台开发
- 三层架构
- Objective-C 【protocol 的引用问题】
- UIAlertController
- POJ 3264 Balanced Lineup(RMQ)
- ios-音乐播放器(2)工具类的封装
- gulp打包seajs,用gulp-cmd-pack打包seajs模块
- iOS开发之 字典和可变字典初解
- Linux初学笔记