<var id="ltzjf"></var><progress id="ltzjf"></progress><cite id="ltzjf"><video id="ltzjf"></video></cite>
<menuitem id="ltzjf"><strike id="ltzjf"></strike></menuitem>
<cite id="ltzjf"><video id="ltzjf"><menuitem id="ltzjf"></menuitem></video></cite>
<var id="ltzjf"><strike id="ltzjf"></strike></var>
<cite id="ltzjf"></cite>
<var id="ltzjf"><video id="ltzjf"></video></var>
<cite id="ltzjf"><strike id="ltzjf"></strike></cite>
<cite id="ltzjf"><span id="ltzjf"></span></cite>
<ins id="ltzjf"><span id="ltzjf"><var id="ltzjf"></var></span></ins><cite id="ltzjf"><video id="ltzjf"></video></cite>
<var id="ltzjf"><video id="ltzjf"></video></var>
<cite id="ltzjf"><span id="ltzjf"><menuitem id="ltzjf"></menuitem></span></cite>
<ins id="ltzjf"><span id="ltzjf"><var id="ltzjf"></var></span></ins><cite id="ltzjf"></cite>
Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

Re:絕望,重寫了幾次都一直WA

Posted by 2310852380 at 2018-02-22 09:21:40 on Problem 1001
In Reply To:絕望,重寫了幾次都一直WA Posted by:liweiliu at 2017-10-12 16:09:15
//你好像忘記考慮整數的情況了,我改了一下。你的代碼很精簡,我想把它放在我的博客里可以嗎?(微信:15955272317)
#include <stdio.h>
#include <algorithm>
#include <iostream>
#include <string>
using namespace std;
string s, a, b;//輸入字符串,乘數,被乘數
int n, l;//冪,小數點位置
void init(){
	l = s.find('.');
	if (l >= 0) {
		s.erase(l, 1);
		l = (s.length() - l)*n;
	}
	reverse(s.begin(), s.end());
}
void multiply(){
	for (int i = 0; i < a.length(); ++i)
	for (int j = 0; j < b.length(); ++j){
		s[i + j] += (a[i] - 48)*(b[j] - 48);
		s[i + j + 1] += s[i + j] / 10;
		s[i + j] %= 10;
	}
	for (int i = 0; i < s.length(); ++i)s[i] += '0';
}
void calculate(){
	a.assign(s);
	while (--n){
		b.assign(s);
		s = string(a.length() + b.length(), 0);
		multiply();
	}
	reverse(s.begin(), s.end());
}
void printout(){
	if (l >= 0)
		s.insert(s.length() - l, ".");
	int start = 0, end = s.length() - 1;
	while (s[start] == '0')++start;
	while (s[end] == '0')--end;
	s = s.substr(start, end - start + 1 - (s[end]=='.'));
	cout << s << endl;
}
int main(){
	while (cin >> s >> n) {
		init();
		calculate();
		printout();
	}
	return 0;
}

Followed by:

Post your reply here:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator

欧美免费全部免费观看_日本免费高清在线视频_欧美色视频日本片免费
<var id="ltzjf"></var><progress id="ltzjf"></progress><cite id="ltzjf"><video id="ltzjf"></video></cite>
<menuitem id="ltzjf"><strike id="ltzjf"></strike></menuitem>
<cite id="ltzjf"><video id="ltzjf"><menuitem id="ltzjf"></menuitem></video></cite>
<var id="ltzjf"><strike id="ltzjf"></strike></var>
<cite id="ltzjf"></cite>
<var id="ltzjf"><video id="ltzjf"></video></var>
<cite id="ltzjf"><strike id="ltzjf"></strike></cite>
<cite id="ltzjf"><span id="ltzjf"></span></cite>
<ins id="ltzjf"><span id="ltzjf"><var id="ltzjf"></var></span></ins><cite id="ltzjf"><video id="ltzjf"></video></cite>
<var id="ltzjf"><video id="ltzjf"></video></var>
<cite id="ltzjf"><span id="ltzjf"><menuitem id="ltzjf"></menuitem></span></cite>
<ins id="ltzjf"><span id="ltzjf"><var id="ltzjf"></var></span></ins><cite id="ltzjf"></cite>