QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#741475#9622. 有限小数wcdrWA 4ms3640kbC++173.1kb2024-11-13 14:27:232024-11-13 14:27:25

Judging History

你现在查看的是最新测评结果

  • [2024-11-13 14:27:25]
  • 评测
  • 测评结果:WA
  • 用时:4ms
  • 内存:3640kb
  • [2024-11-13 14:27:23]
  • 提交

answer

#include<random>
#include<iostream>
#include<iomanip>
#include<cmath>
#include<ctime>
#include<cctype>
#include<cstdio>
#include<cstdlib>
#include<climits>
//#define NDEBUG
#include<cassert>
#include<cstring>
#include<complex>
#include<algorithm>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<vector>
#include<bitset>
//#define LL __int128
#define LL long long
#define ULL unsigned LL
#define uint unsigned int
//#define int LL
//#define double long double
#define mkp make_pair
#define par pair<int,int>
#define psb push_back
#define epb emplace_back
#define f(x) ((x).first)
#define s(x) ((x).second)
using namespace std;
#define Lbt(x) ((x)&(-(x)))
#define Swap(x,y) (x^=y^=x^=y)
const int Mxxx=1e5;
inline char gc()
{
//	return getchar();
	static char buf[Mxxx],*p1=buf,*p2=buf;
	return p1==p2&&(p2=(p1=buf)+fread(buf,1,Mxxx,stdin),p1==p2)?EOF:*p1++;
}
inline char pc(char ch,bool fl=false)
{
//	return fl?0:putchar(ch),0;
	static char buf[Mxxx],*p1=buf,*p2=buf+Mxxx;
	return (fl||((*p1++=ch)&&p1==p2))&&(fwrite(buf,1,p1-buf,stdout),p1=buf),0;
}
#define output pc('!',true)
inline int read()
{
	char ch=gc();
	int gans=0,gflag=0;
	for(;ch<'0'||'9'<ch;gflag|=ch=='-',ch=gc());
	for(;'0'<=ch&&ch<='9';gans=(gans<<1)+(gans<<3)+(ch^48),ch=gc());
	return gflag?-gans:gans;
}
template<typename T>
inline char read(T&gans)
{
	char ch=gc();
	int gflag=0;gans=0;
	for(;ch<'0'||'9'<ch;gflag|=ch=='-',ch=gc());
	for(;'0'<=ch&&ch<='9';gans=(gans<<1)+(gans<<3)+(ch^48),ch=gc());
	return gans=gflag?-gans:gans,ch;
}
template<typename T>
inline void write(T x)
{
	if(x>9)write(x/10);
	pc(x%10^48);
}
template<typename T>
inline void writenum(T x,char ch)
{
	if(x<0)pc('-'),x=-x;
	write(x);pc(ch);
}
inline void writechar(char x,char ch)
{
	pc(x);pc(ch);
}
template<typename T>
inline T Max(T x,T y)
{
	return x>y?x:y;
}
template<typename T>
inline T Min(T x,T y)
{
	return x<y?x:y;
}
template<typename T>
inline T Abs(T x)
{
	return x<0?-x:x;
}
template<typename T>
inline void ckmx(T&x,T y)
{
	x=Max(x,y);
}
template<typename T>
inline void ckmn(T&x,T y)
{
	x=Min(x,y);
}
int TT,ansa,ansb;
//inline LL Gcd(LL x,LL y){return !y?x:Gcd(y,x%y);}
signed main()
{
	#ifndef ONLINE_JUDGE
	freopen("_.in","r",stdin);
//	freopen("_.out","w",stdout);
	#endif
	int a,b,x,y,s,v,nw;
	for(TT=read();TT;TT--)
	{
		a=read();b=read();
//		int tpa=a,tpb=b;
		for(;!(b&1);b>>=1);
		for(;!(b%5);b/=5);
		if(!(a%=b)){writenum(0,32);writenum(1,10);continue;}
//		cout<<"CK?:"<<a<<" "<<b<<"\n";
		for(x=0,ansa=s=b-a,ansb=nw=b;nw<=1e9;nw<<=1,s<<=1,x++)for(LL vl=(y=0,v=s,nw);vl<=1e9;vl*=5,v*=5,y++)if((v%b)<ansa)
//		cout<<"Cng:"<<ansa<<" "<<ansb<<"\n",
		ansa=v%b,ansb=vl
//		,cout<<"Cng:"<<ansa<<" "<<ansb<<"\n"
		;
		writenum(ansa,32);writenum(ansb,10);
//		LL g=Gcd(tpb,ansb),tpd=(LL)tpb*ansb/g,tpc=(LL)tpa*ansb/g+(LL)tpb*ansa/g;
//		g=Gcd(tpc,tpd);for(tpd/=g;!(tpd&1);tpd>>=1);for(;!(tpd%5);tpd/=5);
//		assert(tpd==1);
	}
	return output;
}
/*
1 1 2
*/
/*
1 2 3
*/
/*
4
1 2
2 3
3 7
19 79
*/

詳細信息

Test #1:

score: 100
Accepted
time: 0ms
memory: 3640kb

input:

4
1 2
2 3
3 7
19 79

output:

0 1
1 3
1 4375
3 316

result:

ok 4 case(s)

Test #2:

score: -100
Wrong Answer
time: 4ms
memory: 3604kb

input:

10000
11 12
28 53
17 60
2 35
17 181
80 123
68 141
79 163
71 99
13 64
33 61
15 32
16 61
11 86
33 74
128 143
40 53
7 23
30 31
5 6
86 181
73 91
13 23
71 81
1 2
7 38
117 160
33 83
129 151
88 153
25 58
16 19
19 141
95 124
43 96
71 139
11 59
106 109
93 152
34 43
17 99
1 57
20 159
16 25
5 73
159 170
172 17...

output:

1 3
1 828125000
1 3
1 21875
1 231680000
23 960937500
1 36096000
5 326
1 63360
0 1
1 61000
0 1
1 4880
1 5375
1 9250
1 11714560
1 331250
1 898437500
1 31
1 3
1 289600000
1 455000
1 115000000
1 1265625
0 1
1 14843750
0 1
1 415
1 235937500
1 765000000
1 90625
1 2968750
1 4406250
3 6200
1 15
3 347500
1 9...

result:

wrong answer The result is not terminating.(Testcase 3)