QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#796742#9622. 有限小数AdisFDCompile Error//C++141.2kb2024-12-02 01:16:232024-12-02 01:16:23

Judging History

This is the latest submission verdict.

  • [2024-12-02 01:16:23]
  • Judged
  • [2024-12-02 01:16:23]
  • Submitted

answer

#include<bits/stdc++.h>
#define int long long
using namespace std;
int T,a,b,c,ans,ans1,ans2,gd1,k2,k5,a2,a5;
int i1,i2;
map<int> mp;
int gcd(int a1,int b1) {
	int c1=a1%b1;
	while(b1!=0) {
		c1=a1%b1;
		a1=b1;
		b1=c1;
	}
	return a1;
}
int dfs(int a1,int b1,bool b2) {
	int gd=1;
	if(ans==1)return 0;
	gd=gcd(c-(a1%c),b1);
	if(b1/gd>1000000000)return 0;
	if((c-(a1%c))/gd<ans) {
		ans=(c-(a1%c))/gd;
		ans1=b1/gd;
	}
	if(b2==0)dfs(a1*2,b1*2,0);
	dfs(a1*5,b1*5,1);
	return 0;
}

signed main() {
	cin>>T;
	for(int I=1; I<=T; I++) {
		cin>>a>>b;
		c=b;
		k2=k5=0;
		while(c%2==0) {
			c/=2;
			k2++;
		}
		while(c%5==0) {
			c/=5;
			k5++;
		}
		if(c==1) {
			cout<<"0 1"<<endl;
			continue;
		}
		ans=c+1;
		dfs(a,b,0);
		a2=1;
		for(int i=0; i<=k2; i++) {
			a2*=2;
			a5=1;
			for(int ii=0; ii<=k5; ii++) {
				a5*=5;
				i1=a2*a5*c/10;
				mp.clear();
				for(int j=1; j<c; j++) {
					if(mp[ans2])break;
					ans2=j*(b/i1)+a;
					ans2=c-(ans2%c);
					mp[ans2]=1;
					if(ans2==c) {
						gd1=gcd(j,i1);
						if(j/gd1<ans) {
							ans=j/gd1;
							ans1=i1/gd1;
						}
					}
				}
			}
		}
		cout<<ans<<" "<<ans1<<endl;
	}
}

詳細信息

answer.code:6:8: error: wrong number of template arguments (1, should be at least 2)
    6 | map<int> mp;
      |        ^
In file included from /usr/include/c++/13/map:63,
                 from /usr/include/x86_64-linux-gnu/c++/13/bits/stdc++.h:152,
                 from answer.code:1:
/usr/include/c++/13/bits/stl_map.h:102:11: note: provided for ‘template<class _Key, class _Tp, class _Compare, class _Alloc> class std::map’
  102 |     class map
      |           ^~~
answer.code: In function ‘int main()’:
answer.code:57:36: error: request for member ‘clear’ in ‘mp’, which is of non-class type ‘int’
   57 |                                 mp.clear();
      |                                    ^~~~~
answer.code:59:46: error: invalid types ‘int[long long int]’ for array subscript
   59 |                                         if(mp[ans2])break;
      |                                              ^
answer.code:62:43: error: invalid types ‘int[long long int]’ for array subscript
   62 |                                         mp[ans2]=1;
      |                                           ^