Skip to content

Commit 8bee681

Browse files
authored
Create ToPiOrNotToPi.java
1 parent 0933d34 commit 8bee681

File tree

1 file changed

+91
-0
lines changed

1 file changed

+91
-0
lines changed

Moderate-Level/ToPiOrNotToPi.java

Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
/*
2+
The first argument is a path to a file. Each line includes a test case, which comprises a number indicating the sequence number of a PI value. Print the number that is located at that sequence number.
3+
*/
4+
import java.io.*;
5+
import java.math.BigDecimal;
6+
7+
public class Main {
8+
public static void main (String[] args) throws IOException {
9+
File file = new File(args[0]);
10+
BufferedReader br = new BufferedReader(new FileReader(file));
11+
String line;
12+
while ((line = br.readLine()) != null) {
13+
String pi = "314159265358979323846264338327950288419716939937510582097494459230781640628620899862803482534211706798"
14+
+ "2148086513282306647093844609550582231725359408128481117450284102701938521105559644622948954930381964"
15+
+ "428810975665933446128475648233786783165271201909145648566923460348610454326648213393607260249141273724587006606315588174881520920962829254091715364367"
16+
+ "892590360011330530548820466521384146951941511609433057270365759591953092186117381932611793105118548074462379962749567351885752724891227938183011949129"
17+
+ "833673362440656643086021394946395224737190702179860943702770539217176293176752384674818467669405132000568127145263560827785771342757789609173637178721"
18+
+ "468440901224953430146549585371050792279689258923542019956112129021960864034418159813629774771309960518707211349999998372978049951059731732816096318595"
19+
+ "024459455346908302642522308253344685035261931188171010003137838752886587533208381420617177669147303598253490428755468731159562863882353787593751957781"
20+
+ "857780532171226806613001927876611195909216420198938095257201065485863278865936153381827968230301952035301852968995773622599413891249721775283479131515"
21+
+ "57485724245415069595082953311686172785588907509838"
22+
+ "17546374649393192550604009277016711390098488240128"
23+
+ "58361603563707660104710181942955596198946767837449"
24+
+ "44825537977472684710404753464620804668425906949129"
25+
+ "33136770289891521047521620569660240580381501935112"
26+
+ "53382430035587640247496473263914199272604269922796"
27+
+ "78235478163600934172164121992458631503028618297455"
28+
+ "57067498385054945885869269956909272107975093029553"
29+
+ "21165344987202755960236480665499119881834797753566"
30+
+ "36980742654252786255181841757467289097777279380008"
31+
+ "16470600161452491921732172147723501414419735685481"
32+
+ "61361157352552133475741849468438523323907394143334"
33+
+ "54776241686251898356948556209921922218427255025425"
34+
+ "68876717904946016534668049886272327917860857843838"
35+
+ "27967976681454100953883786360950680064225125205117"
36+
+ "39298489608412848862694560424196528502221066118630"
37+
+ "67442786220391949450471237137869609563643719172874"
38+
+ "67764657573962413890865832645995813390478027590099"
39+
+ "46576407895126946839835259570982582262052248940772"
40+
+ "67194782684826014769909026401363944374553050682034"
41+
+ "96252451749399651431429809190659250937221696461515"
42+
+ "70985838741059788595977297549893016175392846813826"
43+
+ "86838689427741559918559252459539594310499725246808"
44+
+ "45987273644695848653836736222626099124608051243884"
45+
+ "39045124413654976278079771569143599770012961608944"
46+
+ "16948685558484063534220722258284886481584560285060"
47+
+ "16842739452267467678895252138522549954666727823986"
48+
+ "45659611635488623057745649803559363456817432411251"
49+
+ "50760694794510965960940252288797108931456691368672"
50+
+ "28748940560101503308617928680920874760917824938589"
51+
+ "00971490967598526136554978189312978482168299894872"
52+
+ "26588048575640142704775551323796414515237462343645"
53+
+ "42858444795265867821051141354735739523113427166102"
54+
+ "13596953623144295248493718711014576540359027993440"
55+
+ "37420073105785390621983874478084784896833214457138"
56+
+ "68751943506430218453191048481005370614680674919278"
57+
+ "19119793995206141966342875444064374512371819217999"
58+
+ "83910159195618146751426912397489409071864942319615"
59+
+ "67945208095146550225231603881930142093762137855956"
60+
+ "63893778708303906979207734672218256259966150142150"
61+
+ "30680384477345492026054146659252014974428507325186"
62+
+ "66002132434088190710486331734649651453905796268561"
63+
+ "00550810665879699816357473638405257145910289706414"
64+
+ "01109712062804390397595156771577004203378699360072"
65+
+ "30558763176359421873125147120532928191826186125867"
66+
+ "32157919841484882916447060957527069572209175671167"
67+
+ "22910981690915280173506712748583222871835209353965"
68+
+ "72512108357915136988209144421006751033467110314126"
69+
+ "71113699086585163983150197016515116851714376576183"
70+
+ "51556508849099898599823873455283316355076479185358"
71+
+ "93226185489632132933089857064204675259070915481416"
72+
+ "54985946163718027098199430992448895757128289059232"
73+
+ "33260972997120844335732654893823911932597463667305"
74+
+ "83604142813883032038249037589852437441702913276561"
75+
+ "80937734440307074692112019130203303801976211011004"
76+
+ "49293215160842444859637669838952286847831235526582"
77+
+ "13144957685726243344189303968642624341077322697802"
78+
+ "80731891544110104468232527162010526522721116603966"
79+
+ "65573092547110557853763466820653109896526918620564"
80+
+ "76931257058635662018558100729360659876486117910453"
81+
+ "34885034611365768675324944166803962657978771855608"
82+
+ "45529654126654085306143444318586769751456614068007"
83+
+ "00237877659134401712749470420562230538994561314071"
84+
+ "127000407854733269939081454664645880797270826683063432858785698305235808933065757406795457163775254202114955761581400250126228594130216471550979259230"
85+
+ "99079654737612551765675135751782966645477917450112996148903046399471329621073404375189573596145890193897131117904297828564750320319869151402870808599048010941214722131794764777262241425485454033215718530614228813758504306332175182979866223717215916077166925474873898665494945011465406284336639379003976926567214638530673609657120918076383271664162748"
86+
+ "888007869256029022847210403172118608204190004229661711963779213375751149595015660496318629472654736425230817703675159067350235072835405670403867435136222247715891504953098444893330963408780769325993978054193414473774418426312986080998886874132604721";
87+
System.out.println(pi.charAt(Integer.parseInt(line)-1));
88+
}
89+
br.close();
90+
}
91+
}

0 commit comments

Comments
 (0)