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 ========= ...
随机推荐
- node.js 爬虫动态代理ip
参考文章: https://andyliwr.github.io/2017/12/05/nodejs_spider_ip/ https://segmentfault.com/q/10100000081 ...
- RocketMQ服务搭建_1
rocketmq是阿里研发,并贡献给Apache的一款分布式消息中间件. RcoketMQ 是一款低延迟.高可靠.可伸缩.易于使用的消息中间件. ACE环境:(Adapted communicatio ...
- django组件:中间件
全局性的逻辑处理 一.中间件的概念 中间件顾名思义,是介于request与response处理之间的一道处理过程,相对比较轻量级,并且在全局上改变django的输入与输出.因为改变的是全局,所以需要谨 ...
- CSS TYPOGRAPHY
CSS TYPOGRAPHY Review Great job! You learned how to style an important aspect of the user experience ...
- 使用ab对网站进行压力测试
1.安装yum install httpd-tools 2.ab -kc 1000 -n 1000 http://localhost/ab.html 这个指令会使用1000个并发,进行连接1000次
- MOBA项目问题记录
1,动态变化的文本,使用较多时,耗时大,原因:只要字符串发生改变就会重绘,原理:每个字符的宽度不一样 项目中使用了网上写的一个文本控件,大概类型UGUI的东西,实现了字符缓存,绘制过的字符就不会再重建 ...
- LeetCode OJ 47. Permutations II
题目 Given a collection of numbers that might contain duplicates, return all possible unique permutati ...
- 更换Notepad++主题与字体(下载与配置)
本文推荐一款自用主题----tomorrow-theme!其github上有着绝大多数IDE和文本编辑器的这个主题的适配文件.可以在README中先预览一下你要的主题的具体名称.链接:https: ...
- ArcGIS案例学习笔记2_1_山顶点提取最大值提取
ArcGIS案例学习笔记2_1_山顶点提取最大值提取 计划时间:第二天上午 目的:最大值提取 教程:Pdf page=343 数据:chap8/ex5/dem.tif 背景知识:等高线种类 基本等高线 ...
- Javascript中的this之我见
来源:http://www.blogjava.net/baoyaer/articles/105864.html 在面向对象编程语言中,对于this关键字我们是非常熟悉的.比如C++.C#和Java等都 ...