Time limit: 1 s space limit: 128000 KB title level: Silver
Title Description Description
Give you a real number, no more than 50 digits after the decimal point, please keep to the decimal point after n bit (rounding!!!) )
Enter a description input Description
First line, a real number, no more than 50 digits after the decimal point
Second row, reserved to n decimal places
outputs description output Description
A real number, a fractional number that has been retained
sample input to sample
5.198273258723587235728
3
Sample output Sample outputs
5.198
data size & Hint
Not too big, just pay attention, remember it's rounding up
Portal Point This expansion
This problem is very simple, issued just to take a bubble, prove that I still continue to walk this road.
Maybe it's been kicked out in years.
#include <iostream>#include<cstring>#include<cstdio>using namespacestd;Chars[14451245];intI,n;intMain () {intC=0; Gets (s); CIN>>N; for(i=0; I<strlen (s); + +i) {if(s[i]=='.') {C=i; Break; } } if(s[c+n+1]>='5'&&s[c+n+1]<='9') S[c+n]++; intk=0; while(s[c+n-k]>'9') {S[c+n]='0'; S[c+n-1]++; K++; } for(i=0; i<c+n+1;++i) cout<<s[i];}
View Code
Codevs 2894 reserved Decimals