传送门:点我

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 mnk are written in one line. 0 < mn ≤ 1000 ≤ k ≤ 1000.

Output

Print k digits after the decimal point of the given number.

Time limit 1 second
Memory limit 64 MiB
Input example #1
1 2 3
Output example #1
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的更多相关文章

  1. caffe的python接口学习(7):绘制loss和accuracy曲线

    使用python接口来运行caffe程序,主要的原因是python非常容易可视化.所以不推荐大家在命令行下面运行python程序.如果非要在命令行下面运行,还不如直接用 c++算了. 推荐使用jupy ...

  2. caffe中accuracy和loss用python从log日志里面获取

    import re import pylab as pl import numpy as np if __name__=="__main__": accuracys=[] loss ...

  3. PR曲线,ROC曲线,AUC指标等,Accuracy vs Precision

    作为机器学习重要的评价指标,标题中的三个内容,在下面读书笔记里面都有讲: http://www.cnblogs.com/charlesblc/p/6188562.html 但是讲的不细,不太懂.今天又 ...

  4. OpenCV Template Matching Subpixel Accuracy

    OpenCV has function matchTemplate to easily do the template matching. But its accuracy can only reac ...

  5. 准确率(Accuracy), 精确率(Precision), 召回率(Recall)和F1-Measure

    yu Code 15 Comments  机器学习(ML),自然语言处理(NLP),信息检索(IR)等领域,评估(Evaluation)是一个必要的 工作,而其评价指标往往有如下几点:准确率(Accu ...

  6. Cross-Entropy Loss 与Accuracy的数值关系

    以分类任务为例, 假设要将样本分为\(n\)个类别. 先考虑单个样本\((X, z)\). 将标题\(z\)转化为一个\(n\)维列向量\(y = (y_1, \dots y_k, \dots, y_ ...

  7. 加州大学伯克利分校Stat2.2x Probability 概率初步学习笔记: Section 5 The accuracy of simple random samples

    Stat2.2x Probability(概率)课程由加州大学伯克利分校(University of California, Berkeley)于2014年在edX平台讲授. PDF笔记下载(Acad ...

  8. 分类指标准确率(Precision)和正确率(Accuracy)的区别

    http://www.cnblogs.com/fengfenggirl/p/classification_evaluate.html 一.引言 分类算法有很多,不同分类算法又用很多不同的变种.不同的分 ...

  9. {Reship}Precision, Accuracy & Recall

    ============================================================== This aritcle came from here ========= ...

随机推荐

  1. oracle登陆认证方式

    转自:http://blog.itpub.net/14359/viewspace-683064/ 案例: 1,发现此时操作系统认证不成功: C:\Users\Administrator.WIN-201 ...

  2. php计算程序运行时间

    这里介绍一下 microtime() 这个函数,microtime() 用的不多,但是不能不知道这个函数,它是返回当前 Unix 时间戳和微秒数.例如:echo microtime(); 会返回:0. ...

  3. 微信小程序插件 - 开发教程

    昨天(2018.3.13),微信小程序发布了重大功能更新,支持插件的使用和开发,个人预计,不超过2个月,优质服务的插件将会如雨后春笋般涌现. 这篇文章,我将会带大家,从0开始,学习如何开发和使用插件. ...

  4. centos7 操作记录

    centos7 firewall 命令查看已经开放的端口firewall-cmd --list-ports查看开放的服务firewall-cmd --list-services开启端口firewall ...

  5. 继承标签extend

    写页面的时候,整体框架是相同的,只有content区是不同的,所以就有了继承的概念: 在content 里面加一个 {%block content%} {% endblock %} 其他框架的继承: ...

  6. get return value of python in shell

    from: https://stackoverflow.com/questions/2115615/assigning-value-to-shell-variable-using-a-function ...

  7. Linux:结束线程的三种方式

    一般情况下,线程终止后,其终止状态一直保留到其它线程调用pthread_join获取它的状态为止.但是线程也可以被置为detach状态,这样的线程一旦终止就立刻回收它占用的所有资源,而不保留终止状态. ...

  8. PDF文档的目录编辑与显示

    为了更好的保护PDF文件,可以将其转换为图片的格式,再重新排版编辑. 使用压缩率更高的JPEG 2000图片格式更佳. ---------------------------------------- ...

  9. Kotlin语言学习笔记(3)

    数据类(Data Classes) data class User(val name: String, val age: Int) 编译器自动生成的有: equals()/hashCode() toS ...

  10. Window环境下Python和Django的安装,以及项目的创建

    1.首先我们要下载python和Django,他们的下载地址如下 python地址:https://www.python.org/ Django地址:  https://www.djangoproje ...