Codeforces Round #362 (Div. 2) B. Barnicle(乱搞)
来源:互联网 发布:数据库订单管理模板 编辑:程序博客网 时间:2024/05/07 22:55
题目l链接:点这里!!!!
题意:
输入一个字符串类似于:a.deb(0<=a<=9,0<=d<=1e100,0<=b<=100,a=0时b=0,d没有后缀零),叫你转换成正常的表达方式,且没有多余的字符。
比如:8.0123e3 ->8012.3
题解:
1、这道题很多人WA了终测,我也WA了- -,还好hack别人把分都捡回来了。
2、这道题说白了就是小数点往后移的问题,如果是整数了就删除小数点,在后面补零就是了。
3、当然你要特判一下,a.0e0这种情况,这种情况输出a就可以了。
代码:
#include<cstdio>#include<cstring>#include<iostream>#include<sstream>#include<algorithm>#include<vector>#include<bitset>#include<set>#include<queue>#include<stack>#include<map>#include<cstdlib>#include<cmath>#define LL long long#define pb push_back#define pa pair<int,int>#define clr(a,b) memset(a,b,sizeof(a))#define lson lr<<1,l,mid#define rson lr<<1|1,mid+1,r#define bug(x) printf("%d++++++++++++++++++++%d\n",x,x)#define key_value ch[ch[root][1]][0]#pragma comment(linker, "/STACK:102400000000,102400000000")const LL MOD = 1000000007;const int N = 1e5+15;const int maxn = 1e5+15;const int letter = 130;const LL INF = 1e7;const double pi=acos(-1.0);const double eps=1e-10;using namespace std;inline int read(){ int x=0,f=1;char ch=getchar(); while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();} while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();} return x*f;}char s[N],d[N],ans[N];int b;int main(){ scanf("%s",s); int n=strlen(s); int lend=0,lenb; int flag=0; for(int i=0;;i++){ if(s[i]=='e') {flag=i;break;} if(i!=1)d[lend++]=s[i]; } d[lend]='\0'; flag++; for(int i=flag;i<n;i++) b=b*10+s[i]-'0'; if(d[1]=='0'&&lend==2&&b==0) { printf("%c\n",s[0]); return 0; } if(b<lend-1){ int flag=0; for(int i=0;i<lend;i++){ if(b==i){ flag=1; printf("%c.",d[i]); } else if(d[i]!='0') {printf("%c",d[i]);flag=1;} else if(flag) printf("0"); } puts(""); } else { int flag=0; for(int i=0;i<lend;i++){ if(d[i]!='0') printf("%c",d[i]),flag=1; else if(flag) printf("0"); } for(int i=0;i<b-lend+1;i++) printf("0"); puts(""); } return 0;}/*2.0e00.0e0*/
0 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 #256 (Div. 2) B. Suffix Structures (乱搞)
- Codeforces Round #362 (Div. 2)B. Barnicle(较坑模拟【菜鸡与大佬的区别】)
- Codeforces Round #337 (Div. 2) B. Vika and Squares (技巧乱搞)
- Codeforces Round 421 Div.2 D. Mister B and PR Shifts 思维 乱搞
- Codeforces Round #362 (Div. 2) A,B
- Codeforces Round #362 (Div. 2) B 模拟
- Codeforces Round #207 (Div. 2)---C. Knight Tournament(set乱搞)
- Codeforces Round #324 (Div. 2) 数论乱搞过
- php set get asset unset
- POJ 1200
- CocoaPods安装和使用
- Ubuntu14.04安装Samba实现文件共享
- hdu 2191
- Codeforces Round #362 (Div. 2) B. Barnicle(乱搞)
- c++构造和析构能不能抛异常的问题!
- OSG3.5.1 + Qt5.4.2 + VS2010 + CMake3.4.3 安装说明
- SQLyog客户端 导入sql文件乱码的解决方法
- perl 处理文本
- POJ 1915 Knight Moves(BFS)
- android studio 使用常见问题
- mysql写类似 select top x * from
- 基础变换:初识向量/矩阵