This repository was archived by the owner on Mar 11, 2026. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 22
Expand file tree
/
Copy pathdarts.java
More file actions
182 lines (162 loc) · 16.1 KB
/
darts.java
File metadata and controls
182 lines (162 loc) · 16.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
import java.io.*;
import java.util.*;
public class darts {
private static Reader in;
private static PrintWriter out;
public static int [] sections = new int[]
{ 20, 1, 18, 4, 13, 6, 10, 15, 2, 17, 3, 19, 7, 16, 8, 11, 14, 9, 12, 5 };
public static int [] left, right;
private static double [][] memo;
private static double [][] ans = {{0,0},{0.13636364,0.90909091},{0.13636364,0.90909091},{0.13636364,0.90909091},{0.13636364,0.90909091},{0.13636364,0.90909091},{0.13636364,0.90909091},{0.13636364,0.90909091},{0.13636364,0.90909091},{0.13636364,0.90909091},{0.13636364,0.90909091},{0.13636364,0.90909091},{0.13636364,0.90909091},{0.13636364,0.90909091},{0.13636364,0.90909091},{0.13636364,0.90909091},{0.13636364,0.90909091},{0.13636364,0.90909091},{0.13636364,0.90909091},{0.13636364,0.90909091},{0.13636364,0.90909091},{0.13636364,0.90909091},{0.13409091,0.91060606},{0.13174242,0.91217172},{0.12931566,0.91378956},{0.12680800,0.91546134},{0.12421675,0.91718883},{0.12153912,0.91897392},{0.11877225,0.92081850},{0.11591314,0.92272457},{0.12720185,0.91214321},{0.12405681,0.91451768},{0.12079305,0.91697130},{0.11740660,0.91950671},{0.11389339,0.92212663},{0.11024918,0.92483388},{0.10646961,0.92763137},{0.10724422,0.92611496},{0.10470588,0.92761437},{0.11170134,0.92328707},{0.10705151,0.92702122},{0.11441183,0.92275323},{0.11121608,0.92497631},{0.10802219,0.92719354},{0.10638637,0.92789836},{0.10371155,0.92959671},{0.10883293,0.92534517},{0.10555516,0.92775837},{0.10654796,0.92689017},{0.10476131,0.92797178},{0.10403074,0.92876870},{0.10119001,0.93077457},{0.09803895,0.93307288},{0.09907432,0.93182983},{0.09632143,0.93379270},{0.09625600,0.93354156},{0.09576941,0.93373756},{0.09647721,0.93324319},{0.09677935,0.93316782},{0.09460844,0.93553178},{0.09654546,0.93399740},{0.09375845,0.93594580},{0.09427601,0.93536236},{0.09266568,0.93630898},{0.09252501,0.93633538},{0.09348141,0.93554407},{0.09173605,0.93722618},{0.09188081,0.93703293},{0.08952384,0.93869501},{0.08975284,0.93841809},{0.08761726,0.93985195},{0.08675305,0.94035655},{0.08733848,0.93979654},{0.08629056,0.94064885},{0.08648481,0.94050036},{0.08483798,0.94184257},{0.08569347,0.94110108},{0.08419156,0.94223833},{0.08328618,0.94288049},{0.08355143,0.94254001},{0.08243259,0.94333075},{0.08291106,0.94293876},{0.08140049,0.94415675},{0.08173099,0.94383095},{0.08077315,0.94454299},{0.08000134,0.94516346},{0.07953196,0.94538898},{0.07828377,0.94623463},{0.07870349,0.94586819},{0.07733006,0.94689752},{0.07730021,0.94686202},{0.07664033,0.94736871},{0.07635327,0.94759081},{0.07578626,0.94797887},{0.07460234,0.94881917},{0.07507913,0.94838688},{0.07386317,0.94927825},{0.07373981,0.94932473},{0.07314690,0.94977133},{0.07286598,0.94994926},{0.07250491,0.95021508},{0.07142600,0.95102687},{0.07156847,0.95083628},{0.07052004,0.95159111},{0.07037850,0.95167047},{0.06966530,0.95217474},{0.06924572,0.95243738},{0.06903770,0.95259396},{0.06820554,0.95322213},{0.06808957,0.95325161},{0.06718696,0.95390322},{0.06720114,0.95386848},{0.06644302,0.95440440},{0.06594354,0.95472831},{0.06583261,0.95480332},{0.06513726,0.95531027},{0.06495616,0.95541468},{0.06415260,0.95600605},{0.06413775,0.95597917},{0.06346116,0.95646453},{0.06294416,0.95681839},{0.06275127,0.95693448},{0.06210963,0.95738652},{0.06194304,0.95749532},{0.06122548,0.95802333},{0.06108698,0.95808356},{0.06052193,0.95849367},{0.06011422,0.95877988},{0.05980256,0.95897770},{0.05918969,0.95940334},{0.05910149,0.95945925},{0.05844438,0.95993487},{0.05821467,0.96006847},{0.05774583,0.96041149},{0.05741360,0.96063994},{0.05705792,0.96087790},{0.05647059,0.96128936},{0.05638647,0.96133477},{0.05578644,0.96176310},{0.05551766,0.96193550},{0.05509236,0.96224327},{0.05476889,0.96245864},{0.05443031,0.96269386},{0.05390676,0.96306569},{0.05375798,0.96315058},{0.05321413,0.96353615},{0.05298124,0.96369180},{0.05255950,0.96399050},{0.05221866,0.96421577},{0.05193472,0.96441778},{0.05147555,0.96474385},{0.05126296,0.96487496},{0.05077033,0.96522449},{0.05057513,0.96535474},{0.05015754,0.96564719},{0.04980238,0.96588509},{0.04955533,0.96606047},{0.04913917,0.96635232},{0.04889441,0.96651187},{0.04845061,0.96682791},{0.04825572,0.96695462},{0.04785796,0.96723322},{0.04752235,0.96746230},{0.04727533,0.96763344},{0.04688447,0.96790422},{0.04665105,0.96806207},{0.04624631,0.96834963},{0.04602850,0.96849016},{0.04566557,0.96874592},{0.04536559,0.96895290},{0.04510276,0.96913194},{0.04472908,0.96938979},{0.04452113,0.96953292},{0.04414514,0.96979780},{0.04390415,0.96995547},{0.04357789,0.97018662},{0.04330412,0.97037475},{0.04303107,0.97056066},{0.04268083,0.97080334},{0.04248423,0.97093790},{0.04213106,0.97118462},{0.04188797,0.97134700},{0.04158767,0.97155931},{0.04132441,0.97173824},{0.04105887,0.97192076},{0.04073767,0.97214448},{0.04053560,0.97228080},{0.04020404,0.97251156},{0.03997621,0.97266643},{0.03969049,0.97286665},{0.03942855,0.97304366},{0.03918238,0.97321470},{0.03888771,0.97341990},{0.03867419,0.97356312},{0.03836616,0.97377774},{0.03815479,0.97392237},{0.03787831,0.97411443},{0.03762133,0.97428862},{0.03739329,0.97444775},{0.03711799,0.97463836},{0.03690069,0.97478486},{0.03661638,0.97498343},{0.03641313,0.97512189},{0.03614755,0.97530568},{0.03590365,0.97547228},{0.03568588,0.97562356},{0.03542375,0.97580392},{0.03521371,0.97594700},{0.03495002,0.97613109},{0.03474707,0.97626840},{0.03449665,0.97644193},{0.03426927,0.97659815},{0.03405527,0.97674562},{0.03380511,0.97691735},{0.03360716,0.97705336},{0.03335947,0.97722555},{0.03315639,0.97736270},{0.03292290,0.97752501},{0.03270946,0.97767170},{0.03249869,0.97781622},{0.03226244,0.97797870},{0.03207444,0.97810812},{0.03183936,0.97827069},{0.03164109,0.97840515},{0.03142266,0.97855712},{0.03121822,0.97869706},{0.03101435,0.97883690},{0.03079324,0.97898941},{0.03061048,0.97911475},{0.03038719,0.97926868},{0.03019813,0.97939771},{0.02999119,0.97954130},{0.02979310,0.97967637},{0.02959941,0.97980969},{0.02939227,0.97995266},{0.02921237,0.98007548},{0.02900152,0.98022082},{0.02882243,0.98034355},{0.02862433,0.98048038},{0.02843328,0.98061060},{0.02825028,0.98073693},{0.02805439,0.98087183},{0.02787848,0.98099175},{0.02768038,0.98112850},{0.02750907,0.98124588},{0.02731929,0.98137651},{0.02713715,0.98150097},{0.02696296,0.98162120},{0.02677618,0.98174940},{0.02660675,0.98186514},{0.02642043,0.98199383},{0.02625462,0.98210714},{0.02607390,0.98223141},{0.02590148,0.98234956},{0.02573400,0.98246484},{0.02555572,0.98258697},{0.02539419,0.98269765},{0.02521792,0.98281923},{0.02505703,0.98292893},{0.02488595,0.98304669},{0.02472240,0.98315887},{0.02456081,0.98326974},{0.02439136,0.98338583},{0.02423737,0.98349153},{0.02406966,0.98360690},{0.02391458,0.98371264},{0.02375273,0.98382415},{0.02359652,0.98393116},{0.02344125,0.98403753},{0.02328084,0.98414757},{0.02313312,0.98424891},{0.02297332,0.98435858},{0.02282503,0.98445986},{0.02267131,0.98456572},{0.02252146,0.98466817},{0.02237319,0.98476978},{0.02222131,0.98487405},{0.02207892,0.98497153},{0.02192698,0.98507572},{0.02178565,0.98517243},{0.02163900,0.98527324},{0.02149537,0.98537131},{0.02135425,0.98546814},{0.02120993,0.98556715},{0.02107278,0.98566089},{0.02092865,0.98575975},{0.02079365,0.98585218},{0.02065353,0.98594830},{0.02051640,0.98604196},{0.02038191,0.98613428},{0.02024430,0.98622854},{0.02011276,0.98631842},{0.01997608,0.98641221},{0.01984665,0.98650074},{0.01971295,0.98659234},{0.01958238,0.98668161},{0.01945381,0.98676980},{0.01932249,0.98685962},{0.01919681,0.98694556},{0.01906692,0.98703466},{0.01894268,0.98711953},{0.01881538,0.98720672},{0.01869103,0.98729180},{0.01856790,0.98737613},{0.01844274,0.98746169},{0.01832276,0.98754379},{0.01819905,0.98762857},{0.01807997,0.98770984},{0.01795886,0.98779282},{0.01784019,0.98787398},{0.01772235,0.98795458},{0.01760323,0.98803603},{0.01748853,0.98811452},{0.01737057,0.98819524},{0.01725673,0.98827295},{0.01714142,0.98835195},{0.01702798,0.98842947},{0.01691540,0.98850643},{0.01680206,0.98858395},{0.01669224,0.98865903},{0.01657981,0.98873590},{0.01647112,0.98881014},{0.01636116,0.98888542},{0.01625272,0.98895945},{0.01614531,0.98903288},{0.01603735,0.98910671},{0.01593219,0.98917854},{0.01582511,0.98925173},{0.01572133,0.98932263},{0.01561638,0.98939441},{0.01551282,0.98946508},{0.01541035,0.98953514},{0.01530739,0.98960550},{0.01520680,0.98967417},{0.01510484,0.98974386},{0.01500564,0.98981161},{0.01490548,0.98988005},{0.01480669,0.98994747},{0.01470885,0.99001435},{0.01461062,0.99008142},{0.01451450,0.99014702},{0.01441737,0.99021340},{0.01432251,0.99027815},{0.01422697,0.99034339},{0.01413274,0.99040771},{0.01403927,0.99047156},{0.01394555,0.99053551},{0.01385376,0.99059816},{0.01376117,0.99066141},{0.01367047,0.99072327},{0.01357938,0.99078546},{0.01348945,0.99084684},{0.01340016,0.99090779},{0.01331079,0.99096875},{0.01322312,0.99102859},{0.01313481,0.99108888},{0.01304815,0.99114795},{0.01296129,0.99120726},{0.01287542,0.99126583},{0.01279015,0.99132400},{0.01270493,0.99138213},{0.01262118,0.99143928},{0.01253693,0.99149674},{0.01245418,0.99155316},{0.01237132,0.99160971},{0.01228933,0.99166561},{0.01220792,0.99172112},{0.01212666,0.99177655},{0.01204662,0.99183113},{0.01196627,0.99188591},{0.01188726,0.99193978},{0.01180819,0.99199371},{0.01172990,0.99204706},{0.01165220,0.99210004},{0.01157468,0.99215290},{0.01149822,0.99220500},{0.01142159,0.99225724},{0.01134613,0.99230867},{0.01127068,0.99236011},{0.01119595,0.99241101},{0.01112178,0.99246158},{0.01104781,0.99251199},{0.01097478,0.99256174},{0.01090169,0.99261155},{0.01082963,0.99266065},{0.01075762,0.99270971},{0.01068630,0.99275829},{0.01061549,0.99280655},{0.01054490,0.99285463},{0.01047517,0.99290212},{0.01040545,0.99294963},{0.01033662,0.99299650},{0.01026791,0.99304330},{0.01019984,0.99308966},{0.01013224,0.99313571},{0.01006487,0.99318157},{0.00999829,0.99322691},{0.00993177,0.99327222},{0.00986605,0.99331696},{0.00980049,0.99336161},{0.00973551,0.99340585},{0.00967097,0.99344979},{0.00960669,0.99349354},{0.00954312,0.99353682},{0.00947965,0.99358003},{0.00941689,0.99362274},{0.00935433,0.99366533},{0.00929230,0.99370754},{0.00923069,0.99374948},{0.00916935,0.99379122},{0.00910865,0.99383253},{0.00904808,0.99387374},{0.00898817,0.99391451},{0.00892846,0.99395514},{0.00886925,0.99399542},{0.00881043,0.99403544},{0.00875191,0.99407526},{0.00869395,0.99411469},{0.00863615,0.99415401},{0.00857895,0.99419292},{0.00852197,0.99423168},{0.00846545,0.99427012},{0.00840930,0.99430831},{0.00835345,0.99434630},{0.00829811,0.99438393},{0.00824296,0.99442144},{0.00818835,0.99445858},{0.00813397,0.99449556},{0.00808001,0.99453224},{0.00802642,0.99456869},{0.00797312,0.99460493},{0.00792028,0.99464085},{0.00786765,0.99467663},{0.00781552,0.99471207},{0.00776362,0.99474736},{0.00771211,0.99478236},{0.00766096,0.99481714},{0.00761009,0.99485172},{0.00755965,0.99488600},{0.00750942,0.99492014},{0.00745965,0.99495396},{0.00741011,0.99498763},{0.00736095,0.99502103},{0.00731212,0.99505422},{0.00726357,0.99508721},{0.00721541,0.99511993},{0.00716748,0.99515250},{0.00711997,0.99518478},{0.00707269,0.99521690},{0.00702577,0.99524878},{0.00697915,0.99528044},{0.00693281,0.99531192},{0.00688684,0.99534315},{0.00684110,0.99537422},{0.00679574,0.99540503},{0.00675061,0.99543568},{0.00670583,0.99546610},{0.00666133,0.99549632},{0.00661710,0.99552636},{0.00657322,0.99555615},{0.00652956,0.99558580},{0.00648626,0.99561520},{0.00644319,0.99564445},{0.00640044,0.99567347},{0.00635797,0.99570231},{0.00631575,0.99573097},{0.00627387,0.99575941},{0.00623220,0.99578770},{0.00619086,0.99581576},{0.00614976,0.99584366},{0.00610895,0.99587136},{0.00606841,0.99589888},{0.00602811,0.99592623},{0.00598813,0.99595337},{0.00594836,0.99598036},{0.00590890,0.99600714},{0.00586967,0.99603376},{0.00583071,0.99606019},{0.00579202,0.99608645},{0.00575356,0.99611255},{0.00571539,0.99613845},{0.00567743,0.99616420},{0.00563977,0.99618976},{0.00560232,0.99621516},{0.00556514,0.99624039},{0.00552820,0.99626544},{0.00549150,0.99629034},{0.00545506,0.99631506},{0.00541883,0.99633963},{0.00538288,0.99636402},{0.00534714,0.99638826},{0.00531165,0.99641234},{0.00527639,0.99643625},{0.00524135,0.99646001},{0.00520657,0.99648359},{0.00517200,0.99650704},{0.00513768,0.99653031},{0.00510356,0.99655345},{0.00506969,0.99657642},{0.00503603,0.99659924},{0.00500259,0.99662191},{0.00496940,0.99664442}};
// private static void init () {
// left = new int[21];
// right = new int[21];
// left[sections[0]] = sections[19];
// right[sections[0]] = sections[1];
// for (int i = 1; i < sections.length - 1; i++) {
// left[sections[i]] = sections[i - 1];
// right[sections[i]] = sections[i + 1];
// }
// left[sections[19]] = sections[18];
// right[sections[19]] = sections[0];
// memo = new double[502][502];
// prob (501, 501);
// }
public static void main (String [] args) throws IOException {
in = new Reader ();
out = new PrintWriter (System.out, true);
// init ();
while (true) {
int N = in.nextInt ();
if (N == 0)
break;
out.printf ("%.8f %.8f\n", ans [N][0], ans [N][1]);
}
out.close ();
System.exit (0);
}
// private static double prob (int scoreA, int scoreB) {
// if (memo[scoreA][scoreB] != 0)
// return memo[scoreA][scoreB];
// if (scoreB == 0)
// return 1;
// if (scoreA == 0)
// return 0;
//
// double ret = 0;
// for (int i = 1; i <= 20; i++) {
// double probB = 1. / 3;
// double probSame = 0;
// double res = 0;
// for (int j = 1; j <= 20; j++) {
// double probA = 1. / 20;
//
// if (scoreA >= j || scoreB >= left[i])
// res += probB * probA
// * prob (scoreA >= j ? scoreA - j : scoreA, scoreB >= left[i] ? scoreB - left[i] : scoreB);
// else probSame += probB * probA;
//
// if (scoreA >= j || scoreB >= i)
// res += probB * probA * prob (scoreA >= j ? scoreA - j : scoreA, scoreB >= i ? scoreB - i : scoreB);
// else probSame += probB * probA;
//
// if (scoreA >= j || scoreB >= right[i])
// res += probB * probA
// * prob (scoreA >= j ? scoreA - j : scoreA, scoreB >= right[i] ? scoreB - right[i] : scoreB);
// else probSame += probB * probA;
// }
// ret = Math.max (ret, res / (1 - probSame));
// }
//
// return memo[scoreA][scoreB] = ret;
// }
static class Reader {
final private int BUFFER_SIZE = 1 << 16;
private DataInputStream din;
private byte [] buffer;
private int bufferPointer, bytesRead;
public Reader () {
din = new DataInputStream (System.in);
buffer = new byte[BUFFER_SIZE];
bufferPointer = bytesRead = 0;
}
public Reader (String file_name) throws IOException {
din = new DataInputStream (new FileInputStream (file_name));
buffer = new byte[BUFFER_SIZE];
bufferPointer = bytesRead = 0;
}
public String readLine () throws IOException {
byte [] buf = new byte[1024];
int cnt = 0, c;
while ((c = read ()) != -1) {
if (c == '\n')
break;
buf[cnt++] = (byte) c;
}
return new String (buf, 0, cnt);
}
public int nextInt () throws IOException {
int ret = 0;
byte c = read ();
while (c <= ' ')
c = read ();
boolean neg = (c == '-');
if (neg)
c = read ();
do {
ret = ret * 10 + c - '0';
} while ((c = read ()) >= '0' && c <= '9');
if (neg)
return -ret;
return ret;
}
public long nextLong () throws IOException {
long ret = 0;
byte c = read ();
while (c <= ' ')
c = read ();
boolean neg = (c == '-');
if (neg)
c = read ();
do {
ret = ret * 10 + c - '0';
} while ((c = read ()) >= '0' && c <= '9');
if (neg)
return -ret;
return ret;
}
public double nextDouble () throws IOException {
double ret = 0, div = 1;
byte c = read ();
while (c <= ' ')
c = read ();
boolean neg = (c == '-');
if (neg)
c = read ();
do {
ret = ret * 10 + c - '0';
} while ((c = read ()) >= '0' && c <= '9');
if (c == '.')
while ((c = read ()) >= '0' && c <= '9')
ret += (c - '0') / (div *= 10);
if (neg)
return -ret;
return ret;
}
private void fillBuffer () throws IOException {
bytesRead = din.read (buffer, bufferPointer = 0, BUFFER_SIZE);
if (bytesRead == -1)
buffer[0] = -1;
}
private byte read () throws IOException {
if (bufferPointer == bytesRead)
fillBuffer ();
return buffer[bufferPointer++];
}
public void close () throws IOException {
if (din == null)
return;
din.close ();
}
}
}