十一分求助
查看原帖
十一分求助
1400000
Lordi楼主2024/8/15 18:22

风格很差劲的那种啦,各位路过大佬帮帮忙。会非常感谢。

#include<bits/stdc++.h>
using namespace std;
struct node{
	bool nm;
	int pos;
};
node xb[11];
int num[10000010];
signed main(){
	ios::sync_with_stdio(NULL);
	cin.tie(0);
	cout.tie(0);
	long long a,b,k=0,j;
	cin>>a>>b;
	k=a%b;
	cout<<a/b;
//	while(k){
	j=2;
	num[1] = -1;
	while(k){
		k*=10;
		num[j]=k/b;
		j++;
		k%=b;
		if(xb[k].nm<1){
			xb[k].nm = 1;
			xb[k].pos = j;
		}
		else {
			num[1]=xb[k].pos;
			break;
		}
	}
//	}
	if(num[1]==-1){
		cout<<".";
		for(int i=2;i<j;i++){
			cout<<num[i];
		}
	} else{
		cout<<".";
		for(int i=2;i<j;i++){
			if(i == num[1]) cout << '(';
			cout<<num[i];
		}
		cout << ')';
	}
	return 0;
}

QWQ

2024/8/15 18:22
加载中...