Codeforces Round #362 (Div. 2) B. Barnicle
来源:互联网 发布:丽得姿黑面膜淘宝 编辑:程序博客网 时间:2024/04/30 10:37
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.
Barney asked the bar tender Carl about this distance value, but Carl was so busy talking to the customers so he wrote the distance value (it's a real number) on a napkin. The problem is that he wrote it in scientific notation. The scientific notation of some real number x is the notation of form AeB, where A is a real number and B is an integer and x = A × 10B is true. In our case A is between 0 and 9 and B is non-negative.
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.
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.
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).
8.549e2
854.9
8.549e3
8549
0.33e0
0.33
#include <bits/stdc++.h>using namespace std;int main(){ //freopen("cin.txt","r",stdin); char z[1005]; int n,i,dian,e,a,h=0; dian=-1; i=0; cin>>z; n=strlen(z); for(a=0;n>a;a++){ if(z[a]=='e'){ if(i==0){ cout<<"0"<<endl; return 0; } break; } if(z[a]!='0'&&z[a]!='.'){ i=1; } } for(a=0;n>a;a++){ if(z[a]=='.') dian=a; if(z[a]=='e') e=a; } if(n-e==4){ i=z[e+3]-'0'; i+=(z[e+2]-'0')*10; i+=(z[e+1]-'0')*100; } else if(n-e==3){ i=z[e+2]-'0'; i+=(z[e+1]-'0')*10; } else if(n-e==2) i=z[e+1]-'0'; int flag=1,flag2=1,flag3=1; dian+=i; //cout<<i<<endl; for(a=0;n>a;a++){ if(z[a]=='e') break; if((z[a]=='.'||z[a]=='0')&&a<dian&&flag){ continue; } if(z[a]!='.'&&flag3){ flag=0; cout<<z[a]; flag2=0; } if(flag2&&flag3){ cout<<"0"; } if(a==dian&&a<e-1){ flag3=0; } if(z[a]!='.'&&!flag3&&z[a]!='0'){ h=a; } } for(a=dian;h>=a;a++){ if(a==dian&&a!=h){ cout<<"."; continue; } cout<<z[a]; } while(dian-->=e) cout<<"0"; cout<<endl;return 0;}
- Codeforces Round #362 (Div. 2) B. Barnicle
- Codeforces Round 362 Div.2 B Barnicle
- Codeforces Round #362 (Div. 2) B. Barnicle
- Codeforces Round #362 (Div. 2) B. Barnicle
- Codeforces Round #362 (Div. 2) B. Barnicle(乱搞)
- Codeforces Round #362 (Div. 2)->B. Barnicle(模拟)
- 【Codeforces Round 362 (Div 2)B】【模拟】Barnicle 科学计数法转普通表示法
- Codeforces Round #362 (Div. 2) B. Barnicle 科学记数法、表达式处理
- codeforces #362(div.2)B. Barnicle【模拟】
- Codeforces - 362 (Div. 2)B - Barnicle(模拟)
- Codeforces Round #362 (Div. 2)B. Barnicle(较坑模拟【菜鸡与大佬的区别】)
- Codeforces Round #362 (Div. 2) A,B
- Codeforces Round #362 (Div. 2) B 模拟
- Codeforces-697B Barnicle
- Codeforces 697B Barnicle
- CodeForces 697B Barnicle
- Codeforces Round #362 (Div. 1) B Puzzles
- Codeforces Round #131 (Div. 2) A B
- Codeforces Gym 100513
- objective-C日期相关操作
- Maven学习(四)-- 生命周期和插件
- .9图片制作
- 支持多屏幕
- Codeforces Round #362 (Div. 2) B. Barnicle
- 2016微软技术大会 汇聚最前沿科技
- Android之自定义View实现随手势滑动的小圆球
- 台阶走法
- JNDI 在 J2EE 中的角色
- 基于珠海鼎芯IMX6在eglfs平台下Qt5触摸屏问题
- Android笔记:登录显示与隐藏密码
- 第八周拓展实践1小明借书
- adb server version (31) doesn't match this client (36);解决