codeofrce:http://codeforces.com/contest/697/problem/B
qduoj:https://qduoj.com/problem/120/
将科学计数法表示的数字转化为一般数字
Java的高精度类:
复制代码
1
2
3
4
5
6
7import java.util.Scanner; public class Main { static Scanner sc = new Scanner(System.in); public static void main(String[] args) { System.out.println(sc.nextBigDecimal().stripTrailingZeros().toPlainString()); } }
c++的模拟:
复制代码
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98#include<iostream> #include<algorithm> #include<cstring> #include<string> #include<cstdio> #include<vector> #include<queue> #include<set> #include<map> using namespace std; int main() { string p, num, q, first, last; while(cin >> p) { int len = p.length(); int e = p.find_first_of('e'), n = 0; int point = p.find_first_of('.'); num = p.substr(0, e); q = p.substr(e+1, len - e); for(int i = 0; i < q.length(); i++) n = n*10 + q[i] - '0'; first = p.substr(0, point); last = p.substr(point+1, e-point-1); if(first.length() == 1 && first[0] == '0' && last.find_first_not_of('0') >= last.length()) { cout << 0 << endl; continue; } if(last.find_first_not_of('0') >= last.length()) { cout << first; for(int i = 0; i < n; i++) cout<<0; cout << endl; continue; } if(first.length() == 1 && first[0] == '0' ) { if(n == 0) { cout << 0 << "." << last << endl; continue; } if(last.length() > n) { string ans = last.substr(0, n); int flag = 0; if(ans.find_first_not_of('0') >= ans.length()) cout << 0; else { for(int k = 0; k < ans.length(); k++) { if(ans[k] == '0' && flag == 0) continue; else { flag = 1; cout << ans[k]; } } } cout <<"."<<last.substr(n, last.length()) << endl; } else { cout << last; for(int i = 0; i < n-last.length(); i++) cout << 0; cout << endl; } continue; } else { if(n == 0) { cout << first << "." << last << endl; continue; } if(last.length() > n) { cout << first << last.substr(0, n) <<"."<<last.substr(n, last.length()) << endl; } else { cout << first << last; for(int i = 0; i < n-last.length(); i++) cout << 0; cout << endl; } continue; } } return 0; }
最后
以上就是痴情彩虹最近收集整理的关于codeforce#362B. Barnicle(java高精度类)的全部内容,更多相关codeforce#362B.内容请搜索靠谱客的其他文章。
本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
发表评论 取消回复