e-olymp Problem11 Big accuracy
传送门:点我
Big accuracy
The rational fraction m/n
is given. Write it in the decimal notation with k
digits after the decimal point.
Input
Three numbers m
, n
, k
are written in one line. 0 < m
, n ≤ 100
, 0 ≤ k ≤ 1000
.
Output
Print k
digits after the decimal point of the given number.
1 2 3
0.500 题意:给你N,M,K,求N/M ,保留K位。
本题有点小坑的地方是,K等于0的时候是取整数部分,保留K位是直接扔掉后面的,不需要四舍五入。
JAVA代码:
import java.text.DecimalFormat;
import java.util.*;
import java.io.*;
import java.math.BigDecimal;
import java.math.BigInteger;
import java.util.Arrays;
import java.util.InputMismatchException; public class Main
{
public static void main (String[] argv)
{
new Main();
}
boolean test = false;
public Main(){
FastReader in = new FastReader(new BufferedReader(new InputStreamReader(System.in)));
//FastReader in = new FastReader(new BufferedReader(new FileReader("Main.in")));
Scanner input = new Scanner(System.in);
BigDecimal x = input.nextBigDecimal();
BigDecimal y = input.nextBigDecimal();
int k = input.nextInt();
if(k == 0){
BigDecimal ans = x.divide(y,1,BigDecimal.ROUND_DOWN);
int answer = ans.intValue();
System.out.println(answer);
}//如果只需要整数部分,就直接取int
else{
BigDecimal ans = x.divide(y,k,BigDecimal.ROUND_DOWN);
System.out.println(ans);
}//保留K位,并且不需要四舍五入
input.close();
}
static class FastReader
{
BufferedReader br;
StringTokenizer st;
public FastReader(BufferedReader in)
{
br = in;
} String next()
{
while (st == null || !st.hasMoreElements())
{
try
{
String line = br.readLine();
if (line == null || line.length() == 0) return "";
st = new StringTokenizer(line);
}
catch (IOException e)
{
return "";
//e.printStackTrace();
}
}
return st.nextToken();
} int nextInt()
{
return Integer.parseInt(next());
} long nextLong()
{
return Long.parseLong(next());
} double nextDouble()
{
return Double.parseDouble(next());
} String nextLine()
{
String str = "";
try
{
str = br.readLine();
}
catch (IOException e)
{
return "";
//e.printStackTrace();
}
return str;
}
}
}
e-olymp Problem11 Big accuracy的更多相关文章
- caffe的python接口学习(7):绘制loss和accuracy曲线
使用python接口来运行caffe程序,主要的原因是python非常容易可视化.所以不推荐大家在命令行下面运行python程序.如果非要在命令行下面运行,还不如直接用 c++算了. 推荐使用jupy ...
- caffe中accuracy和loss用python从log日志里面获取
import re import pylab as pl import numpy as np if __name__=="__main__": accuracys=[] loss ...
- PR曲线,ROC曲线,AUC指标等,Accuracy vs Precision
作为机器学习重要的评价指标,标题中的三个内容,在下面读书笔记里面都有讲: http://www.cnblogs.com/charlesblc/p/6188562.html 但是讲的不细,不太懂.今天又 ...
- OpenCV Template Matching Subpixel Accuracy
OpenCV has function matchTemplate to easily do the template matching. But its accuracy can only reac ...
- 准确率(Accuracy), 精确率(Precision), 召回率(Recall)和F1-Measure
yu Code 15 Comments 机器学习(ML),自然语言处理(NLP),信息检索(IR)等领域,评估(Evaluation)是一个必要的 工作,而其评价指标往往有如下几点:准确率(Accu ...
- Cross-Entropy Loss 与Accuracy的数值关系
以分类任务为例, 假设要将样本分为\(n\)个类别. 先考虑单个样本\((X, z)\). 将标题\(z\)转化为一个\(n\)维列向量\(y = (y_1, \dots y_k, \dots, y_ ...
- 加州大学伯克利分校Stat2.2x Probability 概率初步学习笔记: Section 5 The accuracy of simple random samples
Stat2.2x Probability(概率)课程由加州大学伯克利分校(University of California, Berkeley)于2014年在edX平台讲授. PDF笔记下载(Acad ...
- 分类指标准确率(Precision)和正确率(Accuracy)的区别
http://www.cnblogs.com/fengfenggirl/p/classification_evaluate.html 一.引言 分类算法有很多,不同分类算法又用很多不同的变种.不同的分 ...
- {Reship}Precision, Accuracy & Recall
============================================================== This aritcle came from here ========= ...
随机推荐
- contains 之 点击元素外位置隐藏元素
contains 之 点击元素外位置隐藏元素 api: contains 检测一个元素包含在另一个元素之内 详解:http://www.runoob.com/jquery/misc-contai ...
- enum使用方法
DK1.5引入了新的类型——枚举.在 Java 中它虽然算个“小”功能,却给我的开发带来了“大”方便. 用法一:常量 在JDK1.5 之前,我们定义常量都是: publicstaticfianl... ...
- Redis 配置主从
- Java快速开发平台强大的代码生成器,JEECG 3.7.5 VUE+ElementUI SPA单页面应用版本发布
JEECG 3.7.5 VUE+ElementUI SPA单页面应用版本发布 此版本为Vue+ElementUI SPA单页面应用版本,提供新一代风格代码生成器模板,采用Vue技术,提供两套精美模板E ...
- day07-while,for循环
1.循环语句 Python提供了for循环和while循环while在给定的判断条件为 true 时执行循环体,否则退出循环体.for重复执行语句嵌套循环可以在while循环体中嵌套for.while ...
- js 购物车的实现
购物车原理:创建一个构造函数,把涉及到的项目写成方法,然后把这些方法放到构造函数的原型对象上,通过按钮绑定,调用原型对象上的方法,实现对涉及项目的改变 html代码: <!DOCTYPE htm ...
- git 常用的命令总结
下载gitlab上的代码: git clone ssh://git@47.xx.xx.xx:4xx/xxx.git 查看git代码状态: git status 不提交的代码文件: git checko ...
- How to Pronounce Word vs. World
How to Pronounce Word vs. World Share Tweet Share Tagged With: Comparison, Dark L What is the differ ...
- [重点]delphi删除部分字符串(不区分大小写)
type TDelFlags = set of (dfDelBefore, dfDelAfter); //删除ms字符串中endstr子字符串前面或后面的部分字符串 procedure Delstr( ...
- Hibernate学习笔记3.3(Hibernate组建映射2)
多对多 相当于一个老师可以教多个学生,一个学生也可以有多个老师 数据表中都是再设计一个表寸相关的id 1.多对多单向 1annotation Student.java package com.bjsx ...