Codeforces697B Barnicle 模拟
来源:互联网 发布:java 字符串排序函数 编辑:程序博客网 时间:2024/06/16 12:38
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, whereA 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 Bis 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 eis 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 <iostream>#include <cstdio>#include <map>#include <cmath>#include <algorithm>#include <cstring>#include <string>using namespace std;#define LL long long#define maxn 1000100char b[505];void f(int p,int q){ int flag=1; for(int m=p;m<q;m++){ if(b[m]!='0'){ flag=0; } if(flag!=1||b[m]!='0'){ printf("%c",b[m]); } }}void fff(int p,int q){ for(int m=p;m<q;m++){ printf("%c",b[m]); }}void ff(int n){ while(n--){ printf("0"); }}void change(char *a){ char c[200]; char p; int l=strlen(a); p=a[0]; int j=2; while(a[j]!='e'){ b[j-2]=a[j]; j++; } int ss=j-2; j++; int k=0; while(j<l){ c[k++]=a[j]; j++; } int t=0; int temp=1; for(int s=k-1;s>=0;s--){ t+=temp*(c[s]-'0'); temp*=10; } if(p=='0'){ if(ss==1&&b[0]=='0'){ printf("0\n"); }else{ if(t<ss){ int flag=1,fa=1; for(int m=0;m<t;m++){ if(b[m]!='0'){ flag=0; } if(flag!=1||b[m]!='0'){ printf("%c",b[m]); fa=0; } } if(fa==1) printf("0"); printf("."); fff(t,ss); printf("\n"); }else{ f(0,ss); ff(t-ss); printf("\n"); } } }else{ printf("%c",p); if(ss==1&&b[0]=='0'&&t==0){ printf("\n"); }else{ if(t<ss){ fff(0,t); printf("."); fff(t,ss); printf("\n"); }else{ fff(0,ss); ff(t-ss); printf("\n"); } } }}int main(){ char a[505]; while(~scanf("%s",a)){ change(a); memset(a,0,sizeof(a)); memset(b,0,sizeof(b)); } return 0;}
- Codeforces697B Barnicle 模拟
- Codeforces-697B Barnicle(模拟)
- Barnicle
- Barnicle
- Barnicle
- Codeforces-697B-Barnicle(模拟)
- Codeforces 697B. Barnicle(模拟)
- CodeForces 697 B. Barnicle(简单模拟)
- codeforces #362(div.2)B. Barnicle【模拟】
- Codeforces Round #362 (Div. 2)->B. Barnicle(模拟)
- Codeforces - 362 (Div. 2)B - Barnicle(模拟)
- 【Codeforces Round 362 (Div 2)B】【模拟】Barnicle 科学计数法转普通表示法
- Codeforces---Barnicle
- Codeforces Round #362 (Div. 2)B. Barnicle(较坑模拟【菜鸡与大佬的区别】)
- Codeforces-697B Barnicle
- Codeforces 697B Barnicle
- CodeForces 697B Barnicle
- codeforce 697B Barnicle
- Looper、MessageQueue、Handler三者关系理解
- 安卓字体渲染器
- CodeBlocks主程序添加头文件失败解决方法
- mysql的备份
- 设置Android app的字体不随系统全局字体大小的变动而变动
- Codeforces697B Barnicle 模拟
- Gym 100735 - I. Yet another A + B
- 线程同步——互斥量
- mac快捷键
- 导出excel 02
- Android设置中“强行停止”详解
- log 4j配置文件log4j.properties
- 关于爱拍(拍视频)
- scipy module 1 -- Scipy Tutorial 5 Statistics