Codeforces Round #362 (Div. 2) B 模擬
連結:戳這裡
B. Barnicle
time limit per test1 second
memory limit per test256 megabytes
inputstandard input
outputstandard output
Barney is standing in a bar and starring at a pretty girl. He wants to shoot her with his heart arrow but he needs to know the distance between him and the girl to make his shot accurate.![](https://i.iter01.com/images/093082340f104fd0198e69b455e561636e0f1ce8f0c84c51751468c3d7ca407c.png)
Barney doesn't know anything about scientific notation (as well as anything scientific at all). So he asked you to tell him the distance value in usual decimal representation with minimal number of digits after the decimal point (and no decimal point if it is an integer). See the output format for better understanding.
Input
The first and only line of input contains a single string of form a.deb where a, d and b are integers and e is usual character 'e' (0 ≤ a ≤ 9, 0 ≤ d < 10100, 0 ≤ b ≤ 100) — the scientific notation of the desired distance value.
a and b contain no leading zeros and d contains no trailing zeros (but may be equal to 0). Also, b can not be non-zero if a is zero.
Output
Print the only real number x (the desired distance value) in the only line in its decimal notation.
Thus if x is an integer, print it's integer value without decimal part and decimal point and without leading zeroes.
Otherwise print x in a form of p.q such that p is an integer that have no leading zeroes (but may be equal to zero), and q is an integer that have no trailing zeroes (and may not be equal to zero).
Examples
input
8.549e2
output
854.9
input
8.549e3
output
8549
input
0.33e0
output
0.33
題意:
給出一個科學計數法表示的數,輸出十進位制下的數
思路:
有一個坑點就是 a.0e0 答案是a
程式碼:
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<string>
#include<vector>
#include <ctime>
#include<queue>
#include<set>
#include<map>
#include<stack>
#include<iomanip>
#include<cmath>
#define mst(ss,b) memset((ss),(b),sizeof(ss))
#define maxn 0x3f3f3f3f
#define MAX 1000100
///#pragma comment(linker, "/STACK:102400000,102400000")
typedef long long ll;
typedef unsigned long long ull;
#define INF (1ll<<60)-1
using namespace std;
string s;
char p[10010];
int main(){
cin>>s;
int a=s[0]-'0';
int t=2,cnt=0;
while(s[t]!='e') {
p[cnt++]=s[t];
t++;
}
t=s.size()-1;
int b=0,x=1;
while(s[t]!='e'){
b=b+(s[t]-'0')*x;
t--;
x*=10;
}
cout<<a;
if(b==0){
if(cnt==1 && p[0]=='0') return 0;
cout<<".";
for(int i=0;i<cnt;i++) cout<<p[i];
cout<<endl;
return 0;
}
t=0;
int i;
for(i=0;i<b && t<cnt;i++){
cout<<p[i];
t++;
}
if(i==b && t==cnt) return 0;
if(t<cnt){
cout<<".";
for(i=t;i<cnt;i++) cout<<p[i];
return 0;
}
if(i<b){
while(i<b){
cout<<0;
i++;
}
return 0;
}
return 0;
}
相關文章
- Codeforces Round 977 (Div. 2)(B-C2)
- Codeforces Round #491 (Div. 2) B. Getting an A
- codeforces Round #681 (Div. 2) 1443B Saving the City
- Codeforces Round #676 (Div. 2) B. Putting Bricks in the Wall
- Codeforces Round 976 (Div. 2) and Divide By Zero 9.0(A,B,C)IDE
- Codeforces Round #541 (Div. 2)
- Codeforces Round 940 (Div. 2)
- Codeforces Round 934 (Div. 2)
- Codeforces Round 932 (Div. 2)
- Codeforces Round 948 (Div. 2)
- Codeforces Round #639 (Div. 2)
- Codeforces Round #672 (Div. 2)
- Codeforces Round #682 (Div. 2)
- Codeforces Round #678 (Div. 2)
- Codeforces Round #673 (Div. 2)
- Codeforces Round 987 (Div. 2)
- Codeforces Round 976 (Div. 2)
- Codeforces Round 975 (Div. 2)
- Codeforces Round 986 (Div. 2)
- Codeforces Round 973 (Div. 2)
- Codeforces Round 969 (Div. 2)
- Codeforces Round 873 (Div. 2)
- Codeforces Round 967 (Div. 2)
- Codeforces Round 965 (Div. 2)
- Codeforces Round 963 (Div. 2)
- Codeforces Round 979 (Div. 2)
- Codeforces Round 972 (Div. 2)
- Codeforces Round 949 (Div. 2)
- Codeforces Round 955 (Div. 2)
- Codeforces Round 951 (Div. 2)
- Codeforces Round 961 (Div. 2)
- Codeforces Round 958 (Div. 2)
- Codeforces Round 960 (Div. 2)
- Codeforces Round 953 (Div. 2)
- Codeforces Round 982 (Div. 2)
- Codeforces Round 945 (Div. 2)
- Codeforces Round #747 (Div. 2)
- 【Codeforces Round #499 (Div. 1) B】Rocket
- Codeforces Round 975 (Div. 2)題解記錄(A,B,E)