Codeforces697B Barnicle 模拟

本文介绍了一个简单的程序设计问题:如何将科学记数法表示的实数转换为标准的小数形式,并提供了具体的实现代码。文章通过示例说明了输入输出的要求,以及在特定条件下(如整数或特定数值)的处理方式。

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.

Input

The first and only line of input contains a single string of form a.deb where ad 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.

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
题意很简单,将一个数的科学记数法表达还原。简单模拟即可,不过有坑点,题中已作提示,即1.0e0,0.0e0这种数据也是存在的,对于这些数据,单独判断即可。

#include <iostream>
#include <cstdio>
#include <map>
#include <cmath>
#include <algorithm>
#include <cstring>
#include <string>
using namespace std;
#define LL long long
#define maxn 1000100
char 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;
}








内容概要:本文围绕可变桨叶四旋翼无人机的规范控制与点对点运动模拟展开,重点研究优化推力分配策略在翻转动作中的应用与性能比较。通过Matlab代码实现,构建了四旋翼动力学模型,并设计了多种控制算法以实现精确的姿态调整与轨迹跟踪。研究对比了不同推力分配方案在执行高机动性翻转动作时的稳定性、能耗效率与响应速度,旨在提升无人机在复杂飞行任务中的动态性能与控制精度。该仿真研究为无人机飞控系统的设计与优化提供了理论依据技术支持。; 适合人群:具备定自动控制理论基础Matlab编程能力,从事无人机控制、飞行器动力学或机器人系统研究的科研人员及研究生。; 使用场景及目标:① 实现四旋翼无人机在三维空间中的精确点对点运动控制;② 对比分析不同推力分配策略在执行翻转等高难度动作时的控制效果与能耗表现,优化飞行性能;③ 为无人机自主飞行、特技飞行及复杂环境下的机动控制提供算法验证平台。; 阅读建议:此资源以Matlab仿真为核心,建议读者结合相关控制理论知识,深入理解代码实现细节,重点关注动力学建模、控制律设计与推力分配模块。在学习过程中,应动手调试参数,复现文中翻转动作的仿真结果,并尝试拓展至其他复杂飞行任务,以加深对无人机控制机理的理解。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值