QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#796742 | #9622. 有限小数 | AdisFD | Compile Error | / | / | C++14 | 1.2kb | 2024-12-02 01:16:23 | 2024-12-02 01:16:23 |
Judging History
This is the latest submission verdict.
- [2024-12-02 01:16:23]
- Judged
- Verdict: Compile Error
- Time: 0ms
- Memory: 0kb
- [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; | ^