Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

Is the test data OK?

Posted by javaman at 2005-08-26 09:06:47 on Problem 1930
I can pass all the offical test data but cannot got ac.
input:
0.3...
0.6...
0.7...
0.5...
0.3...
0.5...
0.6...
0.2...
0.9...
0.1...
0.62...
0.27...
0.90...
0.59...
0.63...
0.26...
0.40...
0.26...
0.72...
0.36...
0.211...
0.368...
0.567...
0.429...
0.782...
0.530...
0.862...
0.123...
0.067...
0.135...
0.3929...
0.9802...
0.4022...
0.3058...
0.3069...
0.8167...
0.1393...
0.8456...
0.5011...
0.8042...
0.76229...
0.77373...
0.84421...
0.44919...
0.13784...
0.98537...
0.75198...
0.94324...
0.98315...
0.64370...
0.566413...
0.803526...
0.776091...
0.268980...
0.759956...
0.241873...
0.806862...
0.999170...
0.906996...
0.497281...
0.1702305...
0.4420925...
0.7477084...
0.7336327...
0.2660336...
0.9126505...
0.5750846...
0.2621729...
0.0661313...
0.3925857...
0.41616124...
0.84353895...
0.39819582...
0.01100545...
0.98898814...
0.48233367...
0.10515434...
0.85990364...
0.74344043...
0.60313750...
0.477171087...
0.356426808...
0.945117276...
0.889947178...
0.780695788...
0.709393584...
0.491705403...
0.918502651...
0.752392754...
0.474612399...
0.9...
0.50...
0.33...
0.250...
0.20...
0.16...
0.142857...
0.1250...
0.1...
0.10...
0.100...
0.1000...
0.10000...
0.100000...
0.1000000...
0.10000000...
0.100000000...
0.1428571...
0.14285714...
0.142857142...
0.000000001...
0.999999999...
0.999999998...
0.012345679...
0.000002997...
0.000333667...
0.490183332...
0.200000001...
0.135984076...
0.074783710...
0.762952003...
0.551964542...
0.533186397...
0.022682725...
0.308048647...
0.006608467...
0.2131200...
0

output1/3
2/3
7/9
5/9
1/3
5/9
2/3
2/9
1/1
1/9
28/45
3/11
9/10
3/5
7/11
4/15
2/5
4/15
8/11
4/11
19/90
73/198
21/37
43/100
155/198
35/66
194/225
37/300
61/900
5/37
389/990
2426/2475
181/450
278/909
31/101
4043/4950
23/165
1408/1665
451/900
1327/1650
7623/10000
383/495
27859/33000
1123/2500
1253/9090
12194/12375
8347/11100
349/370
8111/8250
869/1350
42481/75000
9799/12195
155063/199800
13449/50000
227987/300000
3356/13875
22693/28125
99917/100000
13741/15150
13812/27775
61283/360000
23873/54000
210293/281250
201749/275000
29559/111110
225881/247500
79793/138750
24251/92500
2767/41841
72701/185185
1124759/2702700
4217273/4999500
402218/1010101
6053/550000
667567/675000
3014284/6249375
260257/2475000
419461/487800
247811/333330
48251/80000
2272241/4761900
1253063/3515625
37804313/39999600
9888301/11111110
70262621/90000000
5675143/7999992
61463114/124999875
2424847/2640000
16718167/22220000
1186531/2500000
1/1
1/2
1/3
1/4
1/5
1/6
1/7
1/8
1/9
1/10
1/10
1/10
1/10
1/10
1/10
1/10
1/10
1/7
1/7
1/7
1/900000000
1/1
899999999/900000000
1/81
1/333667
1/2997
163394444/333333333
66666667/333333333
9065605/66666666
7478371/99999999
42386222/55555555
61329393/111111110
59242933/111111111
4536545/199999998
154024322/499999995
5947621/900000000
666/3125#include <iostream>
#include <cstdio>
#include <cmath>
#include <string>

using namespace std;

typedef __int64 ll;

char s[100];

ll gcd(ll a,ll b) {
	return b?gcd(b,a%b):a;
}

int main() {
ll a,b,c,d,p,q,g,x,bestp,bestq;
int bit,i;

	while (true) {
		scanf("%s",s);
		if (!strcmp(s,"0"))
			break;
		bit=strlen(s)-5;
		s[bit+2]=0;
		sscanf(s+2,"%I64d",&x);
		bestq=-1;
		for (i=1;i<=bit;++i) {
			p=(ll) pow(10.,(double) (bit-i));
			q=(ll) pow(10.,(double) i);
			a=x/q;
			c=x%q;
			b=p;
			d=(q-1)*p;
			g=(a,b);
			a/=g;
			b/=g;
			g=gcd(c,d);
			c/=g;
			d/=g;
			p=a*d+b*c;
			q=b*d;
			g=gcd(p,q);
			p/=g;
			q/=g;
			if ((bestq<0) || (bestq>q) || ((bestq==q) && (bestp<p))) {
				bestp=p;
				bestq=q;
			}
		}
		printf("%I64d/%I64d\n",bestp,bestq);
	}
	return 0;
}




		
	




my code:


Followed by:

Post your reply here:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator