题解 | 特殊的科学计数法
特殊的科学计数法
https://www.nowcoder.com/practice/ca0962879d3b40d8bb598fb9a905ac7a
#include<bits/stdc++.h>
#include <string>
using namespace std;
#define int long long
#define x first
#define y second
#define space ' '
#define endl '\n'
#define pb push_back
#define all(x) x.begin(),x.end()
#define debug(x) x<<' '
typedef pair<int,int> PII;
const int N=2e5+10;
const int INF=0x3f3f3f3f3f3f3f3fLL;
const int inf=0x3f3f3f3f3f3f3f3fLL;
const int mod=1e9+7;
const int MOD=998244353;
int n,m,k,q;
void solve(){
string s;
cin>>s;
if(s.size()<3){
cout<<s[0]<<'.'<<s[1]<<"*10^"<<1;
return ;
}
string ss=s.substr(0,3);
int exp=s.size()-1;
if(ss[2]-'0'>=5){
int ans=(s[0]-'0')*10+(s[1]-'0')+1;
string sss=to_string(ans);
int expp=sss.size()-1;
cout<<sss[0]<<"."<<sss[1]<<"*10^"<<exp+expp-1;
}
else{
cout<<ss[0]<<"."<<ss[1]<<"*10^"<<exp;
}
}
signed main(){
// double start=(double)clock()/CLOCKS_PER_SEC;
ios::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
cout<<fixed<<setprecision(3);
int t=1;
// cin>>t;
while(t--){
solve();
}
// double end=(double)clock()/CLOCKS_PER_SEC;
// cout<<endl<<"time="<<end-start<<endl;
return 0;
}
