84分一WA求助
查看原帖
84分一WA求助
757409
Flying_Eagle楼主2023/2/2 17:02
#include <iostream>
#include <algorithm>
#include <cstring>
using namespace std;
int n;
const int LEN = 100000005;
int a[LEN], b, c[LEN], d;

void div_short(int a[], int b, int c[], int &d) {
	d = 0;
	for (int i = LEN - 1; i >= 0; i--) {
		c[i] = (d * 10 + a[i]) / b;
		d = (d * 10 + a[i]) % b;
	}
}

void read(int a[]) {
	string s;
	cin >> s;
	int len = s.size();
	for (int i = 0; i < len; i++)
		a[i] = s[len - i - 1] - '0';
}

void print(int a[]) {
	int i;
	for (i = LEN - 1; i >= 1; i--)
		if (a[i] != 0)
			break;
	for (; i >= 0; i--)
		cout << a[i];
}

int main() {
//	freopen("xxxx.in", "r", stdin);
//	freopen("xxxx.out", "w", stdout);
	ios::sync_with_stdio(false);
	cin.tie(0);
	read(a);
	cin >> b;
	div_short(a, b, c, d);
	print(c);
	return 0;
}

2023/2/2 17:02
加载中...