高精除低精求调
  • 板块学术版
  • 楼主caramel_qwq
  • 当前回复3
  • 已保存回复3
  • 发布时间2023/8/3 15:28
  • 上次更新2023/11/3 06:09:27
查看原帖
高精除低精求调
444195
caramel_qwq楼主2023/8/3 15:28

以下是一组hack

7319951122
19

标准答案是

385260585
7

但我的是

385260638
0

代码如下

#include<bits/stdc++.h>
using namespace std;
const int N=1e5+8;
int A[N],b,lena,ys;
queue<int> ans;
int main(){
	string s;
	cin>>s>>b;
	lena=s.size();
	for(int i=1;i<=lena;i++) A[i]=s[i-1]-'0';
	int r=0;
	for(int i=1;i<=lena;i++){
		r=ys*10+r*10+A[i];
		if(r<b) ans.push(0);
		else{
			ys=r%b;
			ans.push(floor(r/b));
			r=0;
		}
	}
	while(ans.front()==0&&ans.size()-1>=1) ans.pop();
	while(!ans.empty()){
		printf("%d",ans.front());
		ans.pop();
	}
	printf("\n%d\n",ys);
	return 0;
}
2023/8/3 15:28
加载中...