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 ...
随机推荐
- bzoj千题计划191:bzoj2337: [HNOI2011]XOR和路径
http://www.lydsy.com/JudgeOnline/problem.php?id=2337 概率不能异或 但根据期望的线性,可以计算出每一位为1的概率,再累积他们的期望 枚举每一位i,现 ...
- ngx_lua_API 指令详解(四)ngx.exec指令
https://github.com/openresty/lua-nginx-module#ngxexec 参照:http://blog.csdn.net/weiyuefei/article/deta ...
- 进程ID[PID(Process ID)]与端口号[(Port ID)]的联系
1.首先声明一点:PID不是端口(port id),而是Process ID进程号的意思. 2.那么,什么是进程号? 采集网友的意见就是: 进程号,是系统分配给么一个进程的唯一标识符.PID就是各进程 ...
- 1、Saltstack简介及安装配置
1.Saltstack简介 Saltstack是基于Python开发的一套C/S架构,具备Puppet.Ansible功能于一身的配置管理工具,功能十分强大,各模块融合度及复用性极高:使用号称世界上最 ...
- JQuery效果隐藏/显示
hide() 方法 语法 $(selector).hide(speed,callback) show() 方法 语法 $(selector).show(speed,callback) 参数 描述 sp ...
- linux sftp安装【转】
工具:虚拟机:VMware Workstation Pro.操作系统:CentOS-6.4-x86_64-minimal.终端模拟器:Xshell 5 .ftp:filezilla 一.让虚拟机联网 ...
- pop3设置
- WPF的EventAggregator的发布和订阅
EventAggregator是Prism中专门处理ViewModel与ViewModel之间事件传递的类对象,它提供了针对事件的发布方法和订阅方法,所以可以非常方便的来管理事件.下面分几步来实现相关 ...
- 如何动态修改windows下的host文件
事件背景:为了测试数据提交后,需要在另一个环境的多个测试节点下去验证测试数据是否添加成功,找了一大堆放法,用了比较笨的方法实现了.不多废话思路如下: 为了万无一失,先备份hosts文件内容: 1.读取 ...
- 小白学习安全测试(一)——Http协议基础
Http协议基础 Web技术发展[http://www.cnblogs.com/ProgrammerGE/articles/1824657.html] 静态WEB[网页] 动态WEB 属于一种应用程序 ...