QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#786398#9622. 有限小数EricWCompile Error//C++141.1kb2024-11-26 21:22:272024-11-26 21:22:27

Judging History

This is the latest submission verdict.

  • [2024-11-26 21:22:27]
  • Judged
  • [2024-11-26 21:22:27]
  • Submitted

answer

#include <bits/stdc++.h>
#define int long long
using namespace std;
int ans=1e17,ans1=0;
int max2=40,max5=40;
int tt=0;
void solve()
{
	
	int a,b;
	cin>>a>>b;
	tt++;
	if(tt==391)cout<<a<<" "<<b<<"\n";
	if(tt>5)continue;
	a=a%b;
	int sum=1;
	while(b%2==0)
	 {
	 	sum*=2;
	 	b/=2;
	 }
	 while(b%5==0)
	 {
	 	sum*=5;
	 	b/=5;
	 }
     int temp=sum*b;
     int temp1=sum*b;
	 for(int i=0;i<=max2;i++)
	 { 	
	 	for(int j=0;j<=max5;j++)
	 	{
	      int flag=0;
	 	  temp=sum*b;
	    for(int ii=1;ii<=i;ii++)
	     {
	     	temp=temp*2;
	     	if(temp>1e9)
	     	{
	     		flag=1;
	     		break;
			}
		 }
		 if(flag)
		 break;
		  for(int ii=1;ii<=j;ii++)
	     {
	     	temp=temp*5;
	     	if(temp>1e9)
	     	{
	     		flag=1;
	     		break;
			}
		 }
		 if(flag)
		 break;
		 int c=((-(temp/b/sum)*a)%b+b)%b;
		 if(c<ans)
		 {
		 	ans=c;
		 	ans1=temp;
		 }
		}
	 }
	 cout<<ans/__gcd(ans,ans1)<<' '<<ans1/__gcd(ans,ans1)<<'\n';
}
signed main()
{
	int t;
	cin>>t;
	while(t--)
	{
		ans=1e17;
		solve();
	}
}

详细

answer.code: In function ‘void solve()’:
answer.code:14:17: error: continue statement not within a loop
   14 |         if(tt>5)continue;
      |                 ^~~~~~~~