2010-2011 ACM-ICPC, NEERC, Moscow Subregional Contest Problem J. Joke 水题
Problem J. Joke
题目连接:
http://codeforces.com/gym/100714
Description
The problem is to cut the largest possible number of circles with diameter y out of a stripe of length x
and width y.
Input
The only line of input consists of two positive real numbers x and y with 9-digit precision separated by
spaces. The integers may be written without decimal point.
Output
Output a single integer — the maximum number of circles one can cut out of the stripe.
Sample Input
6.3 0.9
Sample Output
7
Hint
题意
给你两个数,问你A/B是多少,保证小数点后9为小数以内。
题解:
乘以1e9,然后再除就好了
代码
import java.io.*;
import java.math.*;
import java.util.*;
public class Main
{
public static void main(String argv[]) throws Exception
{
Scanner cin = new Scanner(System.in);
String x = cin.next() , y = cin.next();
{
int find = 0;
for(int i = 0 ; i < x.length() ; ++ i) if( x.charAt(i) =='.' ) find = 1;
if( find == 0 ) x += '.';
}
{
int find = 0;
for(int i = 0 ; i < y.length() ; ++ i) if( y.charAt(i) =='.' ) find = 1;
if( find == 0 ) y += '.';
}
int m1 = 0 , m2 = 0;
{
int find = 0;
for(int i = 0 ; i < x.length() ; ++ i){
if( x.charAt(i) == '.' ) find = 1;
else if( find == 1 ) ++ m1;
}
}
{
int find = 0;
for(int i = 0 ; i < y.length() ; ++ i){
if( y.charAt(i) == '.' ) find = 1;
else if( find == 1 ) ++ m2;
}
}
int ms = Math.max( m1 , m2 );
for(int i = m1 ; i < ms ; ++ i) x+='0';
for(int i = m2 ; i < ms ; ++ i) y+='0';
BigInteger A = BigInteger.ZERO , B = BigInteger.ZERO;
for(int i = 0 ; i < x.length() ; ++ i){
if( x.charAt(i) != '.' ){
int add = x.charAt(i) - '0';
A = A.multiply( BigInteger.valueOf(10) );
A = A.add( BigInteger.valueOf(add) );
}
}
for(int i = 0 ; i < y.length() ; ++ i){
if( y.charAt(i) != '.' ){
int add = y.charAt(i) - '0';
B = B.multiply( BigInteger.valueOf(10) );
B = B.add( BigInteger.valueOf(add) );
}
}
System.out.println( A.divide(B) );
}
}
2010-2011 ACM-ICPC, NEERC, Moscow Subregional Contest Problem J. Joke 水题的更多相关文章
- 2010-2011 ACM-ICPC, NEERC, Moscow Subregional Contest Problem H. Hometask 水题
Problem H. Hometask 题目连接: http://codeforces.com/gym/100714 Description Kolya is still trying to pass ...
- 2010-2011 ACM-ICPC, NEERC, Moscow Subregional Contest Problem F. Finance 模拟题
Problem F. Finance 题目连接: http://codeforces.com/gym/100714 Description The Big Boss Company (BBC) pri ...
- ACM ICPC 2016–2017, NEERC, Northern Subregional Contest Problem J. Java2016
题目来源:http://codeforces.com/group/aUVPeyEnI2/contest/229510 时间限制:2s 空间限制:256MB 题目大意: 给定一个数字c 用 " ...
- 2010-2011 ACM-ICPC, NEERC, Moscow Subregional Contest Problem D. Distance 迪杰斯特拉
Problem D. Distance 题目连接: http://codeforces.com/gym/100714 Description In a large city a cellular ne ...
- 2010-2011 ACM-ICPC, NEERC, Moscow Subregional Contest Problem C. Contest 水题
Problem C. Contest 题目连接: http://codeforces.com/gym/100714 Description The second round of the annual ...
- 2016-2017 ACM-ICPC, NEERC, Moscow Subregional Contest Problem L. Lazy Coordinator
题目来源:http://codeforces.com/group/aUVPeyEnI2/contest/229511 时间限制:1s 空间限制:512MB 题目大意: 给定一个n 随后跟着2n行输入 ...
- 2010-2011 ACM-ICPC, NEERC, Moscow Subregional Contest Problem K. KMC Attacks 交互题 暴力
Problem K. KMC Attacks 题目连接: http://codeforces.com/gym/100714 Description Warrant VI is a remote pla ...
- 2010-2011 ACM-ICPC, NEERC, Moscow Subregional Contest Problem I. Interest Targeting 模拟题
Problem I. Interest Targeting 题目连接: http://codeforces.com/gym/100714 Description A unique display ad ...
- 2010-2011 ACM-ICPC, NEERC, Moscow Subregional Contest Problem A. Alien Visit 计算几何
Problem A. Alien Visit 题目连接: http://codeforces.com/gym/100714 Description Witness: "First, I sa ...
随机推荐
- CSS规范 - 命名规则--(来自网易)
使用类选择器,放弃ID选择器 ID在一个页面中的唯一性导致了如果以ID为选择器来写CSS,就无法重用. NEC特殊字符:"-"连字符 "-"在本规范中并不表示连 ...
- Tensorflow数据读取的方式
深度学习既然是基于数据的方法,先不管多抽象,那总归是有读取数据的方法的吧,这里的数据应该是一个统称,包含我们讲的数据集和变量tensor. tf读取数据一共有3种方法: 供给数据(Feeding): ...
- networkManger介绍
http://www.linuxidc.com/Linux/2013-08/88809.htm
- Robotium_断言方法assert、is、search
下面的这些方法都主要用来判断测试结果是否与预期结果相符,一般把is和search方法放在assert里面判断.assert最常用的还是assertThat方法,是Junit的判断,这里就不多说了.断言 ...
- CentOS7上安装与配置Tomcat8与MySQL5.7
一.安装tomcat Tomcat 的安装依赖 JDK,在安装 Tomcat 之前需要先安装 Java JDK.输入命令 java -version,如果显示 JDK 版本,证明已经安装了 JDK.
- webapck编译打包stylus文件
先安装css-loader.stylus.stylus-loader npm install --save-dev css-loader npm install --save-dev stylus n ...
- PhpStorm,Pycharm,Goland破解
phpstorm是一个轻量级且便捷的PHP IDE,其旨在提供用户效率,可深刻理解用户的编码,提供智能代码补全,快速导航以及即时错误检查.不但是php开发的利器,前端开发也是毫不逊色的.下面记录Php ...
- JavaScript:document.execCommand()的用法
document.execCommand()的用法小记 一.语法 execCommand方法是执行一个对当前文档,当前选择或者给出范围的命令.处理Html数据时常用. 如下格式:document.ex ...
- LeetCode(16):最接近的三数之和
Medium! 题目描述: 给定一个包括 n 个整数的数组 nums 和 一个目标值 target.找出 nums 中的三个整数,使得它们的和与 target 最接近.返回这三个数的和.假定每组输入只 ...
- 使用BigDecimal转换较长小数时候出现科学计数法的问题
public static String divToString(double v1, double v2, int scale){ if (scale < 0) { throw new Ill ...