QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#790970#9622. 有限小数tjf4Compile Error//C++20838b2024-11-28 16:16:102024-11-28 16:16:12

Judging History

This is the latest submission verdict.

  • [2024-11-28 16:16:12]
  • Judged
  • [2024-11-28 16:16:10]
  • Submitted

answer

#include<bits/stdc++.h>
typedef long long ll;
typedef long long LL;

using namespace std;

const ll inf = 1e9;
LL exgcd(LL a,LL b,LL &x,LL &y){
    if(!b){
        x = 1,y = 0;
        return a;
    }
    LL d = exgcd(b,a%b, y,x);
    y-=a/b*x;
    return d;
}
void yurui111() {
	ll n,m;
	cin>>n>>m;
	ll w=m;
	while(w%5==0)w/=5;
	while(w%2==0)w/=2;
	if(w==1){
		cout<<"0 1"<<endl;
		return;
	}
	ll ansx=m-n,m;
	for(ll i = w;i<=inf;i*=5ll){
		for(ll j = i;j<=inf;j*=2ll){
			ll d1=-n*j;
			ll a=m;
			ll b=w*w;
			ll x=0,y=0;
			ll d=exgcd(a,b,x,y);
			if(d1%d!=0)continue;
			x*=d1/d;
			ll t = abs(b/d);
			x=(x%t+t)%t;
			if(x<ansx){
				ansx=x;
				ansy=j;
			}
		}
	}
	cout<<ansx<<" "<<ansy<<endl;
}
int main(void) {
	int t=1;
	cin>>t;
	while(t--) {
		yurui111();
	}
	return 0;
}

详细

answer.code: In function ‘void yurui111()’:
answer.code:27:21: error: redeclaration of ‘ll m’
   27 |         ll ansx=m-n,m;
      |                     ^
answer.code:18:14: note: ‘ll m’ previously declared here
   18 |         ll n,m;
      |              ^
answer.code:41:33: error: ‘ansy’ was not declared in this scope; did you mean ‘ansx’?
   41 |                                 ansy=j;
      |                                 ^~~~
      |                                 ansx
answer.code:45:26: error: ‘ansy’ was not declared in this scope; did you mean ‘ansx’?
   45 |         cout<<ansx<<" "<<ansy<<endl;
      |                          ^~~~
      |                          ansx