├── .clang-format ├── DMOJ ├── acc1p1.cpp ├── acc3p2.cpp ├── acc3p4.cpp ├── ahardergame.cpp ├── apio10p1.cpp ├── apio12p1.cpp ├── apio15p1.cpp ├── apio15p2.cpp ├── apio16p1.cpp ├── aplusb.py ├── aplusb2.cpp ├── banknotes.cpp ├── bbc08g.cpp ├── bf1.py ├── bf1hard.py ├── bf3.cpp ├── bf4hard.cpp ├── bfs17p1.cpp ├── bfs17p2.cpp ├── bfs17p3.cpp ├── boi2007p3.cpp ├── boi2011p5.cpp ├── boolean.py ├── bts16p3.cpp ├── bts17p1.cpp ├── bts17p2.cpp ├── bts17p4.cpp ├── bts18p7.cpp ├── ccc00s4.cpp ├── ccc00s5.cpp ├── ccc01j2.cpp ├── ccc01s4.cpp ├── ccc02s4.cpp ├── ccc03s4.cpp ├── ccc03s5.cpp ├── ccc05s5.cpp ├── ccc07s4.cpp ├── ccc07s5.cpp ├── ccc08s2.cpp ├── ccc08s4.cpp ├── ccc08s5.cpp ├── ccc09s1.cpp ├── ccc09s4.cpp ├── ccc09s5.cpp ├── ccc10j5.py ├── ccc11s5.cpp ├── ccc12s4.cpp ├── ccc12s5.cpp ├── ccc13s3.cpp ├── ccc13s4.cpp ├── ccc13s5.cpp ├── ccc14s4.cpp ├── ccc14s5.cpp ├── ccc15j5.cpp ├── ccc15s3.cpp ├── ccc15s4.cpp ├── ccc16s3.cpp ├── ccc16s4.cpp ├── ccc17s2.cpp ├── ccc18s4.cpp ├── ccc96s4.py ├── ccc96s5.cpp ├── cco00p1.cpp ├── cco05p1.cpp ├── cco05p5.cpp ├── cco07p1.cpp ├── cco07p2.cpp ├── cco07p6.cpp ├── cco08p5.cpp ├── cco10p1.cpp ├── cco10p3.cpp ├── cco10p4.cpp ├── cco10p6.py ├── cco11p2.cpp ├── cco11p4.cpp ├── cco12p2.cpp ├── cco12p5.cpp ├── cco13p2.cpp ├── cco13p3.cpp ├── cco14p1.cpp ├── cco14p4.cpp ├── cco15p2.cpp ├── cco16p5.cpp ├── cco17p1.cpp ├── cco17p3.cpp ├── cco18p1.cpp ├── cco18p2.cpp ├── cco18p4.cpp ├── cco18p5.cpp ├── ccoprep16c2q2.cpp ├── ccoprep16c2q3.cpp ├── ccoprep16c3q2.cpp ├── ccoprep16q1.cpp ├── ccoprep1p3.cpp ├── ccoprep2p1.cpp ├── ccoprep3p2.cpp ├── ccoprep4p3.cpp ├── ccoqr16p1.cpp ├── ccoqr16p3.cpp ├── coci06c1p1.cpp ├── coci06c1p2.cpp ├── coci06c1p4.cpp ├── coci06c1p5.cpp ├── coci06c1p6.cpp ├── coci06c2p1.cpp ├── coci06c2p2.py ├── coci06c2p4.py ├── coci06c2p5.cpp ├── coci06c3p1.cpp ├── coci06c3p2.py ├── coci06c3p3.cpp ├── coci06c3p5.cpp ├── coci06c4p1.cpp ├── coci06c4p2.py ├── coci06c4p3.cpp ├── coci06c4p4.cpp ├── coci06c4p6.cpp ├── coci06c5p1.py ├── coci06c5p2.cpp ├── coci06c5p5.cpp ├── coci06c5p6.cpp ├── coci06c6p5.cpp ├── coci07c1p3.py ├── coci07c1p4.cpp ├── coci07c1p5.cpp ├── coci07c1p6.cpp ├── coci07c2p1.cpp ├── coci07c2p2.py ├── coci07c2p3.py ├── coci07c2p4.cpp ├── coci07c2p6.cpp ├── coci07c3p1.cpp ├── coci07c3p2.cpp ├── coci07c3p4.cpp ├── coci07c3p5.cpp ├── coci07c3p6.cpp ├── coci07c4p1.py ├── coci07c4p2.cpp ├── coci07c4p3.cpp ├── coci07c4p4.cpp ├── coci07c4p5.cpp ├── coci07c5p1.cpp ├── coci07c5p2.cpp ├── coci07c5p3.cpp ├── coci07c5p4.cpp ├── coci07c5p6.cpp ├── coci07c6p3.cpp ├── coci07c6p5.cpp ├── coci08c1p1.cpp ├── coci08c1p6.cpp ├── coci08c2p1.cpp ├── coci08c2p2.cpp ├── coci08c2p3.cpp ├── coci08c2p4.cpp ├── coci08c2p5.py ├── coci08c3p6.cpp ├── coci08c4p1.py ├── coci08c4p4.cpp ├── coci08c5p2.py ├── coci08c5p4.cpp ├── coci08c5p5.cpp ├── coci08c6p1.cpp ├── coci08c6p3.cpp ├── coci08c6p4.cpp ├── coci08c6p5.cpp ├── coci08c6p6.cpp ├── coci09c1p1.py ├── coci09c1p2.py ├── coci13c1p1.cpp ├── coci13c1p2.cpp ├── coci13c1p3.cpp ├── coci13c1p4.cpp ├── coci13c1p5.cpp ├── coci14c1p1.cpp ├── coci14c1p2.cpp ├── coci14c1p3.cpp ├── coci14c1p4.cpp ├── coci14c1p5.cpp ├── coci14c1p6.cpp ├── coci14c2p1.py ├── coci14c2p2.cpp ├── coci14c2p4.cpp ├── coci14c2p5.cpp ├── coci14c2p6.cpp ├── coci14c3p1.py ├── coci14c3p2.cpp ├── coci14c3p3.cpp ├── coci14c3p4.cpp ├── coci14c3p5.cpp ├── coci14c4p1.cpp ├── coci14c4p2.cpp ├── coci14c4p3.cpp ├── coci14c4p4.cpp ├── coci14c4p5.cpp ├── coci14c4p6.cpp ├── coci14c5p1.cpp ├── coci14c5p3.cpp ├── coci14c5p4.py ├── coci14c5p5.cpp ├── coci14c6p1.py ├── coci14c6p2.cpp ├── coci14c6p3.cpp ├── coci14c7p2.cpp ├── coci14c7p3.cpp ├── coci14c7p4.py ├── coci14c7p5.cpp ├── coci15c1p3.cpp ├── coci15c1p5.cpp ├── coci15c2p1.py ├── coci15c2p2.cpp ├── coci15c2p4.cpp ├── coci15c2p5.cpp ├── coci15c2p6.cpp ├── coci15c3p1.cpp ├── coci15c3p3.cpp ├── coci15c3p5.cpp ├── coci15c4p2.cpp ├── coci15c4p3.cpp ├── coci15c4p4.cpp ├── coci15c4p5.cpp ├── coci16c1p1.cpp ├── coci16c1p3.cpp ├── coci17c1p3.cpp ├── coci17c1p5.cpp ├── coci17c2p4.cpp ├── coci17c4p4.cpp ├── coi06p1.cpp ├── coi06p2.cpp ├── coi07p1.cpp ├── coi07p4.cpp ├── crci07p2.cpp ├── crci07p4.cpp ├── ddrp5.cpp ├── ddrp6.cpp ├── det.cpp ├── dmopc13c1p4.cpp ├── dmopc14c1p3.cpp ├── dmopc14c2p2.cpp ├── dmopc14c2p4.cpp ├── dmopc14c2p5.cpp ├── dmopc14c2p6.cpp ├── dmopc14c3p4.cpp ├── dmopc14c4p4.cpp ├── dmopc14c4p6.cpp ├── dmopc15c1p3.cpp ├── dmopc15c1p5.cpp ├── dmopc15c1p6.cpp ├── dmopc15c2p5.cpp ├── dmopc15c2p6.cpp ├── dmopc15c3p4.cpp ├── dmopc15c3p5.cpp ├── dmopc15c4p4.cpp ├── dmopc15c6p5.cpp ├── dmopc15c6p6.cpp ├── dmopc16c2p2.cpp ├── dmopc16c2p5.cpp ├── dmopc16c4p1.cpp ├── dmopc16c4p4.cpp ├── dmopc17c1p4.cpp ├── dmopc17c5p5.cpp ├── dmopc18c4p5.cpp ├── dmpg15b4.cpp ├── dmpg15g3.cpp ├── dmpg15g6.cpp ├── dmpg15s5.cpp ├── dmpg15s6.cpp ├── dmpg16g1.cpp ├── dmpg16g2.cpp ├── dmpg16g6.cpp ├── dmpg16s5.cpp ├── dmpg17g2.cpp ├── dmpg17s1.cpp ├── dmpg17s2.cpp ├── dmpg18g3.cpp ├── dmpg18g6.cpp ├── dmpg18s5.cpp ├── dmpg18s6.cpp ├── dpa.cpp ├── dpb.cpp ├── dpc.cpp ├── dpd.cpp ├── dpe.cpp ├── dpf.cpp ├── dpg.cpp ├── dph.cpp ├── dpi.cpp ├── dpj.cpp ├── dpk.cpp ├── dpl.cpp ├── dpm.cpp ├── dpn.cpp ├── dpo.cpp ├── dpp.cpp ├── dpq.cpp ├── dpr.cpp ├── dps.cpp ├── ds1.cpp ├── ds2.cpp ├── ds3.cpp ├── ds4.cpp ├── expectedvalue.cpp ├── factorial.py ├── fastbit.cpp ├── fhc15c1p2.cpp ├── fibonacci.cpp ├── fibonacci2.cpp ├── gfssoc16s1.py ├── gfssoc16s2.cpp ├── gfssoc1j5.cpp ├── gfssoc1s4.cpp ├── gfssoc2j5.cpp ├── gfssoc3s1.py ├── globexcup18s0.cpp ├── hci16boxes.cpp ├── hci16gifts.cpp ├── hci16penguinfood.cpp ├── hci16police.cpp ├── hci16stacker.cpp ├── hci16totient.cpp ├── hci16xorpow.cpp ├── helloworld.py ├── inaho4.py ├── inaho5.cpp ├── ioi01p1.cpp ├── ioi02p4.cpp ├── ioi05p6.cpp ├── ioi07p4.cpp ├── ioi09p4.cpp ├── ioi10p1.cpp ├── ioi10p3.cpp ├── ioi10p5.cpp ├── ioi10p6.cpp ├── ioi11p2.cpp ├── ioi11p3.cpp ├── ioi12p3.cpp ├── ioi13p1.cpp ├── ioi13p2.cpp ├── ioi13p4.cpp ├── ioi13p5.cpp ├── ioi13p6.cpp ├── ioi14p2.cpp ├── ioi14p3.cpp ├── ioi14p4.cpp ├── ioi15p4.cpp ├── ioi16p1.cpp ├── ioi16p4.cpp ├── ioi16p5.cpp ├── ioi94p1.cpp ├── ioi98p1.cpp ├── ioi98p4.cpp ├── joi13p3.cpp ├── joi14p1.cpp ├── joi14p6.cpp ├── lcs.cpp ├── lkp18c1p4.cpp ├── lkp18c1p6.cpp ├── lkp18c2p5.cpp ├── mcco17p2.cpp ├── mcco17p4.cpp ├── mec16p5.cpp ├── mmcc14p2.cpp ├── mmcc15p1.cpp ├── mnyc17p3.cpp ├── mnyc17p6.cpp ├── modinv.py ├── nccc5s5.cpp ├── ncco2d1p1.cpp ├── ncco2d2p2.cpp ├── ncco2d2p3.cpp ├── ncco3d1p1.cpp ├── ncco3d1p3.cpp ├── ncco3d2p1.cpp ├── ncco4d1p3.cpp ├── next1.cpp ├── odd.cpp ├── phantom3.cpp ├── primefactor.cpp ├── raytracing.cpp ├── set.cpp ├── shortest1.py ├── si17c1p4.cpp ├── si17c1p5.cpp ├── si17c1p8.cpp ├── si17c3p4.cpp ├── si17c3p5.cpp ├── sssp.cpp ├── thicc17p1.cpp ├── thicc17p2.cpp ├── thicc17p3.cpp ├── thicc17p4.cpp ├── thicc17p5.cpp ├── thicc17p6.cpp ├── tle16c1p4.cpp ├── tle16c1p5.cpp ├── tle16c3p5.cpp ├── tle16c7p6.cpp ├── tle16c8p5.cpp ├── tle17c1p1.cpp ├── tle17c1p2.cpp ├── tle17c1p5.cpp ├── tle17c4p5.cpp ├── tsoc15c2p6.cpp ├── tsoc16c2p4.cpp ├── utso15p5.cpp ├── valentines18s3.cpp ├── valentines18s5.cpp ├── vmss7wc15c1p3.cpp ├── vmss7wc15c2p2.cpp ├── vmss7wc15c2p3.cpp ├── vmss7wc15c6p3.cpp ├── vmss7wc16c2p3.cpp ├── waterloow2017d.cpp ├── xor.cpp ├── year2015p5.cpp ├── year2018p1.cpp ├── year2018p2.cpp ├── year2018p3.cpp └── year2018p4.cpp ├── README.md ├── SPOJ ├── ACQUIRE.cpp ├── ADAAPHID.cpp ├── ADAAPPLE.cpp ├── ADABERRY.cpp ├── ADABRANC.cpp ├── ADACABAA.cpp ├── ADACAROT.cpp ├── ADACITY.cpp ├── ADACLEAN.cpp ├── ADACOINS.cpp ├── ADACROP.cpp ├── ADACUT.cpp ├── ADACYCLE.cpp ├── ADADIGIT.cpp ├── ADADUNG.cpp ├── ADAFUROW.cpp ├── ADAGCD.cpp ├── ADAGF.cpp ├── ADAGRAFT.cpp ├── ADAHACK.py ├── ADAINDEX.cpp ├── ADALIST.cpp ├── ADANUM.cpp ├── ADAORANG.cpp ├── ADAPATH.cpp ├── ADAPHOTO.cpp ├── ADAPLANT.cpp ├── ADAPLUS.cpp ├── ADAQUEUE.cpp ├── ADARAIN.cpp ├── ADARAINB.cpp ├── ADAROBOT.cpp ├── ADASEA.cpp ├── ADASEQEN.cpp ├── ADASQR.cpp ├── ADASTRNG.cpp ├── ADATAXES.cpp ├── ADATEAMS.cpp ├── ADATREE.cpp ├── ADATRIP.cpp ├── ADAUNIQ.cpp ├── ADAUSORT.cpp ├── ADAVISIT.cpp ├── AGGRCOW.cpp ├── AKVQLD03.cpp ├── ALIEN.cpp ├── ALL.cpp ├── ANDROUND.cpp ├── APIO10A.cpp ├── AROPE.cpp ├── ARRAYSUB.cpp ├── ASSIST.cpp ├── BDOI16A.cpp ├── BDOI16B.cpp ├── BDOI16C.cpp ├── BDOI16D.cpp ├── BDOI16E.cpp ├── BOI7SOU.cpp ├── BOTTOM.cpp ├── BOYSCOUT.cpp ├── BRCKTS.cpp ├── BTCODE_G.cpp ├── BUGLIFE.cpp ├── BYTESM2.cpp ├── C1LJUTNJ.cpp ├── C1TABOVI.cpp ├── CCOST.cpp ├── CEPC08B.cpp ├── CERC07S.cpp ├── CHICAGO.cpp ├── CLOPPAIR.cpp ├── CNTINDX.cpp ├── CNTINDX2.cpp ├── CNTPRIME.cpp ├── CODESPTB.cpp ├── COMDIV.cpp ├── COT.cpp ├── COT2.cpp ├── CTGAME.cpp ├── CVJETICI.cpp ├── CVXPOLY.cpp ├── DANGER.py ├── DCEPC206.cpp ├── DCEPC501.cpp ├── DCEPCA03.cpp ├── DIFERENC.cpp ├── DISQUERY.cpp ├── DISTANCE.cpp ├── DISUBSTR.cpp ├── DONUT.cpp ├── DQUERY.cpp ├── DYNACON2.cpp ├── EC_P.cpp ├── EDIST.cpp ├── ETF.cpp ├── FACTCG2.cpp ├── FASTFLOW.cpp ├── FIBOSUM.cpp ├── FIBTWIST.cpp ├── FLLM.cpp ├── FREQ2.cpp ├── FREQUENT.cpp ├── GCDEX.cpp ├── GERGOVIA.cpp ├── GIVEAWAY.cpp ├── GOODG.cpp ├── GOT.cpp ├── GRASSPLA.cpp ├── GREED.cpp ├── GROCERY.cpp ├── GSS1.cpp ├── GSS3.cpp ├── GSS4.cpp ├── GSS5.cpp ├── GSS6.cpp ├── GSS7.cpp ├── HALLOW.cpp ├── HEISLAZY.cpp ├── HIKE.cpp ├── HIST2.cpp ├── HISTOGRA.cpp ├── HORRIBLE.cpp ├── HOTELS.cpp ├── HRSIAM.cpp ├── ICAMPSEQ.cpp ├── IITWPC4D.cpp ├── ILKQUERY.cpp ├── ILKQUERY2.cpp ├── ILKQUERYIII.cpp ├── IMPER.cpp ├── INCDSEQ.cpp ├── INCSEQ.cpp ├── INVCNT.cpp ├── IWGBST.cpp ├── JEDNAKOS.cpp ├── KATHTHI.cpp ├── KGSS.cpp ├── KL11B.cpp ├── KOIREP.cpp ├── KPMATRIX.cpp ├── KQUERY.cpp ├── KQUERYO.cpp ├── LASTDIG.py ├── LAWRENCE.cpp ├── LCA.cpp ├── LCMSUM.cpp ├── LIS2.cpp ├── LITE.cpp ├── LKS.cpp ├── LONGCS.cpp ├── LOPOV.cpp ├── MATSUM.cpp ├── MEANARR.cpp ├── METEORS.cpp ├── MIXTURES.cpp ├── MKTHNUM.cpp ├── MON2012.cpp ├── MPOLY.cpp ├── MTREE.cpp ├── MULTQ3.cpp ├── MUSKET.cpp ├── NAGAY1.cpp ├── NFACTOR.cpp ├── NICEDAY.cpp ├── NTICKETS.cpp ├── OPCPIZZA.cpp ├── ORDERS.cpp ├── ORDERSET.cpp ├── OTOCI.cpp ├── PATULJCI.cpp ├── PERFUME.cpp ├── PERMUT2.cpp ├── PHONELST.cpp ├── POLQUERY.cpp ├── POSTERS.cpp ├── PRIME1.cpp ├── PRINT.cpp ├── PT07J.cpp ├── PT07X.cpp ├── PT07Y.cpp ├── PT07Z.cpp ├── QMAX3VN.cpp ├── QTREE.cpp ├── QTREE2.cpp ├── QTREE3.cpp ├── QTREE4.cpp ├── QTREE5.cpp ├── QTREE6.cpp ├── QTREE7.cpp ├── QUE1.cpp ├── QUE2.cpp ├── RACETIME.cpp ├── RANGESUM.cpp ├── RIOI_2_3.cpp ├── RMID.cpp ├── RMID2.cpp ├── RPLN.cpp ├── SABBIRGAME.cpp ├── SALMAN.cpp ├── SCUBADIV.cpp ├── SEGSQRSS.cpp ├── SEQ.cpp ├── SEQ2.cpp ├── SGIFT.cpp ├── SLIKAR.cpp ├── SPP.cpp ├── SUBMERGE.cpp ├── SUBSET.cpp ├── SUBST1.cpp ├── SUBSUMS.cpp ├── SUBXOR.cpp ├── SUMFOUR.cpp ├── SUPPER.cpp ├── SWERC14B.cpp ├── SWERC14D.cpp ├── SWERC14J.cpp ├── TAP2012A.cpp ├── TAP2012B.cpp ├── TAP2013C.cpp ├── TAP2013D.cpp ├── TAP2013G.cpp ├── TAP2013H.cpp ├── TAP2013I.cpp ├── TAP2014B.cpp ├── TAP2014E.cpp ├── TAP2014G.cpp ├── TAP2014J.cpp ├── TAP2015D.cpp ├── TAP2015F.cpp ├── TAP2015H.cpp ├── TAP2016C.cpp ├── TDPRIMES.cpp ├── TEST.cpp ├── TFRIENDS.cpp ├── TTM.cpp ├── TWIST.cpp ├── TWOPATHS.cpp ├── UCBINTC.cpp ├── ULM09.cpp ├── UPDATEIT.cpp ├── VOCV.cpp ├── WACHOVIA.cpp ├── WATER.cpp ├── WILD.cpp ├── YODANESS.cpp └── ZQUERY.cpp └── beecrowd ├── 1001.cpp ├── 1002.cpp ├── 1003.cpp ├── 1004.cpp ├── 1005.cpp ├── 1006.cpp ├── 1007.cpp ├── 1008.cpp ├── 1009.cpp ├── 1010.cpp ├── 1011.cpp ├── 1012.cpp ├── 1013.cpp ├── 1014.py ├── 1015.py ├── 1016.py ├── 1017.py ├── 1018.py ├── 1019.py ├── 1020.py ├── 1021.cpp ├── 1022.cpp ├── 1023.cpp ├── 1024.cpp ├── 1025.cpp ├── 1026.cpp ├── 1028.cpp ├── 1029.cpp ├── 1030.cpp ├── 1031.cpp ├── 1032.cpp ├── 1033.cpp ├── 1034.cpp ├── 1035.cpp ├── 1036.py ├── 1037.cpp ├── 1038.cpp ├── 1039.cpp ├── 1040.cpp ├── 1041.cpp ├── 1042.py ├── 1043.py ├── 1044.cpp ├── 1045.py ├── 1046.py ├── 1047.py ├── 1048.py ├── 1049.py ├── 1050.py ├── 1051.py ├── 1052.py ├── 1056.cpp ├── 1057.cpp ├── 1059.py ├── 1060.py ├── 1061.py ├── 1062.cpp ├── 1063.cpp ├── 1064.py ├── 1065.py ├── 1066.py ├── 1067.py ├── 1068.cpp ├── 1069.cpp ├── 1070.py ├── 1071.py ├── 1072.py ├── 1073.py ├── 1074.py ├── 1075.py ├── 1076.py ├── 1077.py ├── 1078.py ├── 1079.cpp ├── 1080.cpp ├── 1081.cpp ├── 1082.py ├── 1084.cpp ├── 1085.cpp ├── 1087.py ├── 1088.cpp ├── 1089.cpp ├── 1091.py ├── 1092.cpp ├── 1094.py ├── 1095.py ├── 1096.py ├── 1097.py ├── 1098.py ├── 1099.cpp ├── 1100.py ├── 1101.py ├── 1103.py ├── 1104.cpp ├── 1105.cpp ├── 1107.cpp ├── 1110.cpp ├── 1112.cpp ├── 1113.cpp ├── 1114.cpp ├── 1115.py ├── 1116.py ├── 1117.py ├── 1118.py ├── 1122.cpp ├── 1123.cpp ├── 1128.cpp ├── 1129.py ├── 1131.py ├── 1132.py ├── 1133.py ├── 1134.py ├── 1135.cpp ├── 1136.cpp ├── 1137.cpp ├── 1138.cpp ├── 1140.py ├── 1142.py ├── 1143.py ├── 1144.py ├── 1145.py ├── 1146.py ├── 1148.cpp ├── 1149.cpp ├── 1150.cpp ├── 1151.py ├── 1152.cpp ├── 1153.py ├── 1154.py ├── 1155.py ├── 1156.py ├── 1157.py ├── 1158.py ├── 1159.cpp ├── 1161.py ├── 1162.cpp ├── 1164.py ├── 1165.py ├── 1168.cpp ├── 1169.cpp ├── 1170.py ├── 1171.py ├── 1172.cpp ├── 1173.py ├── 1174.py ├── 1175.cpp ├── 1176.py ├── 1177.cpp ├── 1178.cpp ├── 1179.cpp ├── 1180.cpp ├── 1181.py ├── 1182.py ├── 1183.py ├── 1184.py ├── 1185.py ├── 1186.py ├── 1187.py ├── 1188.py ├── 1189.py ├── 1190.py ├── 1192.cpp ├── 1193.py ├── 1195.cpp ├── 1197.py ├── 1198.py ├── 1199.py ├── 1200.cpp ├── 1202.cpp ├── 1203.cpp ├── 1205.cpp ├── 1206.cpp ├── 1208.cpp ├── 1209.cpp ├── 1211.cpp ├── 1212.py ├── 1213.cpp ├── 1214.py ├── 1215.py ├── 1216.py ├── 1219.py ├── 1221.py ├── 1222.py ├── 1224.cpp ├── 1225.cpp ├── 1226.cpp ├── 1227.cpp ├── 1233.cpp ├── 1234.cpp ├── 1237.py ├── 1240.py ├── 1241.py ├── 1244.cpp ├── 1245.cpp ├── 1247.py ├── 1248.py ├── 1249.py ├── 1251.cpp ├── 1252.cpp ├── 1253.cpp ├── 1256.py ├── 1258.py ├── 1259.py ├── 1260.py ├── 1261.py ├── 1267.cpp ├── 1269.cpp ├── 1273.py ├── 1274.cpp ├── 1277.py ├── 1278.py ├── 1279.py ├── 1281.py ├── 1282.cpp ├── 1284.cpp ├── 1285.cpp ├── 1286.cpp ├── 1288.cpp ├── 1295.cpp ├── 1296.cpp ├── 1299.cpp ├── 1300.cpp ├── 1301.cpp ├── 1302.cpp ├── 1303.cpp ├── 1307.py ├── 1308.py ├── 1309.py ├── 1310.cpp ├── 1313.cpp ├── 1314.cpp ├── 1316.cpp ├── 1317.cpp ├── 1321.cpp ├── 1323.cpp ├── 1328.cpp ├── 1329.py ├── 1330.cpp ├── 1332.py ├── 1338.cpp ├── 1340.cpp ├── 1343.cpp ├── 1344.cpp ├── 1348.cpp ├── 1350.cpp ├── 1356.cpp ├── 1362.cpp ├── 1365.cpp ├── 1366.cpp ├── 1371.cpp ├── 1372.cpp ├── 1374.py ├── 1375.cpp ├── 1376.cpp ├── 1378.cpp ├── 1381.cpp ├── 1382.cpp ├── 1383.py ├── 1384.cpp ├── 1387.py ├── 1391.cpp ├── 1393.cpp ├── 1397.cpp ├── 1398.py ├── 1401.cpp ├── 1409.cpp ├── 1413.cpp ├── 1418.cpp ├── 1423.cpp ├── 1424.cpp ├── 1427.py ├── 1429.cpp ├── 1430.py ├── 1431.cpp ├── 1436.py ├── 1437.cpp ├── 1439.cpp ├── 1441.cpp ├── 1442.cpp ├── 1447.cpp ├── 1448.py ├── 1449.py ├── 1450.cpp ├── 1452.py ├── 1454.cpp ├── 1455.cpp ├── 1457.py ├── 1458.cpp ├── 1460.cpp ├── 1462.cpp ├── 1464.cpp ├── 1466.cpp ├── 1467.py ├── 1469.cpp ├── 1471.cpp ├── 1474.cpp ├── 1476.cpp ├── 1477.cpp ├── 1479.cpp ├── 1482.cpp ├── 1483.cpp ├── 1486.cpp ├── 1487.cpp ├── 1488.cpp ├── 1490.cpp ├── 1492.cpp ├── 1493.cpp ├── 1495.cpp ├── 1499.cpp ├── 1500.cpp ├── 1501.cpp ├── 1511.cpp ├── 1512.cpp ├── 1513.cpp ├── 1514.cpp ├── 1517.cpp ├── 1522.cpp ├── 1525.cpp ├── 1527.cpp ├── 1529.cpp ├── 1531.cpp ├── 1533.cpp ├── 1539.cpp ├── 1540.py ├── 1544.cpp ├── 1545.cpp ├── 1546.py ├── 1547.py ├── 1548.cpp ├── 1549.cpp ├── 1550.cpp ├── 1551.py ├── 1552.cpp ├── 1553.py ├── 1554.cpp ├── 1555.py ├── 1556.cpp ├── 1558.cpp ├── 1560.cpp ├── 1564.py ├── 1566.cpp ├── 1578.cpp ├── 1579.cpp ├── 1580.py ├── 1581.py ├── 1582.py ├── 1583.cpp ├── 1584.cpp ├── 1585.py ├── 1589.py ├── 1590.cpp ├── 1592.cpp ├── 1593.py ├── 1594.cpp ├── 1595.cpp ├── 1599.cpp ├── 1600.cpp ├── 1602.cpp ├── 1604.cpp ├── 1606.cpp ├── 1607.cpp ├── 1609.cpp ├── 1610.cpp ├── 1611.cpp ├── 1616.cpp ├── 1617.cpp ├── 1620.py ├── 1621.cpp ├── 1631.cpp ├── 1640.cpp ├── 1641.cpp ├── 1643.cpp ├── 1645.cpp ├── 1654.cpp ├── 1655.cpp ├── 1656.cpp ├── 1661.cpp ├── 1663.cpp ├── 1669.cpp ├── 1672.py ├── 1676.cpp ├── 1677.cpp ├── 1683.cpp ├── 1687.cpp ├── 1688.cpp ├── 1690.cpp ├── 1692.cpp ├── 1706.cpp ├── 1713.cpp ├── 1716.cpp ├── 1724.cpp ├── 1728.py ├── 1738.cpp ├── 1739.py ├── 1743.cpp ├── 1744.cpp ├── 1745.cpp ├── 1749.cpp ├── 1750.cpp ├── 1751.cpp ├── 1752.cpp ├── 1757.cpp ├── 1759.py ├── 1763.cpp ├── 1764.cpp ├── 1766.cpp ├── 1773.cpp ├── 1774.cpp ├── 1776.cpp ├── 1777.cpp ├── 1778.cpp ├── 1782.cpp ├── 1789.py ├── 1790.cpp ├── 1792.cpp ├── 1794.py ├── 1795.cpp ├── 1796.py ├── 1798.cpp ├── 1799.py ├── 1800.py ├── 1801.cpp ├── 1802.py ├── 1803.py ├── 1804.cpp ├── 1805.py ├── 1806.cpp ├── 1807.cpp ├── 1808.cpp ├── 1809.cpp ├── 1810.cpp ├── 1813.cpp ├── 1816.py ├── 1820.cpp ├── 1821.cpp ├── 1822.cpp ├── 1829.cpp ├── 1835.cpp ├── 1837.cpp ├── 1838.cpp ├── 1841.cpp ├── 1850.cpp ├── 1854.cpp ├── 1856.cpp ├── 1860.cpp ├── 1861.cpp ├── 1862.cpp ├── 1865.py ├── 1866.py ├── 1867.py ├── 1869.py ├── 1871.py ├── 1873.py ├── 1875.py ├── 1880.cpp ├── 1883.cpp ├── 1884.cpp ├── 1887.cpp ├── 1890.cpp ├── 1891.cpp ├── 1893.cpp ├── 1895.py ├── 1896.cpp ├── 1897.cpp ├── 1900.cpp ├── 1901.py ├── 1902.cpp ├── 1903.cpp ├── 1905.cpp ├── 1907.cpp ├── 1908.cpp ├── 1910.cpp ├── 1911.cpp ├── 1912.cpp ├── 1914.py ├── 1921.py ├── 1924.py ├── 1926.cpp ├── 1927.cpp ├── 1928.cpp ├── 1929.py ├── 1930.py ├── 1931.cpp ├── 1933.py ├── 1936.cpp ├── 1938.cpp ├── 1940.cpp ├── 1943.py ├── 1944.cpp ├── 1947.cpp ├── 1952.cpp ├── 1955.cpp ├── 1956.cpp ├── 1957.py ├── 1958.py ├── 1959.py ├── 1960.py ├── 1961.py ├── 1963.py ├── 1969.cpp ├── 1970.cpp ├── 1972.cpp ├── 1979.py ├── 1980.cpp ├── 1982.cpp ├── 1983.py ├── 1984.cpp ├── 1985.py ├── 1987.cpp ├── 1993.cpp ├── 1994.cpp ├── 1998.cpp ├── 1999.cpp ├── 2001.cpp ├── 2002.cpp ├── 2003.py ├── 2006.py ├── 2008.cpp ├── 2010.cpp ├── 2011.cpp ├── 2014.cpp ├── 2023.cpp ├── 2026.cpp ├── 2028.py ├── 2029.py ├── 2031.py ├── 2032.cpp ├── 2044.cpp ├── 2046.cpp ├── 2047.cpp ├── 2048.cpp ├── 2049.py ├── 2056.cpp ├── 2057.py ├── 2058.py ├── 2059.py ├── 2060.py ├── 2061.py ├── 2062.py ├── 2063.cpp ├── 2064.cpp ├── 2065.cpp ├── 2067.cpp ├── 2069.cpp ├── 2071.cpp ├── 2072.cpp ├── 2073.cpp ├── 2077.cpp ├── 2078.cpp ├── 2079.cpp ├── 2080.cpp ├── 2081.cpp ├── 2084.cpp ├── 2085.cpp ├── 2086.cpp ├── 2087.cpp ├── 2088.cpp ├── 2089.cpp ├── 2091.cpp ├── 2092.cpp ├── 2095.cpp ├── 2096.cpp ├── 2098.cpp ├── 2100.cpp ├── 2102.cpp ├── 2103.cpp ├── 2106.cpp ├── 2107.cpp ├── 2108.py ├── 2111.cpp ├── 2115.cpp ├── 2116.cpp ├── 2122.cpp ├── 2123.cpp ├── 2124.cpp ├── 2126.py ├── 2127.cpp ├── 2129.cpp ├── 2130.cpp ├── 2131.cpp ├── 2133.cpp ├── 2134.py ├── 2135.cpp ├── 2138.cpp ├── 2140.cpp ├── 2146.cpp ├── 2147.py ├── 2149.cpp ├── 2152.py ├── 2153.py ├── 2155.cpp ├── 2157.py ├── 2158.py ├── 2159.py ├── 2160.py ├── 2164.cpp ├── 2165.py ├── 2167.cpp ├── 2173.cpp ├── 2174.cpp ├── 2175.cpp ├── 2176.cpp ├── 2177.cpp ├── 2178.cpp ├── 2180.cpp ├── 2182.cpp ├── 2183.cpp ├── 2184.cpp ├── 2185.cpp ├── 2186.cpp ├── 2187.cpp ├── 2188.cpp ├── 2189.cpp ├── 2190.cpp ├── 2191.cpp ├── 2217.cpp ├── 2222.cpp ├── 2223.cpp ├── 2224.cpp ├── 2227.cpp ├── 2228.cpp ├── 2229.cpp ├── 2230.cpp ├── 2231.cpp ├── 2232.cpp ├── 2234.cpp ├── 2235.cpp ├── 2238.cpp ├── 2242.cpp ├── 2243.cpp ├── 2246.cpp ├── 2247.cpp ├── 2248.cpp ├── 2249.cpp ├── 2250.cpp ├── 2251.cpp ├── 2285.cpp ├── 2286.cpp ├── 2287.cpp ├── 2288.cpp ├── 2290.cpp ├── 2291.cpp ├── 2293.cpp ├── 2294.cpp ├── 2295.cpp ├── 2296.cpp ├── 2297.cpp ├── 2298.cpp ├── 2299.cpp ├── 2300.cpp ├── 2301.cpp ├── 2303.cpp ├── 2304.cpp ├── 2305.cpp ├── 2308.cpp ├── 2309.cpp ├── 2316.cpp ├── 2317.cpp ├── 2318.cpp ├── 2319.cpp ├── 2321.cpp ├── 2322.cpp ├── 2323.cpp ├── 2325.cpp ├── 2326.cpp ├── 2327.cpp ├── 2328.cpp ├── 2329.cpp ├── 2330.cpp ├── 2331.cpp ├── 2332.cpp ├── 2333.cpp ├── 2337.cpp ├── 2339.cpp ├── 2340.cpp ├── 2341.cpp ├── 2342.cpp ├── 2343.cpp ├── 2344.cpp ├── 2345.cpp ├── 2346.cpp ├── 2349.cpp ├── 2353.cpp ├── 2357.cpp ├── 2359.cpp ├── 2366.cpp ├── 2367.cpp ├── 2368.cpp ├── 2369.cpp ├── 2370.cpp ├── 2371.cpp ├── 2372.cpp ├── 2373.cpp ├── 2374.cpp ├── 2375.cpp ├── 2376.cpp ├── 2377.cpp ├── 2378.cpp ├── 2380.cpp ├── 2381.cpp ├── 2382.cpp ├── 2383.cpp ├── 2384.cpp ├── 2385.cpp ├── 2386.cpp ├── 2387.cpp ├── 2388.cpp ├── 2389.cpp ├── 2390.cpp ├── 2391.cpp ├── 2392.cpp ├── 2393.cpp ├── 2394.cpp ├── 2395.cpp ├── 2396.cpp ├── 2397.cpp ├── 2398.cpp ├── 2399.cpp ├── 2400.cpp ├── 2401.cpp ├── 2402.cpp ├── 2403.cpp ├── 2404.cpp ├── 2405.cpp ├── 2406.cpp ├── 2407.cpp ├── 2408.cpp ├── 2409.cpp ├── 2410.cpp ├── 2411.cpp ├── 2412.cpp ├── 2413.cpp ├── 2414.cpp ├── 2415.cpp ├── 2416.cpp ├── 2417.cpp ├── 2418.cpp ├── 2419.cpp ├── 2420.cpp ├── 2421.cpp ├── 2422.cpp ├── 2423.cpp ├── 2424.cpp ├── 2425.cpp ├── 2426.cpp ├── 2427.cpp ├── 2428.cpp ├── 2429.cpp ├── 2430.cpp ├── 2432.cpp ├── 2433.cpp ├── 2434.cpp ├── 2435.cpp ├── 2436.cpp ├── 2437.cpp ├── 2438.cpp ├── 2439.cpp ├── 2440.cpp ├── 2441.cpp ├── 2442.cpp ├── 2443.cpp ├── 2444.cpp ├── 2445.cpp ├── 2446.cpp ├── 2448.cpp ├── 2449.cpp ├── 2450.cpp ├── 2451.cpp ├── 2452.cpp ├── 2453.cpp ├── 2454.cpp ├── 2455.cpp ├── 2456.cpp ├── 2457.cpp ├── 2458.cpp ├── 2459.cpp ├── 2460.cpp ├── 2461.cpp ├── 2462.cpp ├── 2463.cpp ├── 2464.cpp ├── 2465.cpp ├── 2467.cpp ├── 2468.cpp ├── 2469.cpp ├── 2470.cpp ├── 2471.cpp ├── 2472.cpp ├── 2473.cpp ├── 2475.cpp ├── 2476.cpp ├── 2478.cpp ├── 2479.cpp ├── 2481.cpp ├── 2482.py ├── 2483.py ├── 2514.cpp ├── 2519.cpp ├── 2520.cpp ├── 2522.cpp ├── 2524.cpp ├── 2526.cpp ├── 2527.cpp ├── 2528.cpp ├── 2529.cpp ├── 2531.cpp ├── 2532.cpp ├── 2537.cpp ├── 2538.cpp ├── 2539.cpp ├── 2541.cpp ├── 2545.cpp ├── 2546.cpp ├── 2550.cpp ├── 2553.cpp ├── 2555.cpp ├── 2558.cpp ├── 2560.cpp ├── 2561.cpp ├── 2562.cpp ├── 2563.cpp ├── 2565.cpp ├── 2566.cpp ├── 2567.cpp ├── 2570.cpp ├── 2576.cpp ├── 2651.py ├── 2652.cpp ├── 2653.cpp ├── 2655.cpp ├── 2656.cpp ├── 2658.cpp ├── 2661.cpp ├── 2663.cpp ├── 2664.cpp ├── 2665.cpp ├── 2666.cpp ├── 2667.cpp ├── 2670.cpp ├── 2679.py ├── 2680.cpp ├── 2681.py ├── 2683.cpp ├── 2700.cpp ├── 2702.py ├── 2703.cpp ├── 2716.cpp ├── 2723.cpp ├── 2779.py ├── 2780.py ├── 2781.cpp ├── 2782.py ├── 2783.py ├── 2784.py ├── 2785.cpp ├── 2786.py ├── 2787.py ├── 2878.cpp ├── 2879.cpp ├── 2880.cpp ├── 2881.cpp ├── 2882.cpp └── 2884.cpp /DMOJ/aplusb.py: -------------------------------------------------------------------------------- 1 | # Ivan Carvalho 2 | # Solution to https://dmoj.ca/problem/aplusb 3 | import sys 4 | 5 | raw_input = sys.stdin.readline 6 | tc = int(input()) 7 | while tc: 8 | tc -= 1 9 | a, b = [int(i) for i in input().split()] 10 | print(a + b) 11 | -------------------------------------------------------------------------------- /DMOJ/bf1.py: -------------------------------------------------------------------------------- 1 | # Ivan Carvalho 2 | # Solution to https://dmoj.ca/problem/bf1 3 | #!/usr/bin/env python 4 | # -*- coding : utf-8 -*- 5 | a = int(input()) 6 | v = [] 7 | for i in range(a): 8 | j = int(input()) 9 | v.append(j) 10 | v.sort() 11 | for i in v: 12 | print(i) 13 | -------------------------------------------------------------------------------- /DMOJ/bf1hard.py: -------------------------------------------------------------------------------- 1 | # Ivan Carvalho 2 | # Solution to https://dmoj.ca/problem/bf1hard 3 | #!/usr/bin/env python 4 | # -*- coding : utf-8 -*- 5 | from sys import stdin 6 | 7 | raw_input = stdin.readline 8 | a = int(input()) 9 | v = [] 10 | for i in range(a): 11 | j = int(input()) 12 | v.append(j) 13 | v.sort() 14 | for i in v: 15 | print(i) 16 | -------------------------------------------------------------------------------- /DMOJ/bfs17p1.cpp: -------------------------------------------------------------------------------- 1 | // Ivan Carvalho 2 | // Solution to https://dmoj.ca/problem/bfs17p1 3 | #include 4 | using namespace std; 5 | int main() { 6 | cin.tie(0); 7 | cout.tie(0); 8 | ios_base::sync_with_stdio(0); 9 | multiset resp; 10 | int n; 11 | cin >> n; 12 | string s; 13 | while (n--) { 14 | cin >> s; 15 | if (s.size() <= 10) resp.insert(s); 16 | } 17 | cout << resp.size() << endl; 18 | return 0; 19 | } -------------------------------------------------------------------------------- /DMOJ/boolean.py: -------------------------------------------------------------------------------- 1 | # Ivan Carvalho 2 | # Solution to https://dmoj.ca/problem/boolean 3 | #!/usr/bin/env python 4 | # -*- coding : utf-8 -*- 5 | a = input() 6 | print(eval(a)) 7 | -------------------------------------------------------------------------------- /DMOJ/bts17p1.cpp: -------------------------------------------------------------------------------- 1 | // Ivan Carvalho 2 | // Solution to https://dmoj.ca/problem/bts17p1 3 | #include 4 | using namespace std; 5 | int main() { 6 | int flag = 0; 7 | string s; 8 | while (cin >> s) { 9 | if ('A' <= s[0] && s[0] <= 'Z' && flag) 10 | cout << ". "; 11 | else if (flag) { 12 | cout << " "; 13 | } else { 14 | flag = 1; 15 | } 16 | cout << s; 17 | } 18 | cout << "." << endl; 19 | return 0; 20 | } -------------------------------------------------------------------------------- /DMOJ/bts17p2.cpp: -------------------------------------------------------------------------------- 1 | // Ivan Carvalho 2 | // Solution to https://dmoj.ca/problem/bts17p2 3 | #include 4 | using namespace std; 5 | int main() { 6 | double resp = 1.0; 7 | int n; 8 | scanf("%d", &n); 9 | while (n--) { 10 | int e, g; 11 | scanf("%d %d", &e, &g); 12 | double fator = (g - e) / double(g); 13 | resp *= fator; 14 | } 15 | printf("%.6lf\n", resp); 16 | return 0; 17 | } -------------------------------------------------------------------------------- /DMOJ/ccc01j2.cpp: -------------------------------------------------------------------------------- 1 | // Ivan Carvalho 2 | // Solution to https://dmoj.ca/problem/ccc01j2 3 | #include 4 | int main() { 5 | int x, m; 6 | scanf("%d %d", &x, &m); 7 | for (int i = 1; i < m; i++) { 8 | if ((x * i) % m == 1) { 9 | printf("%d\n", i); 10 | return 0; 11 | } 12 | } 13 | printf("No such integer exists.\n"); 14 | return 0; 15 | } -------------------------------------------------------------------------------- /DMOJ/ccc08s2.cpp: -------------------------------------------------------------------------------- 1 | // Ivan Carvalho 2 | // Solution to https://dmoj.ca/problem/ccc08s2 3 | #include 4 | #include 5 | #include 6 | using namespace std; 7 | int main() { 8 | int r; 9 | while (scanf("%d", &r) && r) { 10 | int resp = 0; 11 | for (int x = -r; x <= r; x++) { 12 | int delta = abs(x); 13 | double resta = sqrt(r * r - delta * delta); 14 | int y1 = (int)ceil(-resta); 15 | int y2 = (int)floor(resta); 16 | resp += y2 - y1 + 1; 17 | } 18 | printf("%d\n", resp); 19 | } 20 | return 0; 21 | } -------------------------------------------------------------------------------- /DMOJ/ccc09s1.cpp: -------------------------------------------------------------------------------- 1 | // Ivan Carvalho 2 | // Solution to https://dmoj.ca/problem/ccc09s1 3 | #include 4 | inline int pow(int a) { return a * a * a * a * a * a; } 5 | int main() { 6 | int a, b; 7 | scanf("%d %d", &a, &b); 8 | int resp = 0; 9 | for (int i = 1; i <= 23; i++) { 10 | if (pow(i) >= a && pow(i) <= b) resp++; 11 | } 12 | printf("%d\n", resp); 13 | return 0; 14 | } -------------------------------------------------------------------------------- /DMOJ/ccc15s3.cpp: -------------------------------------------------------------------------------- 1 | // Ivan Carvalho 2 | // Solution to https://dmoj.ca/problem/ccc15s3 3 | #include 4 | #include 5 | using namespace std; 6 | set aero; 7 | int main() { 8 | int n, g; 9 | scanf("%d %d", &g, &n); 10 | for (int i = 1; i <= g; i++) aero.insert(i); 11 | int resp = 0; 12 | while (n--) { 13 | int davez; 14 | scanf("%d", &davez); 15 | if ((*aero.begin()) > davez) { 16 | break; 17 | } 18 | set::iterator it = prev(aero.upper_bound(davez)); 19 | resp++; 20 | aero.erase(it); 21 | } 22 | printf("%d\n", resp); 23 | return 0; 24 | } -------------------------------------------------------------------------------- /DMOJ/coci06c1p1.cpp: -------------------------------------------------------------------------------- 1 | // Ivan Carvalho 2 | // Solution to https://dmoj.ca/problem/coci06c1p1 3 | #include 4 | #include 5 | using namespace std; 6 | int main() { 7 | set conjunto; 8 | for (int i = 1; i <= 10; i++) { 9 | int davez; 10 | scanf("%d", &davez); 11 | conjunto.insert(davez % 42); 12 | } 13 | printf("%d\n", (int)conjunto.size()); 14 | return 0; 15 | } -------------------------------------------------------------------------------- /DMOJ/coci06c1p2.cpp: -------------------------------------------------------------------------------- 1 | // Ivan Carvalho 2 | // Solution to https://dmoj.ca/problem/coci06c1p2 3 | #include 4 | #include 5 | #define PI acos(-1.0) 6 | int main() { 7 | double a; 8 | scanf("%lf", &a); 9 | printf("%.6lf\n", a * a * PI); 10 | printf("%.6lf\n", a * a * 2); 11 | return 0; 12 | } -------------------------------------------------------------------------------- /DMOJ/coci06c2p1.cpp: -------------------------------------------------------------------------------- 1 | // Ivan Carvalho 2 | // Solution to https://dmoj.ca/problem/coci06c2p1 3 | #include 4 | int main() { 5 | int s, r; 6 | scanf("%d %d", &r, &s); 7 | printf("%d\n", 2 * s - r); 8 | return 0; 9 | } -------------------------------------------------------------------------------- /DMOJ/coci06c2p2.py: -------------------------------------------------------------------------------- 1 | # Ivan Carvalho 2 | # Solution to https://dmoj.ca/problem/coci06c2p2 3 | dicio = dict(list(zip(["A", "B", "C"], sorted([int(i) for i in input().split()])))) 4 | lista = [str(dicio[i]) for i in eval(input())] 5 | print((" ".join(lista))) 6 | -------------------------------------------------------------------------------- /DMOJ/coci06c2p4.py: -------------------------------------------------------------------------------- 1 | # Ivan Carvalho 2 | # Solution to https://dmoj.ca/problem/coci06c2p4 3 | 4 | N = int(eval(input())) 5 | ans = 0 6 | 7 | for i in range(1, N + 1): 8 | for j in range(i + 2, N + 1): 9 | a = j - i - 1 10 | b = N - a - 2 11 | ans += a * b 12 | 13 | print((ans // 2)) 14 | -------------------------------------------------------------------------------- /DMOJ/coci06c4p1.cpp: -------------------------------------------------------------------------------- 1 | // Ivan Carvalho 2 | // Solution to https://dmoj.ca/problem/coci06c4p1 3 | #include 4 | int main() { 5 | int n, a, b; 6 | scanf("%d %d %d", &n, &a, &b); 7 | while (n--) { 8 | int c; 9 | scanf("%d", &c); 10 | if (c * c <= a * a + b * b) 11 | printf("DA\n"); 12 | else 13 | printf("NE\n"); 14 | } 15 | return 0; 16 | } -------------------------------------------------------------------------------- /DMOJ/coci06c4p2.py: -------------------------------------------------------------------------------- 1 | # Ivan Carvalho 2 | # Solution to https://dmoj.ca/problem/coci06c4p2 3 | a, b, c, d = [int(i) for i in input().split()] 4 | 5 | for linha in range(a): 6 | entrada = [i * d for i in eval(input())] 7 | for i in range(c): 8 | print(("".join(entrada))) 9 | -------------------------------------------------------------------------------- /DMOJ/coci06c4p3.cpp: -------------------------------------------------------------------------------- 1 | // Ivan Carvalho 2 | // Solution to https://dmoj.ca/problem/coci06c4p3 3 | #include 4 | using namespace std; 5 | int main() { 6 | int n, v; 7 | cin >> n >> v; 8 | n--; 9 | while (n--) { 10 | int u; 11 | cin >> u; 12 | int mdc = __gcd(u, v); 13 | cout << v / mdc << "/" << u / mdc << endl; 14 | } 15 | return 0; 16 | } -------------------------------------------------------------------------------- /DMOJ/coci06c5p1.py: -------------------------------------------------------------------------------- 1 | # Ivan Carvalho 2 | # Solution to https://dmoj.ca/problem/coci06c5p1 3 | lista = [1, 0, 0] 4 | 5 | entrada = eval(input()) 6 | 7 | for i in entrada: 8 | if i == "A": 9 | lista[0], lista[1] = lista[1], lista[0] 10 | elif i == "B": 11 | lista[1], lista[2] = lista[2], lista[1] 12 | else: 13 | lista[0], lista[2] = lista[2], lista[0] 14 | 15 | if lista[0] == 1: 16 | print((1)) 17 | elif lista[1] == 1: 18 | print((2)) 19 | else: 20 | print((3)) 21 | -------------------------------------------------------------------------------- /DMOJ/coci07c2p1.cpp: -------------------------------------------------------------------------------- 1 | // Ivan Carvalho 2 | // Solution to https://dmoj.ca/problem/coci07c2p1 3 | #include 4 | #include 5 | int main() { 6 | int a, b, c, d, e, f; 7 | scanf("%d %d %d %d %d %d", &a, &b, &c, &d, &e, &f); 8 | printf("%d %d %d %d %d %d\n", 1 - a, 1 - b, 2 - c, 2 - d, 2 - e, 8 - f); 9 | return 0; 10 | } -------------------------------------------------------------------------------- /DMOJ/coci07c2p2.py: -------------------------------------------------------------------------------- 1 | # Ivan Carvalho 2 | # Solution to https://dmoj.ca/problem/coci07c2p2 3 | melhor = 1 4 | n = int(eval(input())) 5 | 6 | for a in range(n + 1): 7 | b = n - a 8 | melhor = max(melhor, (a + 1) * (b + 1)) 9 | 10 | print(melhor) 11 | -------------------------------------------------------------------------------- /DMOJ/coci07c3p2.cpp: -------------------------------------------------------------------------------- 1 | // Ivan Carvalho 2 | // Solution to https://dmoj.ca/problem/coci07c3p2 3 | print oct(int(raw_input(), 2))[1:].replace("L", "") -------------------------------------------------------------------------------- /DMOJ/coci07c4p1.py: -------------------------------------------------------------------------------- 1 | # Ivan Carvalho 2 | # Solution to https://dmoj.ca/problem/coci07c4p1 3 | 4 | 5 | def simulate(x, y, z): 6 | while True: 7 | x -= y 8 | if x <= 0: 9 | return 1 10 | x -= z 11 | if x <= 0: 12 | return 0 13 | 14 | 15 | a, b, c, d = [int(i) for i in input().split()] 16 | times = [int(i) for i in input().split()] 17 | 18 | for t in times: 19 | print((["none", "one", "both"][simulate(t, a, b) + simulate(t, c, d)])) 20 | -------------------------------------------------------------------------------- /DMOJ/coci07c4p2.cpp: -------------------------------------------------------------------------------- 1 | // Ivan Carvalho 2 | // Solution to https://dmoj.ca/problem/coci07c4p2 3 | #include 4 | using namespace std; 5 | int main() { 6 | char c; 7 | vector novo, velho; 8 | while (cin >> c) { 9 | velho.push_back(c - '0'); 10 | } 11 | novo = velho; 12 | next_permutation(novo.begin(), novo.end()); 13 | if (novo > velho) { 14 | for (int x : novo) cout << x; 15 | cout << endl; 16 | } else { 17 | cout << 0 << endl; 18 | } 19 | return 0; 20 | } -------------------------------------------------------------------------------- /DMOJ/coci08c1p1.cpp: -------------------------------------------------------------------------------- 1 | // Ivan Carvalho 2 | // Solution to https://dmoj.ca/problem/coci08c1p1 3 | #include 4 | using namespace std; 5 | int main() { 6 | int a, b, c; 7 | int resp = 0; 8 | cin >> a >> b >> c; 9 | cout << max(b - a, c - b) - 1 << endl; 10 | return 0; 11 | } -------------------------------------------------------------------------------- /DMOJ/coci08c2p1.cpp: -------------------------------------------------------------------------------- 1 | // Ivan Carvalho 2 | // Solution to https://dmoj.ca/problem/coci08c2p1 3 | #include 4 | #include 5 | using namespace std; 6 | int main() { 7 | int V[4]; 8 | scanf("%d %d %d %d", &V[0], &V[1], &V[2], &V[3]); 9 | sort(V, V + 4); 10 | printf("%d\n", V[0] * V[2]); 11 | return 0; 12 | } -------------------------------------------------------------------------------- /DMOJ/coci08c2p2.cpp: -------------------------------------------------------------------------------- 1 | // Ivan Carvalho 2 | // Solution to https://dmoj.ca/problem/coci08c2p2 3 | #include 4 | using namespace std; 5 | int crivo[10000], n, k; 6 | int main() { 7 | cin >> n >> k; 8 | for (int i = 2; i <= n; i++) { 9 | if (crivo[i]) continue; 10 | for (int j = i; j <= n; j += i) { 11 | if (crivo[j] == 0) { 12 | k--; 13 | crivo[j] = 1; 14 | if (k == 0) { 15 | cout << j << endl; 16 | return 0; 17 | } 18 | } 19 | } 20 | } 21 | return 0; 22 | } -------------------------------------------------------------------------------- /DMOJ/coci08c2p5.py: -------------------------------------------------------------------------------- 1 | # Ivan Carvalho 2 | # Solution to https://dmoj.ca/problem/coci08c2p5 3 | # -*- coding : utf-8 -*- 4 | 5 | entrada = eval(input()) 6 | 7 | somatorio = 1 8 | nos = 1 9 | 10 | for caractere in entrada: 11 | if caractere == "P": 12 | continue 13 | elif caractere == "L": 14 | somatorio = somatorio * 2 15 | elif caractere == "R": 16 | somatorio = somatorio * 2 + nos 17 | else: 18 | somatorio = somatorio * 5 + nos 19 | nos *= 3 20 | 21 | print(somatorio) 22 | -------------------------------------------------------------------------------- /DMOJ/coci08c4p1.py: -------------------------------------------------------------------------------- 1 | # Ivan Carvalho 2 | # Solution to https://dmoj.ca/problem/coci08c4p1 3 | def exibe(lista): 4 | copia = [str(i) for i in lista] 5 | print((" ".join(copia))) 6 | 7 | 8 | lista = [int(i) for i in input().split()] 9 | 10 | for vez in range(5): 11 | for i in range(len(lista) - 1): 12 | if lista[i] > lista[i + 1]: 13 | lista[i], lista[i + 1] = lista[i + 1], lista[i] 14 | exibe(lista) 15 | -------------------------------------------------------------------------------- /DMOJ/coci08c5p2.py: -------------------------------------------------------------------------------- 1 | # Ivan Carvalho 2 | # Solution to https://dmoj.ca/problem/coci08c5p2 3 | from math import gcd 4 | 5 | a, b = [int(i) for i in input().split()] 6 | 7 | c = gcd(a, b) 8 | 9 | i = 1 10 | while i * i <= c: 11 | if c % i != 0: 12 | i += 1 13 | continue 14 | print(("%d %d %d" % (i, a / i, b / i))) 15 | if i * i != c: 16 | j = c / i 17 | print(("%d %d %d" % (j, a / j, b / j))) 18 | i += 1 19 | -------------------------------------------------------------------------------- /DMOJ/coci08c6p1.cpp: -------------------------------------------------------------------------------- 1 | // Ivan Carvalho 2 | // Solution to https://dmoj.ca/problem/coci08c6p1 3 | #!/ usr / bin / env python2 .7 4 | a = int(raw_input()) b = raw_input() c = 5 | int(raw_input()) if b == "+" : print a + c else : print a * c -------------------------------------------------------------------------------- /DMOJ/coci09c1p1.py: -------------------------------------------------------------------------------- 1 | # Ivan Carvalho 2 | # Solution to https://dmoj.ca/problem/coci09c1p1 3 | 4 | tones = [int(i) for i in input().split()] 5 | 6 | if tones == list(range(1, 9)): 7 | print("ascending") 8 | elif tones == list(range(1, 9))[::-1]: 9 | print("descending") 10 | else: 11 | print("mixed") 12 | -------------------------------------------------------------------------------- /DMOJ/coci09c1p2.py: -------------------------------------------------------------------------------- 1 | # Ivan Carvalho 2 | # Solution to https://dmoj.ca/problem/coci09c1p2 3 | 4 | n = int(eval(input())) 5 | ans = 0 6 | 7 | for i in range(n + 1): 8 | for j in range(i, n + 1): 9 | ans += i + j 10 | 11 | print(ans) 12 | -------------------------------------------------------------------------------- /DMOJ/coci13c1p2.cpp: -------------------------------------------------------------------------------- 1 | // Ivan Carvalho 2 | // Solution to https://dmoj.ca/problem/coci13c1p2 3 | #include 4 | using namespace std; 5 | int main() { 6 | int n, m; 7 | cin >> n >> m; 8 | cout << m - __gcd(n, m) << endl; 9 | return 0; 10 | } -------------------------------------------------------------------------------- /DMOJ/coci14c1p1.cpp: -------------------------------------------------------------------------------- 1 | // Ivan Carvalho 2 | // Solution to https://dmoj.ca/problem/coci14c1p1 3 | n = int(raw_input()) 4 | b = [int(i) for i in raw_input().split()] 5 | total = b[0] 6 | a = [b[0]] 7 | for i in xrange(1,n): 8 | davez = b[i]*(i+1) - total 9 | a.append(davez) 10 | total += davez 11 | for i in a: 12 | print i, -------------------------------------------------------------------------------- /DMOJ/coci14c1p2.cpp: -------------------------------------------------------------------------------- 1 | // Ivan Carvalho 2 | // Solution to https://dmoj.ca/problem/coci14c1p2 3 | #include 4 | using namespace std; 5 | int main() { 6 | int n; 7 | cin >> n; 8 | int x1 = 100, x2 = 1, y1 = 100, y2 = 1; 9 | while (n--) { 10 | int x, y; 11 | cin >> x >> y; 12 | x1 = min(x1, x); 13 | x2 = max(x2, x); 14 | y1 = min(y1, y); 15 | y2 = max(y2, y); 16 | } 17 | int delta = max(x2 - x1, y2 - y1); 18 | cout << delta * delta << endl; 19 | return 0; 20 | } -------------------------------------------------------------------------------- /DMOJ/coci14c2p2.cpp: -------------------------------------------------------------------------------- 1 | // Ivan Carvalho 2 | // Solution to https://dmoj.ca/problem/coci14c2p2 3 | #include 4 | using namespace std; 5 | multiset cjt; 6 | int main() { 7 | ios_base::sync_with_stdio(0); 8 | cin.tie(0); 9 | cout.tie(0); 10 | int n; 11 | cin >> n; 12 | for (int i = 1; i <= n; i++) { 13 | string s; 14 | cin >> s; 15 | cjt.insert(s); 16 | } 17 | for (int i = 1; i < n; i++) { 18 | string s; 19 | cin >> s; 20 | cjt.erase(cjt.find(s)); 21 | } 22 | for (string s : cjt) cout << s << endl; 23 | return 0; 24 | } -------------------------------------------------------------------------------- /DMOJ/coci14c3p1.py: -------------------------------------------------------------------------------- 1 | # Ivan Carvalho 2 | # Solution to https://dmoj.ca/problem/coci14c3p1 3 | 4 | tipo = ["1QAZ", "2WSX", "3EDC", "4RFV5TGB", "6YHN7UJM", "8IK,", "9OL.", "0P;//-=[]'"] 5 | qtd = [0 for i in range(len(tipo))] 6 | a = eval(input()) 7 | 8 | for i in a: 9 | for j in range(len(tipo)): 10 | if i in tipo[j]: 11 | qtd[j] += 1 12 | break 13 | else: 14 | print("Invalid Input") 15 | 16 | for i in qtd: 17 | print(i) 18 | -------------------------------------------------------------------------------- /DMOJ/coci14c4p1.cpp: -------------------------------------------------------------------------------- 1 | // Ivan Carvalho 2 | // Solution to https://dmoj.ca/problem/coci14c4p1 3 | #include 4 | using namespace std; 5 | int main() { 6 | string s; 7 | cin >> s; 8 | int soma = 0; 9 | vector e; 10 | for (char n : s) { 11 | e.push_back(n - '0'); 12 | soma += n - '0'; 13 | } 14 | sort(e.begin(), e.end()); 15 | if (e[0] != 0 || soma % 3 != 0) { 16 | cout << -1 << endl; 17 | return 0; 18 | } 19 | for (int i = e.size() - 1; i >= 0; i--) cout << e[i]; 20 | cout << endl; 21 | return 0; 22 | } -------------------------------------------------------------------------------- /DMOJ/coci14c4p3.cpp: -------------------------------------------------------------------------------- 1 | // Ivan Carvalho 2 | // Solution to https://dmoj.ca/problem/coci14c4p3 3 | #include 4 | using namespace std; 5 | 6 | typedef long long ll; 7 | 8 | int main() { 9 | vector V; 10 | ll sum = 0; 11 | int N; 12 | 13 | cin >> N; 14 | for (int i = 0; i < N; i++) { 15 | int x; 16 | cin >> x; 17 | sum += x; 18 | V.push_back(x); 19 | } 20 | 21 | sort(V.begin(), V.end()); 22 | 23 | printf("%lld\n", max(2LL * V[N - 1], sum)); 24 | 25 | return 0; 26 | } -------------------------------------------------------------------------------- /DMOJ/coci14c5p1.cpp: -------------------------------------------------------------------------------- 1 | // Ivan Carvalho 2 | // Solution to https://dmoj.ca/problem/coci14c5p1 3 | #include 4 | using namespace std; 5 | int vetor[17], soma[17]; 6 | int main() { 7 | for (int i = 1; i <= 8; i++) { 8 | cin >> vetor[i]; 9 | vetor[i + 8] = vetor[i]; 10 | } 11 | int resp = 0; 12 | for (int i = 1; i <= 16; i++) { 13 | soma[i] = soma[i - 1] + vetor[i]; 14 | } 15 | for (int ini = 1, fim = 4; fim <= 16; ini++, fim++) { 16 | resp = max(resp, soma[fim] - soma[ini - 1]); 17 | } 18 | cout << resp << endl; 19 | return 0; 20 | } -------------------------------------------------------------------------------- /DMOJ/coci15c1p3.cpp: -------------------------------------------------------------------------------- 1 | // Ivan Carvalho 2 | // Solution to https://dmoj.ca/problem/coci15c1p3 3 | #include 4 | int vetor[1000010], marcado[1000010]; 5 | int main() { 6 | int resp = 0, n; 7 | scanf("%d", &n); 8 | for (int i = 1; i <= n; i++) scanf("%d", &vetor[i]); 9 | for (int i = 1; i <= n; i++) { 10 | if (marcado[vetor[i]] == 0) { 11 | resp++; 12 | marcado[vetor[i] - 1]++; 13 | } else { 14 | marcado[vetor[i]]--; 15 | marcado[vetor[i] - 1]++; 16 | } 17 | } 18 | printf("%d\n", resp); 19 | return 0; 20 | } -------------------------------------------------------------------------------- /DMOJ/coci15c3p1.cpp: -------------------------------------------------------------------------------- 1 | // Ivan Carvalho 2 | // Solution to https://dmoj.ca/problem/coci15c3p1 3 | n = int(raw_input()) 4 | resposta = 0 5 | for i in xrange(n): 6 | a = [i for i in raw_input()] 7 | b = int(a[-1]) 8 | a.pop(-1) 9 | c = int("".join(a)) 10 | resposta += c**b 11 | print resposta -------------------------------------------------------------------------------- /DMOJ/coci15c4p3.cpp: -------------------------------------------------------------------------------- 1 | // Ivan Carvalho 2 | // Solution to https://dmoj.ca/problem/coci15c4p3 3 | #include 4 | int vetor[1010]; 5 | int main() { 6 | int n; 7 | scanf("%d", &n); 8 | for (int i = 1; i <= n; i++) { 9 | for (int j = 1; j <= n; j++) { 10 | int k; 11 | scanf("%d", &k); 12 | vetor[i] |= k; 13 | vetor[j] |= k; 14 | } 15 | } 16 | for (int i = 1; i <= n; i++) printf("%d ", vetor[i]); 17 | printf("\n"); 18 | return 0; 19 | } -------------------------------------------------------------------------------- /DMOJ/coci16c1p1.cpp: -------------------------------------------------------------------------------- 1 | // Ivan Carvalho 2 | // Solution to https://dmoj.ca/problem/coci16c1p1 3 | #include 4 | using namespace std; 5 | int main() { 6 | int x, n, tot; 7 | cin >> x >> n; 8 | tot = (n + 1) * x; 9 | while (n--) { 10 | int v; 11 | cin >> v; 12 | tot -= v; 13 | } 14 | cout << tot << endl; 15 | return 0; 16 | } -------------------------------------------------------------------------------- /DMOJ/dmopc14c1p3.cpp: -------------------------------------------------------------------------------- 1 | // Ivan Carvalho 2 | // Solution to https://dmoj.ca/problem/dmopc14c1p3 3 | #include 4 | using namespace std; 5 | typedef long long ll; 6 | int main() { 7 | ll soma = 0, n; 8 | scanf("%lld", &n); 9 | for (ll i = 1; i <= n; i++) { 10 | ll davez; 11 | scanf("%lld", &davez); 12 | soma += davez; 13 | } 14 | ll q; 15 | scanf("%lld", &q); 16 | while (q--) { 17 | ll davez; 18 | scanf("%lld", &davez); 19 | soma += davez; 20 | n++; 21 | printf("%.3lf\n", double(soma) / double(n)); 22 | } 23 | return 0; 24 | } -------------------------------------------------------------------------------- /DMOJ/dmopc14c2p2.cpp: -------------------------------------------------------------------------------- 1 | // Ivan Carvalho 2 | // Solution to https://dmoj.ca/problem/dmopc14c2p2 3 | a = int(raw_input()) 4 | entrada = [i for i in raw_input().split("X") if i != ""] 5 | print len(entrada) 6 | for i in entrada: 7 | print i -------------------------------------------------------------------------------- /DMOJ/dmopc14c2p4.cpp: -------------------------------------------------------------------------------- 1 | // Ivan Carvalho 2 | // Solution to https://dmoj.ca/problem/dmopc14c2p4 3 | #include 4 | int dp[1000010], n, q; 5 | int main() { 6 | scanf("%d", &n); 7 | for (int i = 1; i <= n; i++) { 8 | scanf("%d", &dp[i]); 9 | dp[i] += dp[i - 1]; 10 | } 11 | scanf("%d", &q); 12 | while (q--) { 13 | int a, b; 14 | scanf("%d %d", &a, &b); 15 | a++; 16 | b++; 17 | printf("%d\n", dp[b] - dp[a - 1]); 18 | } 19 | return 0; 20 | } -------------------------------------------------------------------------------- /DMOJ/dmopc15c1p3.cpp: -------------------------------------------------------------------------------- 1 | // Ivan Carvalho 2 | // Solution to https://dmoj.ca/problem/dmopc15c1p3 3 | alfabeto = "abcdefghijklmnopqrstuvwxyz" 4 | shift = {} 5 | shift["a"] = "z" 6 | for i in xrange(1,len(alfabeto)): 7 | shift[alfabeto[i]] = alfabeto[i-1] 8 | a = raw_input() 9 | b = raw_input() 10 | for i in xrange(26): 11 | if b in a: 12 | print i 13 | print a 14 | break 15 | a = "".join([shift[j] for j in a]) -------------------------------------------------------------------------------- /DMOJ/dmopc16c4p1.cpp: -------------------------------------------------------------------------------- 1 | // Ivan Carvalho 2 | // Solution to https://dmoj.ca/problem/dmopc16c4p1 3 | #include 4 | using namespace std; 5 | typedef long long ll; 6 | int main() { 7 | ll n; 8 | scanf("%lld", &n); 9 | while (n--) { 10 | ll v; 11 | scanf("%lld", &v); 12 | if (__builtin_popcountll(v) == 1) 13 | printf("T\n"); 14 | else 15 | printf("F\n"); 16 | } 17 | return 0; 18 | } -------------------------------------------------------------------------------- /DMOJ/dmpg17s1.cpp: -------------------------------------------------------------------------------- 1 | // Ivan Carvalho 2 | // Solution to https://dmoj.ca/problem/dmpg17s1 3 | #include 4 | #include 5 | #include 6 | #include 7 | using namespace std; 8 | int main() { 9 | int N; 10 | cin >> N; 11 | vector E(N); 12 | for (int i = 0; i < N; i++) cin >> E[i]; 13 | sort(E.begin(), E.end()); 14 | int resp = abs(E[1] - E[0]); 15 | for (int i = 2; i < N; i++) { 16 | resp = min(resp, abs(E[i + 1] - E[i])); 17 | } 18 | cout << resp << endl; 19 | return 0; 20 | } -------------------------------------------------------------------------------- /DMOJ/dpa.cpp: -------------------------------------------------------------------------------- 1 | // Ivan Carvalho 2 | // Solution to https://dmoj.ca/problem/dpa 3 | #include 4 | using namespace std; 5 | 6 | const int MAXN = 1e5 + 10; 7 | const int INF = 2 * 1e9; 8 | 9 | int dp[MAXN], N, K, h[MAXN]; 10 | 11 | int main() { 12 | scanf("%d", &N); 13 | K = 2; 14 | for (int i = 1; i <= N; i++) { 15 | scanf("%d", &h[i]); 16 | } 17 | 18 | for (int i = 2; i <= N; i++) { 19 | dp[i] = INF; 20 | for (int j = i - 1; j >= max(i - K, 1); j--) { 21 | dp[i] = min(dp[i], dp[j] + abs(h[i] - h[j])); 22 | } 23 | } 24 | 25 | printf("%d\n", dp[N]); 26 | 27 | return 0; 28 | } -------------------------------------------------------------------------------- /DMOJ/dpb.cpp: -------------------------------------------------------------------------------- 1 | // Ivan Carvalho 2 | // Solution to https://dmoj.ca/problem/dpb 3 | #include 4 | using namespace std; 5 | 6 | const int MAXN = 1e5 + 10; 7 | const int INF = 2 * 1e9; 8 | 9 | int dp[MAXN], N, K, h[MAXN]; 10 | 11 | int main() { 12 | scanf("%d %d", &N, &K); 13 | for (int i = 1; i <= N; i++) { 14 | scanf("%d", &h[i]); 15 | } 16 | 17 | for (int i = 2; i <= N; i++) { 18 | dp[i] = INF; 19 | for (int j = i - 1; j >= max(i - K, 1); j--) { 20 | dp[i] = min(dp[i], dp[j] + abs(h[i] - h[j])); 21 | } 22 | } 23 | 24 | printf("%d\n", dp[N]); 25 | 26 | return 0; 27 | } -------------------------------------------------------------------------------- /DMOJ/dpd.cpp: -------------------------------------------------------------------------------- 1 | // Ivan Carvalho 2 | // Solution to https://dmoj.ca/problem/dpd 3 | #include 4 | using namespace std; 5 | 6 | const int MAXW = 1e5 + 10; 7 | 8 | long long knapsack[MAXW]; 9 | int N, W; 10 | 11 | int main() { 12 | cin >> N >> W; 13 | 14 | for (int item = 1; item <= N; item++) { 15 | int w, v; 16 | cin >> w >> v; 17 | for (int i = W; i >= w; i--) 18 | knapsack[i] = max(knapsack[i - w] + v, knapsack[i]); 19 | } 20 | 21 | long long best = 0; 22 | for (int i = 0; i <= W; i++) best = max(best, knapsack[i]); 23 | cout << best << endl; 24 | 25 | return 0; 26 | } -------------------------------------------------------------------------------- /DMOJ/factorial.py: -------------------------------------------------------------------------------- 1 | # Ivan Carvalho 2 | # Solution to https://dmoj.ca/problem/factorial 3 | #!/usr/bin/env python 4 | # -*- coding : utf-8 -*- 5 | mod = 2**32 6 | testes = int(input()) 7 | for vez in range(testes): 8 | fat = 1 9 | n = int(input()) 10 | if n >= 50: 11 | print(0) 12 | continue 13 | for i in range(2, n + 1): 14 | fat *= i 15 | fat %= mod 16 | print(fat) 17 | -------------------------------------------------------------------------------- /DMOJ/fastbit.cpp: -------------------------------------------------------------------------------- 1 | // Ivan Carvalho 2 | // Solution to https://dmoj.ca/problem/fastbit 3 | #include 4 | int setbits(unsigned long long w) { 5 | w -= (w >> 1) & 0x5555555555555555ULL; 6 | w = (w & 0x3333333333333333ULL) + ((w >> 2) & 0x3333333333333333ULL); 7 | w = (w + (w >> 4)) & 0x0f0f0f0f0f0f0f0fULL; 8 | return (w * 0x0101010101010101ULL) >> 56; 9 | } 10 | int main() { return 0; } -------------------------------------------------------------------------------- /DMOJ/gfssoc3s1.py: -------------------------------------------------------------------------------- 1 | # Ivan Carvalho 2 | # Solution to https://dmoj.ca/problem/gfssoc3s1 3 | #!/usr/bin/env python 4 | # -*- coding : utf-8 -*- 5 | n = int(input()) 6 | resp = "" 7 | pot = 0 8 | while 2**pot <= n: 9 | resp = resp + "1" 10 | pot += 1 11 | print(resp) 12 | -------------------------------------------------------------------------------- /DMOJ/hci16xorpow.cpp: -------------------------------------------------------------------------------- 1 | // Ivan Carvalho 2 | // Solution to https://dmoj.ca/problem/hci16xorpow 3 | #include 4 | int freq[4048], n, k, tot, resp; 5 | int main() { 6 | scanf("%d %d", &n, &k); 7 | freq[0] = 1; 8 | for (int i = 1; i <= n; i++) { 9 | int davez; 10 | scanf("%d", &davez); 11 | tot ^= davez; 12 | // printf("%d\n",tot); 13 | for (int temp = k; temp <= 1024; temp *= k) { 14 | resp += freq[tot ^ temp]; 15 | // printf("T : %d\n",tot^temp); 16 | } 17 | freq[tot]++; 18 | } 19 | printf("%d\n", resp); 20 | return 0; 21 | } -------------------------------------------------------------------------------- /DMOJ/helloworld.py: -------------------------------------------------------------------------------- 1 | # Ivan Carvalho 2 | # Solution to https://dmoj.ca/problem/helloworld 3 | print("Hello, World!") 4 | -------------------------------------------------------------------------------- /DMOJ/inaho4.py: -------------------------------------------------------------------------------- 1 | # Ivan Carvalho 2 | # Solution to https://dmoj.ca/problem/inaho4 3 | n = int(input()) 4 | a = [float(i) for i in input().split()] 5 | b = [float(i) for i in input().split()] 6 | total = 0 7 | for i in range(len(a)): 8 | total += (b[i] - a[i]) * (b[i] - a[i]) 9 | print("%.6f" % (total**0.5)) 10 | -------------------------------------------------------------------------------- /DMOJ/inaho5.cpp: -------------------------------------------------------------------------------- 1 | // Ivan Carvalho 2 | // Solution to https://dmoj.ca/problem/inaho5 3 | #include 4 | using namespace std; 5 | typedef long long ll; 6 | typedef unsigned long long llu; 7 | int main() { 8 | llu n, v = 0; 9 | cin >> n; 10 | while (n--) { 11 | ll x; 12 | cin >> x; 13 | v += -x; 14 | } 15 | if (v == 0) 16 | cout << v << endl; 17 | else 18 | cout << "-" << v << endl; 19 | return 0; 20 | } -------------------------------------------------------------------------------- /DMOJ/modinv.py: -------------------------------------------------------------------------------- 1 | # Ivan Carvalho 2 | # Solution to https://dmoj.ca/problem/modinv 3 | def egcd(a, b): 4 | if a == 0: 5 | return (b, 0, 1) 6 | else: 7 | g, x, y = egcd(b % a, a) 8 | return (g, y - (b // a) * x, x) 9 | 10 | 11 | a, b = [int(i) for i in input().split()] 12 | c, d, e = egcd(a, b) 13 | d += b 14 | d %= b 15 | print(d) 16 | -------------------------------------------------------------------------------- /DMOJ/odd.cpp: -------------------------------------------------------------------------------- 1 | // Ivan Carvalho 2 | // Solution to https://dmoj.ca/problem/odd 3 | #include 4 | int main() { 5 | int n, resp = 0; 6 | scanf("%d", &n); 7 | while (n--) { 8 | int d; 9 | scanf("%d", &d); 10 | resp ^= d; 11 | } 12 | printf("%d\n", resp); 13 | return 0; 14 | } -------------------------------------------------------------------------------- /DMOJ/set.cpp: -------------------------------------------------------------------------------- 1 | // Ivan Carvalho 2 | // Solution to https://dmoj.ca/problem/set 3 | #include 4 | #include 5 | using namespace std; 6 | int main() { 7 | set c; 8 | int n, d; 9 | scanf("%d", &n); 10 | while (n--) { 11 | scanf("%d", &d); 12 | c.insert(d); 13 | } 14 | printf("%lu\n", c.size()); 15 | return 0; 16 | } -------------------------------------------------------------------------------- /DMOJ/shortest1.py: -------------------------------------------------------------------------------- 1 | # Ivan Carvalho 2 | # Solution to https://dmoj.ca/problem/shortest1 3 | while 1: 4 | 0 5 | -------------------------------------------------------------------------------- /DMOJ/si17c1p8.cpp: -------------------------------------------------------------------------------- 1 | // Ivan Carvalho 2 | // Solution to https://dmoj.ca/problem/si17c1p8 3 | #include 4 | using namespace std; 5 | const int MAXN = 20; 6 | int V[MAXN], T, N; 7 | int main() { 8 | cin >> N >> T; 9 | for (int i = 0; i < N; i++) cin >> V[i]; 10 | int resposta = 0; 11 | for (int bitmask = 1; bitmask < (1 << N); bitmask++) { 12 | int total = 0; 13 | for (int i = 0; i < N; i++) { 14 | if (bitmask & (1 << i)) total += V[i]; 15 | } 16 | if (total == T) resposta++; 17 | } 18 | printf("%d\n", resposta); 19 | return 0; 20 | } -------------------------------------------------------------------------------- /DMOJ/thicc17p1.cpp: -------------------------------------------------------------------------------- 1 | // Ivan Carvalho 2 | // Solution to https://dmoj.ca/problem/thicc17p1 3 | n,m = [int(i) for i in raw_input().split()] 4 | modulo = 1000000007 5 | entrada = [int(i) for i in raw_input().split()] 6 | entrada.sort() 7 | resp = 0 8 | contador = 0 9 | pot = 0 10 | for i in entrada[::-1]: 11 | resp = (resp + pow(i,pot,modulo)) % modulo 12 | contador += 1 13 | if contador % m == 0: 14 | pot += 1 15 | print resp -------------------------------------------------------------------------------- /DMOJ/thicc17p2.cpp: -------------------------------------------------------------------------------- 1 | // Ivan Carvalho 2 | // Solution to https://dmoj.ca/problem/thicc17p2 3 | #include 4 | using namespace std; 5 | typedef long long ll; 6 | const ll MOD = 1e9 + 7; 7 | ll n, a, b, m, soma, resp; 8 | int main() { 9 | cin >> n >> a >> b >> m; 10 | soma = a; 11 | for (ll i = 1; i < n; i++) { 12 | a *= b; 13 | a %= m; 14 | // printf("%lld %lld\n",a,soma); 15 | resp += (a * soma) % MOD; 16 | resp %= MOD; 17 | soma += a; 18 | soma %= MOD; 19 | } 20 | resp *= 2; 21 | resp %= MOD; 22 | cout << resp << endl; 23 | return 0; 24 | } -------------------------------------------------------------------------------- /DMOJ/xor.cpp: -------------------------------------------------------------------------------- 1 | // Ivan Carvalho 2 | // Solution to https://dmoj.ca/problem/xor 3 | #include 4 | int xor1(int x) { 5 | if (x % 4 == 0) return x; 6 | if (x % 4 == 1) return 1; 7 | if (x % 4 == 2) return x + 1; 8 | return 0; 9 | } 10 | int main() { 11 | int T, a, b; 12 | scanf("%d", &T); 13 | while (T--) { 14 | scanf("%d %d", &a, &b); 15 | printf("%d\n", xor1(a - 1) ^ xor1(b)); 16 | } 17 | return 0; 18 | } -------------------------------------------------------------------------------- /DMOJ/year2018p2.cpp: -------------------------------------------------------------------------------- 1 | // Ivan Carvalho 2 | // Solution to https://dmoj.ca/problem/year2018p2 3 | #include 4 | using namespace std; 5 | const int MAXN = 1e5 + 10; 6 | bool crivo[MAXN]; 7 | int main() { 8 | crivo[0] = true; 9 | crivo[1] = true; 10 | for (int i = 2; i < MAXN; i++) { 11 | if (crivo[i]) continue; 12 | for (int j = 2 * i; j < MAXN; j += i) crivo[j] = true; 13 | } 14 | int N, resposta = 0; 15 | cin >> N; 16 | while (N--) { 17 | int x; 18 | cin >> x; 19 | if (!crivo[x]) resposta++; 20 | } 21 | cout << resposta << endl; 22 | return 0; 23 | } -------------------------------------------------------------------------------- /SPOJ/ADACUT.cpp: -------------------------------------------------------------------------------- 1 | // Ivan Carvalho 2 | // Solution to https://www.spoj.com/problems/ADACUT/ 3 | #include 4 | using namespace std; 5 | typedef long long ll; 6 | const int MAXN = 3 * 1e5 + 10; 7 | ll vetor[MAXN], total, N, resp; 8 | int main() { 9 | scanf("%lld", &N); 10 | for (ll i = 1; i <= N; i++) { 11 | scanf("%lld", &vetor[i]); 12 | total += vetor[i]; 13 | } 14 | resp = total; 15 | sort(vetor + 1, vetor + N + 1); 16 | for (ll i = 1; i <= N; i++) { 17 | resp = min(resp, (N - i + 1) * (-vetor[i]) + total); 18 | } 19 | printf("%lld\n", resp); 20 | return 0; 21 | } -------------------------------------------------------------------------------- /SPOJ/ADAROBOT.cpp: -------------------------------------------------------------------------------- 1 | // Ivan Carvalho 2 | // Solution to https://www.spoj.com/problems/ADAROBOT/ 3 | #include 4 | using namespace std; 5 | const int MAXN = 2 * 1e8 + 2; 6 | long dp[MAXN]; 7 | int main() { 8 | for (int i = 2; i < MAXN; i++) { 9 | long long davez = 1LL * (i) * (i - 1); 10 | long fn = __builtin_ffsll(davez); 11 | dp[i] = dp[i - 2] + fn * fn * fn; 12 | } 13 | int Q; 14 | scanf("%d", &Q); 15 | while (Q--) { 16 | int x; 17 | scanf("%d", &x); 18 | printf("%ld\n", dp[x]); 19 | } 20 | return 0; 21 | } -------------------------------------------------------------------------------- /SPOJ/DANGER.py: -------------------------------------------------------------------------------- 1 | # Ivan Carvalho 2 | # Solution to https://www.spoj.com/problems/DANGER/ 3 | #!/usr/bin/env python 4 | # -*- coding : utf-8 -*- 5 | from math import log, floor 6 | 7 | while True: 8 | entrada = input() 9 | n = int(entrada[0] + entrada[1]) * 10 ** int(entrada[3]) 10 | if n == 0: 11 | break 12 | expo = floor(log(n) / log(2)) 13 | exibir = n - (2**expo) 14 | exibir *= 2 15 | exibir += 1 16 | print("%d" % (exibir)) 17 | -------------------------------------------------------------------------------- /SPOJ/ETF.cpp: -------------------------------------------------------------------------------- 1 | // Ivan Carvalho 2 | // Solution to https://www.spoj.com/problems/ETF/ 3 | #include 4 | const int MAXN = 1e6 + 10; 5 | int totient[MAXN]; 6 | int main() { 7 | for (int i = 1; i < MAXN; i++) { 8 | totient[i] = i; 9 | } 10 | for (int i = 2; i < MAXN; i++) { 11 | if (totient[i] == i) 12 | for (int j = i; j < MAXN; j += i) { 13 | totient[j] -= totient[j] / i; 14 | } 15 | } 16 | int TC; 17 | scanf("%d", &TC); 18 | while (TC--) { 19 | int davez; 20 | scanf("%d", &davez); 21 | printf("%d\n", totient[davez]); 22 | } 23 | return 0; 24 | } -------------------------------------------------------------------------------- /SPOJ/LASTDIG.py: -------------------------------------------------------------------------------- 1 | # Ivan Carvalho 2 | # Solution to https://www.spoj.com/problems/LASTDIG/ 3 | t = int(input()) 4 | for i in range(t): 5 | a, b = [int(j) for j in input().split()] 6 | print(pow(a, b, 10)) 7 | -------------------------------------------------------------------------------- /SPOJ/LKS.cpp: -------------------------------------------------------------------------------- 1 | // Ivan Carvalho 2 | // Solution to https://www.spoj.com/problems/LKS/ 3 | #include 4 | #include 5 | using namespace std; 6 | int dp[2000001]; 7 | int main() { 8 | int W, N; 9 | scanf("%d %d", &W, &N); 10 | while (N--) { 11 | int v, w; 12 | scanf("%d %d", &v, &w); 13 | for (int i = W; i >= w; i--) dp[i] = max(dp[i], dp[i - w] + v); 14 | } 15 | int b = 0; 16 | while (W--) b = max(b, dp[W]); 17 | printf("%d\n", b); 18 | return 0; 19 | } -------------------------------------------------------------------------------- /SPOJ/PERMUT2.cpp: -------------------------------------------------------------------------------- 1 | // Ivan Carvalho 2 | // Solution to https://www.spoj.com/problems/PERMUT2/ 3 | #include 4 | int vetor[100010]; 5 | int main() { 6 | int n; 7 | while (scanf("%d", &n) && n) { 8 | for (int i = 1; i <= n; i++) { 9 | scanf("%d", &vetor[i]); 10 | } 11 | int ambiguo = 1; 12 | for (int i = 1; i <= n; i++) { 13 | if (vetor[vetor[i]] != i) { 14 | ambiguo = 0; 15 | break; 16 | } 17 | } 18 | printf("%s\n", ambiguo ? "ambiguous" : "not ambiguous"); 19 | } 20 | return 0; 21 | } -------------------------------------------------------------------------------- /SPOJ/TDPRIMES.cpp: -------------------------------------------------------------------------------- 1 | // Ivan Carvalho 2 | // Solution to https://www.spoj.com/problems/TDPRIMES/ 3 | #include 4 | using namespace std; 5 | int contador; 6 | const int MAXN = 1e8 + 1; 7 | const int MAXI = 1e4 + 1; 8 | bool crivo[MAXN]; 9 | int main() { 10 | for (int i = 2; i < MAXN; i++) { 11 | if (!crivo[i]) { 12 | contador++; 13 | if (contador % 100 == 1) printf("%d\n", i); 14 | if (i < MAXI) { 15 | for (int j = i * i; j < MAXN; j += i) { 16 | crivo[j] = true; 17 | } 18 | } 19 | } 20 | } 21 | return 0; 22 | } -------------------------------------------------------------------------------- /SPOJ/TEST.cpp: -------------------------------------------------------------------------------- 1 | // Ivan Carvalho 2 | // Solution to https://www.spoj.com/problems/TEST/ 3 | #include 4 | int main() { 5 | int n; 6 | while (scanf("%d", &n) && n != 42) printf("%d\n", n); 7 | return 0; 8 | } -------------------------------------------------------------------------------- /beecrowd/1001.cpp: -------------------------------------------------------------------------------- 1 | // Ivan Carvalho 2 | // Solution to https://www.beecrowd.com.br/judge/problems/view/1001 3 | #include 4 | 5 | using namespace std; 6 | 7 | int main() { 8 | int a, b; 9 | scanf("%d", &a); 10 | scanf("%d", &b); 11 | printf("X = %d\n", a + b); 12 | return 0; 13 | } 14 | -------------------------------------------------------------------------------- /beecrowd/1002.cpp: -------------------------------------------------------------------------------- 1 | // Ivan Carvalho 2 | // Solution to https://www.beecrowd.com.br/judge/problems/view/1002 3 | #include 4 | 5 | using namespace std; 6 | 7 | int main() { 8 | double r; 9 | scanf("%lf", &r); 10 | printf("A=%.4lf\n", 3.14159 * r * r); 11 | return 0; 12 | } 13 | -------------------------------------------------------------------------------- /beecrowd/1003.cpp: -------------------------------------------------------------------------------- 1 | // Ivan Carvalho 2 | // Solution to https://www.beecrowd.com.br/judge/problems/view/1003 3 | #include 4 | int main() { 5 | int a, b; 6 | scanf("%d", &a); 7 | scanf("%d", &b); 8 | printf("SOMA = %d\n", a + b); 9 | return 0; 10 | } 11 | -------------------------------------------------------------------------------- /beecrowd/1004.cpp: -------------------------------------------------------------------------------- 1 | // Ivan Carvalho 2 | // Solution to https://www.beecrowd.com.br/judge/problems/view/1004 3 | #include 4 | int main() { 5 | int a, b; 6 | scanf("%d", &a); 7 | scanf("%d", &b); 8 | printf("PROD = %d\n", a * b); 9 | return 0; 10 | } 11 | -------------------------------------------------------------------------------- /beecrowd/1005.cpp: -------------------------------------------------------------------------------- 1 | // Ivan Carvalho 2 | // Solution to https://www.beecrowd.com.br/judge/problems/view/1005 3 | #include 4 | int main() { 5 | double a, b; 6 | scanf("%lf", &a); 7 | scanf("%lf", &b); 8 | printf("MEDIA = %.5lf\n", (3.5 * a + 7.5 * b) / 11.0); 9 | return 0; 10 | } 11 | -------------------------------------------------------------------------------- /beecrowd/1006.cpp: -------------------------------------------------------------------------------- 1 | // Ivan Carvalho 2 | // Solution to https://www.beecrowd.com.br/judge/problems/view/1006 3 | #include 4 | int main() { 5 | double a, b, c; 6 | scanf("%lf", &a); 7 | scanf("%lf", &b); 8 | scanf("%lf", &c); 9 | printf("MEDIA = %.1lf\n", (2.0 * a + 3.0 * b + 5.0 * c) / 10.0); 10 | return 0; 11 | } 12 | -------------------------------------------------------------------------------- /beecrowd/1007.cpp: -------------------------------------------------------------------------------- 1 | // Ivan Carvalho 2 | // Solution to https://www.beecrowd.com.br/judge/problems/view/1007 3 | #include 4 | 5 | using namespace std; 6 | 7 | int main() { 8 | int a, b, c, d; 9 | scanf("%d", &a); 10 | scanf("%d", &b); 11 | scanf("%d", &c); 12 | scanf("%d", &d); 13 | printf("DIFERENCA = %d\n", (a * b) - (c * d)); 14 | return 0; 15 | } 16 | -------------------------------------------------------------------------------- /beecrowd/1008.cpp: -------------------------------------------------------------------------------- 1 | // Ivan Carvalho 2 | // Solution to https://www.beecrowd.com.br/judge/problems/view/1008 3 | #include 4 | 5 | using namespace std; 6 | 7 | int main() { 8 | int a, b; 9 | double c; 10 | scanf("%d", &a); 11 | scanf("%d", &b); 12 | scanf("%lf", &c); 13 | printf("NUMBER = %d\nSALARY = U$ %.2lf\n", a, b * c); 14 | return 0; 15 | } 16 | -------------------------------------------------------------------------------- /beecrowd/1009.cpp: -------------------------------------------------------------------------------- 1 | // Ivan Carvalho 2 | // Solution to https://www.beecrowd.com.br/judge/problems/view/1009 3 | #include 4 | int main() { 5 | char nome[100]; 6 | double a, b; 7 | scanf("%s", nome); 8 | scanf("%lf", &a); 9 | scanf("%lf", &b); 10 | printf("TOTAL = R$ %.2lf\n", a + 0.15 * b); 11 | return 0; 12 | } 13 | -------------------------------------------------------------------------------- /beecrowd/1010.cpp: -------------------------------------------------------------------------------- 1 | // Ivan Carvalho 2 | // Solution to https://www.beecrowd.com.br/judge/problems/view/1010 3 | #include 4 | int main() { 5 | int a, b, d, e; 6 | double c, f; 7 | scanf("%d %d %lf", &a, &b, &c); 8 | scanf("%d %d %lf", &d, &e, &f); 9 | printf("VALOR A PAGAR: R$ %.2lf\n", (b * c) + (e * f)); 10 | return 0; 11 | } 12 | -------------------------------------------------------------------------------- /beecrowd/1011.cpp: -------------------------------------------------------------------------------- 1 | // Ivan Carvalho 2 | // Solution to https://www.beecrowd.com.br/judge/problems/view/1011 3 | #include 4 | int main() { 5 | int a; 6 | scanf("%d", &a); 7 | printf("VOLUME = %.3lf\n", (4.0 * a * a * a * 3.14159) / 3.0); 8 | return 0; 9 | } 10 | -------------------------------------------------------------------------------- /beecrowd/1012.cpp: -------------------------------------------------------------------------------- 1 | // Ivan Carvalho 2 | // Solution to https://www.beecrowd.com.br/judge/problems/view/1012 3 | #include 4 | int main() { 5 | double a, b, c; 6 | scanf("%lf %lf %lf", &a, &b, &c); 7 | printf( 8 | "TRIANGULO: %.3lf\nCIRCULO: %.3lf\nTRAPEZIO: %.3lf\nQUADRADO: " 9 | "%.3lf\nRETANGULO: %.3lf\n", 10 | (a * c) / 2.0, (c * c * 3.14159), (((a + b) * c) / 2.0), (b * b), 11 | (a * b)); 12 | return 0; 13 | } 14 | -------------------------------------------------------------------------------- /beecrowd/1013.cpp: -------------------------------------------------------------------------------- 1 | // Ivan Carvalho 2 | // Solution to https://www.beecrowd.com.br/judge/problems/view/1013 3 | #include 4 | 5 | using namespace std; 6 | 7 | int main() { 8 | int a, b, c; 9 | scanf("%d %d %d", &a, &b, &c); 10 | if (a >= b && a >= c) 11 | printf("%d eh o maior\n", a); 12 | else if (b >= a && b >= c) 13 | printf("%d eh o maior\n", b); 14 | else 15 | printf("%d eh o maior\n", c); 16 | return 0; 17 | } 18 | -------------------------------------------------------------------------------- /beecrowd/1014.py: -------------------------------------------------------------------------------- 1 | # Ivan Carvalho 2 | # Solution to https://www.beecrowd.com.br/judge/problems/view/1014 3 | # -*- coding: utf-8 -*- 4 | 5 | """ 6 | Escreva a sua solução aqui 7 | Code your solution here 8 | Escriba su solución aquí 9 | """ 10 | a = float(input()) 11 | b = float(input()) 12 | print("%.3f km/l" % (a / b)) 13 | -------------------------------------------------------------------------------- /beecrowd/1015.py: -------------------------------------------------------------------------------- 1 | # Ivan Carvalho 2 | # Solution to https://www.beecrowd.com.br/judge/problems/view/1015 3 | # -*- coding: utf-8 -*- 4 | 5 | """ 6 | Escreva a sua solução aqui 7 | Code your solution here 8 | Escriba su solución aquí 9 | """ 10 | a, b = [float(k) for k in input().split(" ")] 11 | c, d = [float(k) for k in input().split(" ")] 12 | print("%.4f" % (((a - c) ** 2 + (b - d) ** 2) ** 0.5)) 13 | -------------------------------------------------------------------------------- /beecrowd/1016.py: -------------------------------------------------------------------------------- 1 | # Ivan Carvalho 2 | # Solution to https://www.beecrowd.com.br/judge/problems/view/1016 3 | # -*- coding: utf-8 -*- 4 | 5 | """ 6 | Escreva a sua solução aqui 7 | Code your solution here 8 | Escriba su solución aquí 9 | """ 10 | entrada = int(input()) * 2 11 | print("%d minutos" % entrada) 12 | -------------------------------------------------------------------------------- /beecrowd/1017.py: -------------------------------------------------------------------------------- 1 | # Ivan Carvalho 2 | # Solution to https://www.beecrowd.com.br/judge/problems/view/1017 3 | # -*- coding: utf-8 -*- 4 | 5 | """ 6 | Escreva a sua solução aqui 7 | Code your solution here 8 | Escriba su solución aquí 9 | """ 10 | a = int(input()) 11 | b = int(input()) 12 | print("%.3f" % ((a * b) / 12.0)) 13 | -------------------------------------------------------------------------------- /beecrowd/1018.py: -------------------------------------------------------------------------------- 1 | # Ivan Carvalho 2 | # Solution to https://www.beecrowd.com.br/judge/problems/view/1018 3 | # -*- coding: utf-8 -*- 4 | 5 | """ 6 | Escreva a sua solução aqui 7 | Code your solution here 8 | Escriba su solución aquí 9 | """ 10 | entrada = int(input()) 11 | print(entrada) 12 | for i in [100, 50, 20, 10, 5, 2, 1]: 13 | total = int(entrada / i) 14 | print("%d nota(s) de R$ %d,00" % (total, i)) 15 | entrada -= total * i 16 | -------------------------------------------------------------------------------- /beecrowd/1019.py: -------------------------------------------------------------------------------- 1 | # Ivan Carvalho 2 | # Solution to https://www.beecrowd.com.br/judge/problems/view/1019 3 | # -*- coding: utf-8 -*- 4 | 5 | """ 6 | Escreva a sua solução aqui 7 | Code your solution here 8 | Escriba su solución aquí 9 | """ 10 | entrada = int(input()) 11 | dicio = {3600: 0, 60: 0, 1: 0} 12 | for i in [3600, 60, 1]: 13 | dicio[i] = int(entrada / i) 14 | entrada -= dicio[i] * i 15 | print("%d:%d:%d" % (dicio[3600], dicio[60], dicio[1])) 16 | -------------------------------------------------------------------------------- /beecrowd/1020.py: -------------------------------------------------------------------------------- 1 | # Ivan Carvalho 2 | # Solution to https://www.beecrowd.com.br/judge/problems/view/1020 3 | # -*- coding: utf-8 -*- 4 | 5 | """ 6 | Escreva a sua solução aqui 7 | Code your solution here 8 | Escriba su solución aquí 9 | """ 10 | entrada = int(input()) 11 | for a, b in [(365, "ano(s)"), (30, "mes(es)"), (1, "dia(s)")]: 12 | total = int(entrada / a) 13 | print("%d %s" % (total, b)) 14 | entrada -= total * a 15 | -------------------------------------------------------------------------------- /beecrowd/1026.cpp: -------------------------------------------------------------------------------- 1 | // Ivan Carvalho 2 | // Solution to https://www.beecrowd.com.br/judge/problems/view/1026 3 | #include 4 | int main() { 5 | unsigned int x, y; 6 | while (scanf("%u %u", &x, &y) != EOF) printf("%u\n", (x ^ y)); 7 | return 0; 8 | } 9 | -------------------------------------------------------------------------------- /beecrowd/1028.cpp: -------------------------------------------------------------------------------- 1 | // Ivan Carvalho 2 | // Solution to https://www.beecrowd.com.br/judge/problems/view/1028 3 | #include 4 | #include 5 | using namespace std; 6 | int gcd(int x, int y) { 7 | if (x < y) swap(x, y); 8 | if (x % y == 0) return y; 9 | return gcd(y, x % y); 10 | } 11 | int main() { 12 | int casos; 13 | scanf("%d", &casos); 14 | while (casos--) { 15 | int x, y; 16 | scanf("%d %d", &x, &y); 17 | printf("%d\n", gcd(x, y)); 18 | } 19 | return 0; 20 | } 21 | -------------------------------------------------------------------------------- /beecrowd/1030.cpp: -------------------------------------------------------------------------------- 1 | // Ivan Carvalho 2 | // Solution to https://www.beecrowd.com.br/judge/problems/view/1030 3 | #include 4 | int josephus(int n, int k) { 5 | if (n == 1) return 1; 6 | return (josephus(n - 1, k) + k - 1) % n + 1; 7 | } 8 | int main() { 9 | int cases; 10 | scanf("%d", &cases); 11 | for (int i = 1; i <= cases; i++) { 12 | int u, v; 13 | scanf("%d %d", &u, &v); 14 | printf("Case %d: %d\n", i, josephus(u, v)); 15 | } 16 | return 0; 17 | } 18 | -------------------------------------------------------------------------------- /beecrowd/1035.cpp: -------------------------------------------------------------------------------- 1 | // Ivan Carvalho 2 | // Solution to https://www.beecrowd.com.br/judge/problems/view/1035 3 | #include 4 | int main() { 5 | int a, b, c, d; 6 | scanf("%d %d %d %d", &a, &b, &c, &d); 7 | if (b > c && d > a && c + d > a + b && c > 0 && d > 0 && a % 2 == 0) 8 | printf("Valores aceitos\n"); 9 | else 10 | printf("Valores nao aceitos\n"); 11 | return 0; 12 | } 13 | -------------------------------------------------------------------------------- /beecrowd/1036.py: -------------------------------------------------------------------------------- 1 | # Ivan Carvalho 2 | # Solution to https://www.beecrowd.com.br/judge/problems/view/1036 3 | # encoding : utf-8 4 | a, b, c = [float(i) for i in input().split(" ")] 5 | delta = b**2 - 4 * a * c 6 | if delta >= 0 and a != 0: 7 | print("R1 = %.5f" % ((-1 * b + (delta**0.5)) / (2 * a))) 8 | print("R2 = %.5f" % ((-1 * b - (delta**0.5)) / (2 * a))) 9 | else: 10 | print("Impossivel calcular") 11 | -------------------------------------------------------------------------------- /beecrowd/1037.cpp: -------------------------------------------------------------------------------- 1 | // Ivan Carvalho 2 | // Solution to https://www.beecrowd.com.br/judge/problems/view/1037 3 | #include 4 | int main() { 5 | double x; 6 | scanf("%lf", &x); 7 | if (x >= 0 && x <= 100) { 8 | if (x <= 25) 9 | printf("Intervalo [0,25]\n"); 10 | else if (x <= 50) 11 | printf("Intervalo (25,50]\n"); 12 | else if (x <= 75) 13 | printf("Intervalo (50,75]\n"); 14 | else 15 | printf("Intervalo (75,100]\n"); 16 | } else 17 | printf("Fora de intervalo\n"); 18 | return 0; 19 | } 20 | -------------------------------------------------------------------------------- /beecrowd/1041.cpp: -------------------------------------------------------------------------------- 1 | // Ivan Carvalho 2 | // Solution to https://www.beecrowd.com.br/judge/problems/view/1041 3 | #include 4 | int main() { 5 | double x, y; 6 | scanf("%lf %lf", &x, &y); 7 | if (x == 0 && y == 0) 8 | printf("Origem\n"); 9 | else if (x == 0) 10 | printf("Eixo Y\n"); 11 | else if (y == 0) 12 | printf("Eixo X\n"); 13 | else if (x > 0 && y > 0) 14 | printf("Q1\n"); 15 | else if (x < 0 && y > 0) 16 | printf("Q2\n"); 17 | else if (x < 0 && y < 0) 18 | printf("Q3\n"); 19 | else 20 | printf("Q4\n"); 21 | return 0; 22 | } 23 | -------------------------------------------------------------------------------- /beecrowd/1042.py: -------------------------------------------------------------------------------- 1 | # Ivan Carvalho 2 | # Solution to https://www.beecrowd.com.br/judge/problems/view/1042 3 | # -*- coding: utf-8 -*- 4 | 5 | """ 6 | Escreva a sua solução aqui 7 | Code your solution here 8 | Escriba su solución aquí 9 | """ 10 | array = [int(i) for i in input().split(" ")] 11 | for i in sorted(array): 12 | print(i) 13 | print("") 14 | for i in array: 15 | print(i) 16 | -------------------------------------------------------------------------------- /beecrowd/1043.py: -------------------------------------------------------------------------------- 1 | # Ivan Carvalho 2 | # Solution to https://www.beecrowd.com.br/judge/problems/view/1043 3 | # encoding : utf-8 4 | a, b, c = [float(i) for i in input().split(" ")] 5 | x, y, z = sorted([a, b, c]) 6 | if z < x + y: 7 | print("Perimetro = %.1f" % (x + y + z)) 8 | else: 9 | area = (a + b) * c / 2.0 10 | print("Area = %.1f" % area) 11 | -------------------------------------------------------------------------------- /beecrowd/1044.cpp: -------------------------------------------------------------------------------- 1 | // Ivan Carvalho 2 | // Solution to https://www.beecrowd.com.br/judge/problems/view/1044 3 | #include 4 | int main() { 5 | int a, b; 6 | scanf("%d %d", &a, &b); 7 | if (a % b == 0 || b % a == 0) 8 | printf("Sao Multiplos\n"); 9 | else 10 | printf("Nao sao Multiplos\n"); 11 | return 0; 12 | } 13 | -------------------------------------------------------------------------------- /beecrowd/1046.py: -------------------------------------------------------------------------------- 1 | # Ivan Carvalho 2 | # Solution to https://www.beecrowd.com.br/judge/problems/view/1046 3 | # -*- coding: utf-8 -*- 4 | 5 | """ 6 | Escreva a sua solução aqui 7 | Code your solution here 8 | Escriba su solución aquí 9 | """ 10 | a, b = [int(i) for i in input().split(" ")] 11 | if b <= a: 12 | b += 24 13 | print("O JOGO DUROU %d HORA(S)" % (b - a)) 14 | -------------------------------------------------------------------------------- /beecrowd/1047.py: -------------------------------------------------------------------------------- 1 | # Ivan Carvalho 2 | # Solution to https://www.beecrowd.com.br/judge/problems/view/1047 3 | # encoding : utf-8 4 | a, b, c, d = [int(i) for i in input().split(" ")] 5 | minutos1 = 60 * a + b 6 | minutos2 = 60 * c + d 7 | if minutos2 <= minutos1: 8 | minutos2 += 1440 9 | minutos = minutos2 - minutos1 10 | print("O JOGO DUROU %d HORA(S) E %d MINUTO(S)" % (int(minutos / 60), minutos % 60)) 11 | -------------------------------------------------------------------------------- /beecrowd/1048.py: -------------------------------------------------------------------------------- 1 | # Ivan Carvalho 2 | # Solution to https://www.beecrowd.com.br/judge/problems/view/1048 3 | # encoding : utf-8 4 | e = float(input()) 5 | coeficiente = 0 6 | novo = 0 7 | if e <= 400: 8 | novo = e * 1.15 9 | coeficiente = 15 10 | elif e <= 800: 11 | novo = e * 1.12 12 | coeficiente = 12 13 | elif e <= 1200: 14 | novo = e * 1.1 15 | coeficiente = 10 16 | elif e <= 2000: 17 | novo = e * 1.07 18 | coeficiente = 7 19 | else: 20 | novo = e * 1.04 21 | coeficiente = 4 22 | print("Novo salario: %.2f" % novo) 23 | print("Reajuste ganho: %.2f" % (novo - e)) 24 | print("Em percentual: %d %%" % coeficiente) 25 | -------------------------------------------------------------------------------- /beecrowd/1049.py: -------------------------------------------------------------------------------- 1 | # Ivan Carvalho 2 | # Solution to https://www.beecrowd.com.br/judge/problems/view/1049 3 | # -*- coding: utf-8 -*- 4 | dicio = { 5 | "vertebrado": { 6 | "ave": {"carnivoro": "aguia", "onivoro": "pomba"}, 7 | "mamifero": {"onivoro": "homem", "herbivoro": "vaca"}, 8 | }, 9 | "invertebrado": { 10 | "inseto": {"hematofago": "pulga", "herbivoro": "lagarta"}, 11 | "anelideo": {"hematofago": "sanguessuga", "onivoro": "minhoca"}, 12 | }, 13 | } 14 | array = [] 15 | for i in range(3): 16 | array.append(input()) 17 | a, b, c = array 18 | print(dicio[a][b][c]) 19 | -------------------------------------------------------------------------------- /beecrowd/1050.py: -------------------------------------------------------------------------------- 1 | # Ivan Carvalho 2 | # Solution to https://www.beecrowd.com.br/judge/problems/view/1050 3 | # -*- coding: utf-8 -*- 4 | ddd = { 5 | 11: "Sao Paulo", 6 | 71: "Salvador", 7 | 61: "Brasilia", 8 | 21: "Rio de Janeiro", 9 | 32: "Juiz de Fora", 10 | 19: "Campinas", 11 | 27: "Vitoria", 12 | 31: "Belo Horizonte", 13 | } 14 | print(ddd.get(int(input()), "DDD nao cadastrado")) 15 | -------------------------------------------------------------------------------- /beecrowd/1051.py: -------------------------------------------------------------------------------- 1 | # Ivan Carvalho 2 | # Solution to https://www.beecrowd.com.br/judge/problems/view/1051 3 | # -*- coding: utf-8 -*- 4 | e = float(input()) 5 | if e <= 2000: 6 | print("Isento") 7 | elif e <= 3000: 8 | print("R$ %.2f" % ((e - 2000) * 0.08)) 9 | elif e <= 4500: 10 | print("R$ %.2f" % ((e - 3000) * 0.18 + 80)) 11 | else: 12 | print("R$ %.2f" % ((e - 4500) * 0.28 + 80 + 1500 * 0.18)) 13 | -------------------------------------------------------------------------------- /beecrowd/1052.py: -------------------------------------------------------------------------------- 1 | # Ivan Carvalho 2 | # Solution to https://www.beecrowd.com.br/judge/problems/view/1052 3 | # -*- coding: utf-8 -*- 4 | 5 | """ 6 | Escreva a sua solução aqui 7 | Code your solution here 8 | Escriba su solución aquí 9 | """ 10 | print( 11 | { 12 | 1: "January", 13 | 2: "February", 14 | 3: "March", 15 | 4: "April", 16 | 5: "May", 17 | 6: "June", 18 | 7: "July", 19 | 8: "August", 20 | 9: "September", 21 | 10: "October", 22 | 11: "November", 23 | 12: "December", 24 | }[int(input())] 25 | ) 26 | -------------------------------------------------------------------------------- /beecrowd/1059.py: -------------------------------------------------------------------------------- 1 | # Ivan Carvalho 2 | # Solution to https://www.beecrowd.com.br/judge/problems/view/1059 3 | # -*- coding: utf-8 -*- 4 | 5 | """ 6 | Escreva a sua solução aqui 7 | Code your solution here 8 | Escriba su solución aquí 9 | """ 10 | for i in range(2, 101, 2): 11 | print(i) 12 | -------------------------------------------------------------------------------- /beecrowd/1060.py: -------------------------------------------------------------------------------- 1 | # Ivan Carvalho 2 | # Solution to https://www.beecrowd.com.br/judge/problems/view/1060 3 | # -*- coding: utf-8 -*- 4 | 5 | """ 6 | Escreva a sua solução aqui 7 | Code your solution here 8 | Escriba su solución aquí 9 | """ 10 | count = 0 11 | for i in range(6): 12 | entrada = float(input()) 13 | count += entrada > 0 14 | print("%d valores positivos" % count) 15 | -------------------------------------------------------------------------------- /beecrowd/1064.py: -------------------------------------------------------------------------------- 1 | # Ivan Carvalho 2 | # Solution to https://www.beecrowd.com.br/judge/problems/view/1064 3 | # -*- coding: utf-8 -*- 4 | array = [] 5 | for i in range(6): 6 | entrada = float(input()) 7 | if entrada > 0: 8 | array.append(entrada) 9 | print("%d valores positivos" % len(array)) 10 | print("%.1f" % (sum(array) / float(len(array)))) 11 | -------------------------------------------------------------------------------- /beecrowd/1065.py: -------------------------------------------------------------------------------- 1 | # Ivan Carvalho 2 | # Solution to https://www.beecrowd.com.br/judge/problems/view/1065 3 | # -*- coding: utf-8 -*- 4 | 5 | """ 6 | Escreva a sua solução aqui 7 | Code your solution here 8 | Escriba su solución aquí 9 | """ 10 | array = [] 11 | for i in range(5): 12 | array.append(int(input()) % 2) 13 | print("%d valores pares" % (5 - sum(array))) 14 | -------------------------------------------------------------------------------- /beecrowd/1066.py: -------------------------------------------------------------------------------- 1 | # Ivan Carvalho 2 | # Solution to https://www.beecrowd.com.br/judge/problems/view/1066 3 | # -*- coding: utf-8 -*- 4 | array = [] 5 | for i in range(5): 6 | array.append(int(input())) 7 | for a, b in [ 8 | ("valor(es) par(es)", lambda x: x % 2 == 0), 9 | ("valor(es) impar(es)", lambda x: x % 2 == 1), 10 | ("valor(es) positivo(s)", lambda x: x > 0), 11 | ("valor(es) negativo(s)", lambda x: x < 0), 12 | ]: 13 | print("%d %s" % (len([l for l in array if b(l)]), a)) 14 | -------------------------------------------------------------------------------- /beecrowd/1067.py: -------------------------------------------------------------------------------- 1 | # Ivan Carvalho 2 | # Solution to https://www.beecrowd.com.br/judge/problems/view/1067 3 | # -*- coding: utf-8 -*- 4 | 5 | """ 6 | Escreva a sua solução aqui 7 | Code your solution here 8 | Escriba su solución aquí 9 | """ 10 | ordem = int(input()) 11 | for i in range(1, ordem + 1, 2): 12 | print(i) 13 | -------------------------------------------------------------------------------- /beecrowd/1070.py: -------------------------------------------------------------------------------- 1 | # Ivan Carvalho 2 | # Solution to https://www.beecrowd.com.br/judge/problems/view/1070 3 | # -*- coding: utf-8 -*- 4 | 5 | """ 6 | Escreva a sua solução aqui 7 | Code your solution here 8 | Escriba su solución aquí 9 | """ 10 | entrada = int(input()) 11 | if entrada % 2 == 0: 12 | entrada += 1 13 | for i in range(6): 14 | print(entrada + i * 2) 15 | -------------------------------------------------------------------------------- /beecrowd/1071.py: -------------------------------------------------------------------------------- 1 | # Ivan Carvalho 2 | # Solution to https://www.beecrowd.com.br/judge/problems/view/1071 3 | #!/usr/bin/env python 4 | # encoding : utf-8 5 | a = int(input()) 6 | b = int(input()) 7 | x, y = sorted([a, b]) 8 | if x % 2 == 1: 9 | x += 2 10 | else: 11 | x += 1 12 | print(sum(range(x, y, 2))) 13 | -------------------------------------------------------------------------------- /beecrowd/1072.py: -------------------------------------------------------------------------------- 1 | # Ivan Carvalho 2 | # Solution to https://www.beecrowd.com.br/judge/problems/view/1072 3 | # -*- coding: utf-8 -*- 4 | 5 | """ 6 | Escreva a sua solução aqui 7 | Code your solution here 8 | Escriba su solución aquí 9 | """ 10 | ordem = int(input()) 11 | dentro = 0 12 | fora = 0 13 | for j in range(ordem): 14 | i = int(input()) 15 | if i >= 10 and i <= 20: 16 | dentro += 1 17 | else: 18 | fora += 1 19 | print("%d in" % dentro) 20 | print("%d out" % fora) 21 | -------------------------------------------------------------------------------- /beecrowd/1073.py: -------------------------------------------------------------------------------- 1 | # Ivan Carvalho 2 | # Solution to https://www.beecrowd.com.br/judge/problems/view/1073 3 | # -*- coding: utf-8 -*- 4 | 5 | """ 6 | Escreva a sua solução aqui 7 | Code your solution here 8 | Escriba su solución aquí 9 | """ 10 | ordem = int(input()) 11 | for i in range(2, ordem + 1, 2): 12 | print("%d^2 = %d" % (i, i**2)) 13 | -------------------------------------------------------------------------------- /beecrowd/1074.py: -------------------------------------------------------------------------------- 1 | # Ivan Carvalho 2 | # Solution to https://www.beecrowd.com.br/judge/problems/view/1074 3 | # -*- coding: utf-8 -*- 4 | 5 | """ 6 | Escreva a sua solução aqui 7 | Code your solution here 8 | Escriba su solución aquí 9 | """ 10 | ordem = int(input()) 11 | for i in range(ordem): 12 | entrada = int(input()) 13 | if entrada == 0: 14 | print("NULL") 15 | else: 16 | parouimpar = ["EVEN", "ODD"][entrada % 2] 17 | positivoounegativo = ["NEGATIVE", "POSITIVE"][entrada > 0] 18 | print("%s %s" % (parouimpar, positivoounegativo)) 19 | -------------------------------------------------------------------------------- /beecrowd/1075.py: -------------------------------------------------------------------------------- 1 | # Ivan Carvalho 2 | # Solution to https://www.beecrowd.com.br/judge/problems/view/1075 3 | # -*- coding: utf-8 -*- 4 | 5 | """ 6 | Escreva a sua solução aqui 7 | Code your solution here 8 | Escriba su solución aquí 9 | """ 10 | entrada = int(input()) 11 | for i in range(2, 10001, entrada): 12 | print(i) 13 | -------------------------------------------------------------------------------- /beecrowd/1078.py: -------------------------------------------------------------------------------- 1 | # Ivan Carvalho 2 | # Solution to https://www.beecrowd.com.br/judge/problems/view/1078 3 | # -*- coding: utf-8 -*- 4 | 5 | """ 6 | Escreva a sua solução aqui 7 | Code your solution here 8 | Escriba su solución aquí 9 | """ 10 | entrada = int(input()) 11 | for i in range(1, 11): 12 | print("%d x %d = %d" % (i, entrada, i * entrada)) 13 | -------------------------------------------------------------------------------- /beecrowd/1079.cpp: -------------------------------------------------------------------------------- 1 | // Ivan Carvalho 2 | // Solution to https://www.beecrowd.com.br/judge/problems/view/1079 3 | #include 4 | int main() { 5 | int ordem, i; 6 | scanf("%d", &ordem); 7 | for (i = 0; i < ordem; i++) { 8 | double a, b, c; 9 | scanf("%lf %lf %lf", &a, &b, &c); 10 | printf("%.1lf\n", (2 * a + 3 * b + 5 * c) / 10.0); 11 | } 12 | return 0; 13 | } 14 | -------------------------------------------------------------------------------- /beecrowd/1080.cpp: -------------------------------------------------------------------------------- 1 | // Ivan Carvalho 2 | // Solution to https://www.beecrowd.com.br/judge/problems/view/1080 3 | #include 4 | int main() { 5 | int resposta = 0, indice = 0, i; 6 | for (i = 0; i < 100; i++) { 7 | int momento; 8 | scanf("%d", &momento); 9 | if (momento > resposta) { 10 | resposta = momento; 11 | indice = i; 12 | } 13 | } 14 | printf("%d\n%d\n", resposta, indice + 1); 15 | return 0; 16 | } 17 | -------------------------------------------------------------------------------- /beecrowd/1087.py: -------------------------------------------------------------------------------- 1 | # Ivan Carvalho 2 | # Solution to https://www.beecrowd.com.br/judge/problems/view/1087 3 | #!/usr/bin/env python 4 | # encoding : utf-8 5 | while True: 6 | a, b, c, d = [int(i) for i in input().split(" ")] 7 | diferencax = abs(a - c) 8 | diferencay = abs(b - d) 9 | if a == 0 and b == 0 and c == 0 and d == 0: 10 | break 11 | else: 12 | if a == c and b == d: 13 | print(0) 14 | elif a == c or b == d: 15 | print(1) 16 | elif diferencax == diferencay: 17 | print(1) 18 | else: 19 | print(2) 20 | -------------------------------------------------------------------------------- /beecrowd/1089.cpp: -------------------------------------------------------------------------------- 1 | // Ivan Carvalho 2 | // Solution to https://www.beecrowd.com.br/judge/problems/view/1089 3 | #include 4 | int vetor[100001]; 5 | int main() { 6 | int n; 7 | while (scanf("%d", &n) && n) { 8 | for (int i = 1; i <= n; i++) { 9 | scanf("%d", &vetor[i]); 10 | } 11 | vetor[0] = vetor[n]; 12 | vetor[n + 1] = vetor[1]; 13 | int resp = 0; 14 | for (int i = 1; i <= n; i++) { 15 | resp += int(vetor[i - 1] < vetor[i] && vetor[i] > vetor[i + 1]); 16 | } 17 | printf("%d\n", 2 * resp); 18 | } 19 | return 0; 20 | } 21 | -------------------------------------------------------------------------------- /beecrowd/1095.py: -------------------------------------------------------------------------------- 1 | # Ivan Carvalho 2 | # Solution to https://www.beecrowd.com.br/judge/problems/view/1095 3 | # -*- coding: utf-8 -*- 4 | 5 | """ 6 | Escreva a sua solução aqui 7 | Code your solution here 8 | Escriba su solución aquí 9 | """ 10 | i = 1 11 | j = 60 12 | while j >= 0: 13 | print("I=%d J=%d" % (i, j)) 14 | i += 3 15 | j -= 5 16 | -------------------------------------------------------------------------------- /beecrowd/1096.py: -------------------------------------------------------------------------------- 1 | # Ivan Carvalho 2 | # Solution to https://www.beecrowd.com.br/judge/problems/view/1096 3 | # -*- coding: utf-8 -*- 4 | 5 | """ 6 | Escreva a sua solução aqui 7 | Code your solution here 8 | Escriba su solución aquí 9 | """ 10 | i = 1 11 | while i <= 9: 12 | for j in [7, 6, 5]: 13 | print("I=%d J=%d" % (i, j)) 14 | i += 2 15 | -------------------------------------------------------------------------------- /beecrowd/1097.py: -------------------------------------------------------------------------------- 1 | # Ivan Carvalho 2 | # Solution to https://www.beecrowd.com.br/judge/problems/view/1097 3 | # -*- coding: utf-8 -*- 4 | i = 1 5 | j = 7 6 | while i <= 9: 7 | print("I=%d J=%d" % (i, j)) 8 | print("I=%d J=%d" % (i, j - 1)) 9 | print("I=%d J=%d" % (i, j - 2)) 10 | i += 2 11 | j += 2 12 | -------------------------------------------------------------------------------- /beecrowd/1098.py: -------------------------------------------------------------------------------- 1 | # Ivan Carvalho 2 | # Solution to https://www.beecrowd.com.br/judge/problems/view/1098 3 | # -*- coding: utf-8 -*- 4 | def b(numero): 5 | if numero % 1 == 0: 6 | return str(int(numero)) 7 | else: 8 | return str(numero) 9 | 10 | 11 | i = 0 12 | j = 10 13 | while i <= 20: 14 | print("I=%s J=%s" % (b(i / 10.0), b(j / 10.0))) 15 | print("I=%s J=%s" % (b(i / 10.0), b((j + 10) / 10.0))) 16 | print("I=%s J=%s" % (b(i / 10.0), b((j + 20) / 10.0))) 17 | i += 2 18 | j += 2 19 | -------------------------------------------------------------------------------- /beecrowd/1101.py: -------------------------------------------------------------------------------- 1 | # Ivan Carvalho 2 | # Solution to https://www.beecrowd.com.br/judge/problems/view/1101 3 | #!/usr/bin/env python 4 | # encoding : utf-8 5 | while True: 6 | a, b = sorted([int(i) for i in input().split(" ")]) 7 | if a <= 0 or b <= 0: 8 | break 9 | else: 10 | print( 11 | "%s Sum=%d" 12 | % (str(list(range(a, b + 1)))[1:-1].replace(",", ""), sum(range(a, b + 1))) 13 | ) 14 | -------------------------------------------------------------------------------- /beecrowd/1103.py: -------------------------------------------------------------------------------- 1 | # Ivan Carvalho 2 | # Solution to https://www.beecrowd.com.br/judge/problems/view/1103 3 | #!/usr/bin/env python 4 | # encoding : utf-8 5 | while True: 6 | a, b, c, d = [int(i) for i in input().split(" ")] 7 | if a == 0 and b == 0 and c == 0 and d == 0: 8 | break 9 | else: 10 | inicial = a * 60 + b 11 | final = c * 60 + d 12 | if final <= inicial: 13 | final += 24 * 60 14 | print(final - inicial) 15 | -------------------------------------------------------------------------------- /beecrowd/1107.cpp: -------------------------------------------------------------------------------- 1 | // Ivan Carvalho 2 | // Solution to https://www.beecrowd.com.br/judge/problems/view/1107 3 | #include 4 | #define MAXN 10010 5 | int vetor[MAXN], a, c, auxiliar[MAXN]; 6 | int main() { 7 | while (scanf("%d %d", &a, &c) && (a || c)) { 8 | for (int i = 1; i <= c; i++) { 9 | scanf("%d", &vetor[i]); 10 | } 11 | int resp = a - vetor[1]; 12 | for (int i = 2; i <= c; i++) { 13 | if (vetor[i] < vetor[i - 1]) { 14 | resp += vetor[i - 1] - vetor[i]; 15 | } 16 | } 17 | printf("%d\n", resp); 18 | } 19 | return 0; 20 | } 21 | -------------------------------------------------------------------------------- /beecrowd/1113.cpp: -------------------------------------------------------------------------------- 1 | // Ivan Carvalho 2 | // Solution to https://www.beecrowd.com.br/judge/problems/view/1113 3 | #include 4 | int main() { 5 | while (1) { 6 | int x, y; 7 | scanf("%d %d", &x, &y); 8 | if (x == y) 9 | break; 10 | else if (x > y) 11 | printf("Decrescente\n"); 12 | else 13 | printf("Crescente\n"); 14 | } 15 | return 0; 16 | } 17 | -------------------------------------------------------------------------------- /beecrowd/1114.cpp: -------------------------------------------------------------------------------- 1 | // Ivan Carvalho 2 | // Solution to https://www.beecrowd.com.br/judge/problems/view/1114 3 | #include 4 | int main() { 5 | int x; 6 | while (1) { 7 | scanf("%d", &x); 8 | if (x == 2002) 9 | break; 10 | else 11 | printf("Senha Invalida\n"); 12 | } 13 | printf("Acesso Permitido\n"); 14 | return 0; 15 | } 16 | -------------------------------------------------------------------------------- /beecrowd/1115.py: -------------------------------------------------------------------------------- 1 | # Ivan Carvalho 2 | # Solution to https://www.beecrowd.com.br/judge/problems/view/1115 3 | # -*- coding: utf-8 -*- 4 | 5 | """ 6 | Escreva a sua solução aqui 7 | Code your solution here 8 | Escriba su solución aquí 9 | """ 10 | while True: 11 | x, y = [int(k) for k in input().split(" ")] 12 | if x == 0 or y == 0: 13 | break 14 | else: 15 | if x > 0 and y > 0: 16 | print("primeiro") 17 | elif x < 0 and y > 0: 18 | print("segundo") 19 | elif x < 0 and y < 0: 20 | print("terceiro") 21 | else: 22 | print("quarto") 23 | -------------------------------------------------------------------------------- /beecrowd/1116.py: -------------------------------------------------------------------------------- 1 | # Ivan Carvalho 2 | # Solution to https://www.beecrowd.com.br/judge/problems/view/1116 3 | # -*- coding: utf-8 -*- 4 | 5 | """ 6 | Escreva a sua solução aqui 7 | Code your solution here 8 | Escriba su solución aquí 9 | """ 10 | ordem = int(input()) 11 | for onomatopeia in range(ordem): 12 | a, b = [float(i) for i in input().split(" ")] 13 | try: 14 | print("%.1f" % (a / b)) 15 | except ZeroDivisionError: 16 | print("divisao impossivel") 17 | -------------------------------------------------------------------------------- /beecrowd/1117.py: -------------------------------------------------------------------------------- 1 | # Ivan Carvalho 2 | # Solution to https://www.beecrowd.com.br/judge/problems/view/1117 3 | # -*- coding: utf-8 -*- 4 | 5 | """ 6 | Escreva a sua solução aqui 7 | Code your solution here 8 | Escriba su solución aquí 9 | """ 10 | array = [] 11 | while True: 12 | entrada = float(input()) 13 | if entrada >= 0 and entrada <= 10: 14 | array.append(entrada) 15 | else: 16 | print("nota invalida") 17 | if len(array) == 2: 18 | print("media = %.2f" % (sum(array) / 2.0)) 19 | break 20 | -------------------------------------------------------------------------------- /beecrowd/1129.py: -------------------------------------------------------------------------------- 1 | # Ivan Carvalho 2 | # Solution to https://www.beecrowd.com.br/judge/problems/view/1129 3 | #!/usr/bin/env python 4 | # -*- coding : utf-8 5 | while True: 6 | a = int(input()) 7 | if a == 0: 8 | break 9 | for i in range(a): 10 | entrada = [int(i) <= 127 for i in input().split()] 11 | if entrada.count(True) == 1: 12 | print("ABCDE"[entrada.index(True)]) 13 | else: 14 | print("*") 15 | -------------------------------------------------------------------------------- /beecrowd/1132.py: -------------------------------------------------------------------------------- 1 | # Ivan Carvalho 2 | # Solution to https://www.beecrowd.com.br/judge/problems/view/1132 3 | #!/usr/bin/env python 4 | # encoding : utf-8 5 | entrada1 = int(input()) 6 | entrada2 = int(input()) 7 | a, b = sorted([entrada1, entrada2]) 8 | 9 | 10 | def soma(x): 11 | return ((x) * (x + 1)) / 2 12 | 13 | 14 | def multiplo(y): 15 | if y % 13 == 0: 16 | return y 17 | else: 18 | return y - (y % 13) + 13 19 | 20 | 21 | print(soma(b) - (sum([i for i in range(multiplo(a), b + 1, 13)]) + soma(a - 1))) 22 | -------------------------------------------------------------------------------- /beecrowd/1133.py: -------------------------------------------------------------------------------- 1 | # Ivan Carvalho 2 | # Solution to https://www.beecrowd.com.br/judge/problems/view/1133 3 | #!/usr/bin/env python 4 | # encoding : utf-8 5 | a = int(input()) 6 | b = int(input()) 7 | x, y = sorted([a, b]) 8 | for i in [k for k in range(x + 1, y) if k % 5 == 2 or k % 5 == 3]: 9 | print(i) 10 | -------------------------------------------------------------------------------- /beecrowd/1134.py: -------------------------------------------------------------------------------- 1 | # Ivan Carvalho 2 | # Solution to https://www.beecrowd.com.br/judge/problems/view/1134 3 | #!/usr/bin/env python 4 | # encoding : utf-8 5 | dicio = {1: 0, 2: 0, 3: 0} 6 | while True: 7 | entrada = int(input()) 8 | if entrada in [1, 2, 3]: 9 | dicio[entrada] += 1 10 | elif entrada == 4: 11 | print("MUITO OBRIGADO") 12 | print("Alcool: %d" % dicio[1]) 13 | print("Gasolina: %d" % dicio[2]) 14 | print("Diesel: %d" % dicio[3]) 15 | break 16 | -------------------------------------------------------------------------------- /beecrowd/1140.py: -------------------------------------------------------------------------------- 1 | # Ivan Carvalho 2 | # Solution to https://www.beecrowd.com.br/judge/problems/view/1140 3 | #!/usr/bin/env python 4 | # -*- coding : utf-8 -*- 5 | while True: 6 | entrada = input() 7 | if entrada == "*": 8 | break 9 | if len(set([k[0].lower() for k in entrada.split()])) == 1: 10 | print("Y") 11 | else: 12 | print("N") 13 | -------------------------------------------------------------------------------- /beecrowd/1142.py: -------------------------------------------------------------------------------- 1 | # Ivan Carvalho 2 | # Solution to https://www.beecrowd.com.br/judge/problems/view/1142 3 | #!/usr/bin/env python 4 | # encoding : utf-8 5 | ordem = int(input()) 6 | i = 1 7 | count = 0 8 | while count < ordem: 9 | print("%d %d %d PUM" % (i, i + 1, i + 2)) 10 | i += 4 11 | count += 1 12 | -------------------------------------------------------------------------------- /beecrowd/1143.py: -------------------------------------------------------------------------------- 1 | # Ivan Carvalho 2 | # Solution to https://www.beecrowd.com.br/judge/problems/view/1143 3 | # -*- coding: utf-8 -*- 4 | 5 | """ 6 | Escreva a sua solução aqui 7 | Code your solution here 8 | Escriba su solución aquí 9 | """ 10 | ordem = int(input()) 11 | for i in range(1, ordem + 1): 12 | print("%d %d %d" % (i, i**2, i**3)) 13 | -------------------------------------------------------------------------------- /beecrowd/1144.py: -------------------------------------------------------------------------------- 1 | # Ivan Carvalho 2 | # Solution to https://www.beecrowd.com.br/judge/problems/view/1144 3 | #!/usr/bin/env python 4 | # encoding : utf-8 5 | ordem = int(input()) 6 | for i in range(1, ordem + 1): 7 | print("%d %d %d" % (i, i**2, i**3)) 8 | print("%d %d %d" % (i, i**2 + 1, i**3 + 1)) 9 | -------------------------------------------------------------------------------- /beecrowd/1145.py: -------------------------------------------------------------------------------- 1 | # Ivan Carvalho 2 | # Solution to https://www.beecrowd.com.br/judge/problems/view/1145 3 | #!/usr/bin/env python 4 | a, b = [int(i) for i in input().split(" ")] 5 | for i in range(1, b + 1, a): 6 | array = [] 7 | for j in range(0, a): 8 | array.append(j + i) 9 | print(" ".join([str(f) for f in array if f <= b])) 10 | -------------------------------------------------------------------------------- /beecrowd/1146.py: -------------------------------------------------------------------------------- 1 | # Ivan Carvalho 2 | # Solution to https://www.beecrowd.com.br/judge/problems/view/1146 3 | #!/usr/bin/env python 4 | # encoding : utf-8 5 | while True: 6 | entrada = int(input()) 7 | if entrada == 0: 8 | break 9 | else: 10 | print(" ".join([str(i) for i in range(1, entrada + 1)])) 11 | -------------------------------------------------------------------------------- /beecrowd/1149.cpp: -------------------------------------------------------------------------------- 1 | // Ivan Carvalho 2 | // Solution to https://www.beecrowd.com.br/judge/problems/view/1149 3 | #include 4 | int main() { 5 | int resposta = 0, a, n = -1; 6 | scanf("%d", &a); 7 | while (n <= 0) scanf("%d", &n); 8 | while (n--) { 9 | resposta += a; 10 | a++; 11 | } 12 | printf("%d\n", resposta); 13 | return 0; 14 | } 15 | -------------------------------------------------------------------------------- /beecrowd/1150.cpp: -------------------------------------------------------------------------------- 1 | // Ivan Carvalho 2 | // Solution to https://www.beecrowd.com.br/judge/problems/view/1150 3 | #include 4 | #define MENOSINFINITO -2147483647 5 | int main() { 6 | int x, z = MENOSINFINITO, temp = 0, resposta = 0; 7 | scanf("%d", &x); 8 | while (z <= x) scanf("%d", &z); 9 | while (temp < z) { 10 | resposta++; 11 | temp += x; 12 | x++; 13 | } 14 | printf("%d\n", resposta); 15 | return 0; 16 | } 17 | -------------------------------------------------------------------------------- /beecrowd/1151.py: -------------------------------------------------------------------------------- 1 | # Ivan Carvalho 2 | # Solution to https://www.beecrowd.com.br/judge/problems/view/1151 3 | #!/usr/bin/env python 4 | # encoding : utf-8 5 | fib = [0, 1, 1] 6 | maximo = int(input()) 7 | for i in range(3, maximo): 8 | fib.append(fib[i - 1] + fib[i - 2]) 9 | print(" ".join([str(k) for k in fib])) 10 | -------------------------------------------------------------------------------- /beecrowd/1153.py: -------------------------------------------------------------------------------- 1 | # Ivan Carvalho 2 | # Solution to https://www.beecrowd.com.br/judge/problems/view/1153 3 | #!/usr/bin/env python 4 | # encoding : utf-8 5 | def fatorial(x): 6 | if x == 0: 7 | return 1 8 | else: 9 | return x * fatorial(x - 1) 10 | 11 | 12 | print(fatorial(int(input()))) 13 | -------------------------------------------------------------------------------- /beecrowd/1154.py: -------------------------------------------------------------------------------- 1 | # Ivan Carvalho 2 | # Solution to https://www.beecrowd.com.br/judge/problems/view/1154 3 | #!/usr/bin/env python 4 | # encoding : utf-8 5 | array = [] 6 | while True: 7 | entrada = int(input()) 8 | if entrada < 0: 9 | break 10 | else: 11 | array.append(entrada) 12 | print("%.2f" % (sum(array) / float(len(array)))) 13 | -------------------------------------------------------------------------------- /beecrowd/1155.py: -------------------------------------------------------------------------------- 1 | # Ivan Carvalho 2 | # Solution to https://www.beecrowd.com.br/judge/problems/view/1155 3 | #!/usr/bin/env python 4 | # encoding : utf-8 5 | print("%.2f" % (sum([1.0 / float(i) for i in range(1, 101)]))) 6 | -------------------------------------------------------------------------------- /beecrowd/1156.py: -------------------------------------------------------------------------------- 1 | # Ivan Carvalho 2 | # Solution to https://www.beecrowd.com.br/judge/problems/view/1156 3 | #!/usr/bin/env python 4 | # encoding : utf-8 5 | print( 6 | "%.2f" 7 | % ( 8 | sum( 9 | [ 10 | float(i) / float(2**j) 11 | for i, j in zip(list(range(1, 40, 2)), list(range(20))) 12 | ] 13 | ) 14 | ) 15 | ) 16 | -------------------------------------------------------------------------------- /beecrowd/1157.py: -------------------------------------------------------------------------------- 1 | # Ivan Carvalho 2 | # Solution to https://www.beecrowd.com.br/judge/problems/view/1157 3 | #!/usr/bin/env python 4 | # encoding : utf-8 5 | x = int(input()) 6 | for i in [k for k in range(1, int(x / 2) + 1) if x % k == 0] + [x]: 7 | print(i) 8 | -------------------------------------------------------------------------------- /beecrowd/1158.py: -------------------------------------------------------------------------------- 1 | # Ivan Carvalho 2 | # Solution to https://www.beecrowd.com.br/judge/problems/view/1158 3 | #!/usr/bin/env python 4 | # encoding : utf-8 5 | ordem = int(input()) 6 | for i in range(ordem): 7 | a, b = [int(i) for i in input().split(" ") if i != ""] 8 | if a % 2 == 0: 9 | a += 1 10 | soma = 0 11 | count = 0 12 | while count < b: 13 | soma += a 14 | count += 1 15 | a += 2 16 | print(soma) 17 | -------------------------------------------------------------------------------- /beecrowd/1159.cpp: -------------------------------------------------------------------------------- 1 | // Ivan Carvalho 2 | // Solution to https://www.beecrowd.com.br/judge/problems/view/1159 3 | #include 4 | int main() { 5 | int n; 6 | while (scanf("%d", &n) && n) { 7 | if (n % 2) n++; 8 | printf("%d\n", 5 * n + 20); 9 | } 10 | return 0; 11 | } 12 | -------------------------------------------------------------------------------- /beecrowd/1161.py: -------------------------------------------------------------------------------- 1 | # Ivan Carvalho 2 | # Solution to https://www.beecrowd.com.br/judge/problems/view/1161 3 | # -*- coding: utf-8 -*- 4 | 5 | """ 6 | Escreva a sua solução aqui 7 | Code your solution here 8 | Escriba su solución aquí 9 | """ 10 | 11 | 12 | def fatorial(x): 13 | if x == 0: 14 | return 1 15 | else: 16 | return x * fatorial(x - 1) 17 | 18 | 19 | while True: 20 | try: 21 | a, b = [int(k) for k in input().split(" ")] 22 | print(fatorial(a) + fatorial(b)) 23 | except EOFError: 24 | break 25 | -------------------------------------------------------------------------------- /beecrowd/1164.py: -------------------------------------------------------------------------------- 1 | # Ivan Carvalho 2 | # Solution to https://www.beecrowd.com.br/judge/problems/view/1164 3 | # -*- coding: utf-8 -*- 4 | 5 | """ 6 | Escreva a sua solução aqui 7 | Code your solution here 8 | Escriba su solución aquí 9 | """ 10 | ordem = int(input()) 11 | 12 | 13 | def divisores(x): 14 | return [k for k in range(1, int(x / 2) + 1) if x % k == 0] 15 | 16 | 17 | for i in range(ordem): 18 | entrada = int(input()) 19 | if sum(divisores(entrada)) == entrada: 20 | print("%d eh perfeito" % entrada) 21 | else: 22 | print("%d nao eh perfeito" % entrada) 23 | -------------------------------------------------------------------------------- /beecrowd/1170.py: -------------------------------------------------------------------------------- 1 | # Ivan Carvalho 2 | # Solution to https://www.beecrowd.com.br/judge/problems/view/1170 3 | # -*- coding: utf-8 -*- 4 | from math import ceil as teto 5 | from math import log10 as log 6 | 7 | log2 = lambda x: log(x) / log(2) 8 | ordem = int(input()) 9 | for i in range(ordem): 10 | entradalinha = float(input()) 11 | print("%d dias" % int(teto(log2(entradalinha)))) 12 | -------------------------------------------------------------------------------- /beecrowd/1171.py: -------------------------------------------------------------------------------- 1 | # Ivan Carvalho 2 | # Solution to https://www.beecrowd.com.br/judge/problems/view/1171 3 | #!/usr/bin/env python 4 | # -*- coding : utf-8 -*- 5 | from collections import Counter 6 | 7 | total = int(input()) 8 | contador = Counter() 9 | for i in range(total): 10 | contador[int(input())] += 1 11 | for a, b in sorted(contador.most_common()): 12 | print("%d aparece %d vez(es)" % (a, b)) 13 | -------------------------------------------------------------------------------- /beecrowd/1172.cpp: -------------------------------------------------------------------------------- 1 | // Ivan Carvalho 2 | // Solution to https://www.beecrowd.com.br/judge/problems/view/1172 3 | #include 4 | int main() { 5 | int i; 6 | for (i = 0; i < 10; i++) { 7 | int davez; 8 | scanf("%d", &davez); 9 | if (davez <= 0) 10 | printf("X[%d] = 1\n", i); 11 | else 12 | printf("X[%d] = %d\n", i, davez); 13 | } 14 | return 0; 15 | } 16 | -------------------------------------------------------------------------------- /beecrowd/1173.py: -------------------------------------------------------------------------------- 1 | # Ivan Carvalho 2 | # Solution to https://www.beecrowd.com.br/judge/problems/view/1173 3 | #!/usr/bin/env python 4 | # encoding : utf-8 5 | entrada = int(input()) 6 | array = [entrada * (2**i) for i in range(10)] 7 | for a, b in enumerate(array): 8 | print("N[%d] = %d" % (a, b)) 9 | -------------------------------------------------------------------------------- /beecrowd/1174.py: -------------------------------------------------------------------------------- 1 | # Ivan Carvalho 2 | # Solution to https://www.beecrowd.com.br/judge/problems/view/1174 3 | #!/usr/bin/env python 4 | # encoding : utf-8 5 | array = [] 6 | for i in range(100): 7 | array.append(float(input())) 8 | for a, b in enumerate(array): 9 | if b <= 10: 10 | print("A[%d] = %.1f" % (a, b)) 11 | -------------------------------------------------------------------------------- /beecrowd/1175.cpp: -------------------------------------------------------------------------------- 1 | // Ivan Carvalho 2 | // Solution to https://www.beecrowd.com.br/judge/problems/view/1175 3 | #include 4 | int main() { 5 | int vetor[20]; 6 | int i; 7 | for (i = 0; i < 20; i++) { 8 | scanf("%d", &vetor[i]); 9 | } 10 | for (i = 0; i < 20; i++) { 11 | printf("N[%d] = %d\n", i, vetor[19 - i]); 12 | } 13 | return 0; 14 | } 15 | -------------------------------------------------------------------------------- /beecrowd/1176.py: -------------------------------------------------------------------------------- 1 | # Ivan Carvalho 2 | # Solution to https://www.beecrowd.com.br/judge/problems/view/1176 3 | #!/usr/bin/env python 4 | ordem = int(input()) 5 | array = [] 6 | for i in range(ordem): 7 | array.append(int(input())) 8 | fib = [0, 1, 1] 9 | maximo = max(array) 10 | for i in range(3, maximo + 1): 11 | fib.append(fib[i - 1] + fib[i - 2]) 12 | for number in array: 13 | print("Fib(%d) = %d" % (number, fib[number])) 14 | -------------------------------------------------------------------------------- /beecrowd/1177.cpp: -------------------------------------------------------------------------------- 1 | // Ivan Carvalho 2 | // Solution to https://www.beecrowd.com.br/judge/problems/view/1177 3 | #include 4 | int main() { 5 | int i, a, davez = 0; 6 | scanf("%d", &a); 7 | for (i = 0; i < 1000; i++) { 8 | davez = davez % a; 9 | printf("N[%d] = %d\n", i, davez); 10 | davez++; 11 | } 12 | return 0; 13 | } 14 | -------------------------------------------------------------------------------- /beecrowd/1178.cpp: -------------------------------------------------------------------------------- 1 | // Ivan Carvalho 2 | // Solution to https://www.beecrowd.com.br/judge/problems/view/1178 3 | #include 4 | int main() { 5 | int i; 6 | double a; 7 | scanf("%lf", &a); 8 | for (i = 0; i < 100; i++) { 9 | printf("N[%d] = %.4lf\n", i, a); 10 | a = a / 2.0; 11 | } 12 | return 0; 13 | } 14 | -------------------------------------------------------------------------------- /beecrowd/1180.cpp: -------------------------------------------------------------------------------- 1 | // Ivan Carvalho 2 | // Solution to https://www.beecrowd.com.br/judge/problems/view/1180 3 | #include 4 | int main() { 5 | int a, i, resp = 0, pos = 0; 6 | scanf("%d", &a); 7 | scanf("%d", &resp); 8 | for (i = 1; i < a; i++) { 9 | int davez; 10 | scanf("%d", &davez); 11 | if (davez < resp) { 12 | pos = i; 13 | resp = davez; 14 | } 15 | } 16 | printf("Menor valor: %d\nPosicao: %d\n", resp, pos); 17 | return 0; 18 | } 19 | -------------------------------------------------------------------------------- /beecrowd/1181.py: -------------------------------------------------------------------------------- 1 | # Ivan Carvalho 2 | # Solution to https://www.beecrowd.com.br/judge/problems/view/1181 3 | #!/usr/bin/env python 4 | linha = int(input()) 5 | array = [[0 for j in range(12)] for k in range(12)] 6 | operacao = input() 7 | for p in range(12): 8 | for k in range(12): 9 | array[p][k] = float(input()) 10 | if operacao == "S": 11 | print("%.1f" % (sum(array[linha]))) 12 | else: 13 | print("%.1f" % (sum(array[linha]) / 12.0)) 14 | -------------------------------------------------------------------------------- /beecrowd/1182.py: -------------------------------------------------------------------------------- 1 | # Ivan Carvalho 2 | # Solution to https://www.beecrowd.com.br/judge/problems/view/1182 3 | #!/usr/bin/env python 4 | linha = int(input()) 5 | array = [[0 for j in range(12)] for k in range(12)] 6 | operacao = input() 7 | for p in range(12): 8 | for k in range(12): 9 | array[p][k] = float(input()) 10 | matriz = list(zip(*array)) 11 | if operacao == "S": 12 | print("%.1f" % (sum(matriz[linha]))) 13 | else: 14 | print("%.1f" % (sum(matriz[linha]) / 12.0)) 15 | -------------------------------------------------------------------------------- /beecrowd/1183.py: -------------------------------------------------------------------------------- 1 | # Ivan Carvalho 2 | # Solution to https://www.beecrowd.com.br/judge/problems/view/1183 3 | #!/usr/bin/env python 4 | array = [[0 for j in range(12)] for k in range(12)] 5 | operacao = input() 6 | count = 0 7 | for p in range(12): 8 | for k in range(12): 9 | e = float(input()) 10 | if k > p: 11 | array[p][k] = e 12 | count += 1 13 | if operacao == "S": 14 | print("%.1f" % (sum([sum(x) for x in array]))) 15 | else: 16 | print("%.1f" % (sum([sum(x) for x in array]) / float(count))) 17 | -------------------------------------------------------------------------------- /beecrowd/1184.py: -------------------------------------------------------------------------------- 1 | # Ivan Carvalho 2 | # Solution to https://www.beecrowd.com.br/judge/problems/view/1184 3 | #!/usr/bin/env python 4 | array = [[0 for j in range(12)] for k in range(12)] 5 | operacao = input() 6 | count = 0 7 | for p in range(12): 8 | for k in range(12): 9 | e = float(input()) 10 | if p > k: 11 | array[p][k] = e 12 | count += 1 13 | if operacao == "S": 14 | print("%.1f" % (sum([sum(x) for x in array]))) 15 | else: 16 | print("%.1f" % (sum([sum(x) for x in array]) / float(count))) 17 | -------------------------------------------------------------------------------- /beecrowd/1185.py: -------------------------------------------------------------------------------- 1 | # Ivan Carvalho 2 | # Solution to https://www.beecrowd.com.br/judge/problems/view/1185 3 | #!/usr/bin/env python 4 | array = [[0 for j in range(12)] for k in range(12)] 5 | operacao = input() 6 | count = 0 7 | for p in range(12): 8 | for k in range(12): 9 | e = float(input()) 10 | if p + k <= 10: 11 | array[p][k] = e 12 | count += 1 13 | if operacao == "S": 14 | print("%.1f" % (sum([sum(x) for x in array]))) 15 | else: 16 | print("%.1f" % (sum([sum(x) for x in array]) / float(count))) 17 | -------------------------------------------------------------------------------- /beecrowd/1186.py: -------------------------------------------------------------------------------- 1 | # Ivan Carvalho 2 | # Solution to https://www.beecrowd.com.br/judge/problems/view/1186 3 | #!/usr/bin/env python 4 | array = [[0 for j in range(12)] for k in range(12)] 5 | operacao = input() 6 | count = 0 7 | for p in range(12): 8 | for k in range(12): 9 | e = float(input()) 10 | if p + k >= 12: 11 | array[p][k] = e 12 | count += 1 13 | if operacao == "S": 14 | print("%.1f" % (sum([sum(x) for x in array]))) 15 | else: 16 | print("%.1f" % (sum([sum(x) for x in array]) / float(count))) 17 | -------------------------------------------------------------------------------- /beecrowd/1187.py: -------------------------------------------------------------------------------- 1 | # Ivan Carvalho 2 | # Solution to https://www.beecrowd.com.br/judge/problems/view/1187 3 | #!/usr/bin/env python 4 | array = [[0 for j in range(12)] for k in range(12)] 5 | operacao = input() 6 | count = 0 7 | for p in range(12): 8 | for k in range(12): 9 | e = float(input()) 10 | if p + k <= 10 and k > p: 11 | array[p][k] = e 12 | count += 1 13 | if operacao == "S": 14 | print("%.1f" % (sum([sum(x) for x in array]))) 15 | else: 16 | print("%.1f" % (sum([sum(x) for x in array]) / float(count))) 17 | -------------------------------------------------------------------------------- /beecrowd/1188.py: -------------------------------------------------------------------------------- 1 | # Ivan Carvalho 2 | # Solution to https://www.beecrowd.com.br/judge/problems/view/1188 3 | #!/usr/bin/env python 4 | # encoding : utf-8 5 | array = [[0 for j in range(12)] for k in range(12)] 6 | operacao = input() 7 | count = 0 8 | for p in range(12): 9 | for k in range(12): 10 | e = float(input()) 11 | if p + k >= 12 and k < p: 12 | array[p][k] = e 13 | count += 1 14 | if operacao == "S": 15 | print("%.1f" % (sum([sum(x) for x in array]))) 16 | else: 17 | print("%.1f" % (sum([sum(x) for x in array]) / float(count))) 18 | -------------------------------------------------------------------------------- /beecrowd/1189.py: -------------------------------------------------------------------------------- 1 | # Ivan Carvalho 2 | # Solution to https://www.beecrowd.com.br/judge/problems/view/1189 3 | #!/usr/bin/env python 4 | # encoding : utf-8 5 | array = [[0 for j in range(12)] for k in range(12)] 6 | operacao = input() 7 | count = 0 8 | for p in range(12): 9 | for k in range(12): 10 | e = float(input()) 11 | if p + k <= 10 and p > k: 12 | array[p][k] = e 13 | count += 1 14 | if operacao == "S": 15 | print("%.1f" % (sum([sum(x) for x in array]))) 16 | else: 17 | print("%.1f" % (sum([sum(x) for x in array]) / float(count))) 18 | -------------------------------------------------------------------------------- /beecrowd/1190.py: -------------------------------------------------------------------------------- 1 | # Ivan Carvalho 2 | # Solution to https://www.beecrowd.com.br/judge/problems/view/1190 3 | #!/usr/bin/env python 4 | # encoding : utf-8 5 | array = [[0 for j in range(12)] for k in range(12)] 6 | operacao = input() 7 | count = 0 8 | for p in range(12): 9 | for k in range(12): 10 | e = float(input()) 11 | if p + k >= 12 and p < k: 12 | array[p][k] = e 13 | count += 1 14 | if operacao == "S": 15 | print("%.1f" % (sum([sum(x) for x in array]))) 16 | else: 17 | print("%.1f" % (sum([sum(x) for x in array]) / float(count))) 18 | -------------------------------------------------------------------------------- /beecrowd/1192.cpp: -------------------------------------------------------------------------------- 1 | // Ivan Carvalho 2 | // Solution to https://www.beecrowd.com.br/judge/problems/view/1192 3 | #include 4 | #include 5 | int main() { 6 | int casos; 7 | scanf("%d", &casos); 8 | while (casos--) { 9 | char davez[4]; 10 | scanf("%s", davez); 11 | int a = int(davez[0] - '1' + 1), b = int(davez[2] - '1' + 1); 12 | if (a == b) 13 | printf("%d\n", a * a); 14 | else if (toupper(davez[1]) == davez[1]) 15 | printf("%d\n", b - a); 16 | else 17 | printf("%d\n", a + b); 18 | } 19 | return 0; 20 | } 21 | -------------------------------------------------------------------------------- /beecrowd/1197.py: -------------------------------------------------------------------------------- 1 | # Ivan Carvalho 2 | # Solution to https://www.beecrowd.com.br/judge/problems/view/1197 3 | # -*- coding: utf-8 -*- 4 | while True: 5 | try: 6 | a, b = [int(i) for i in input().split(" ")] 7 | print(2 * a * b) 8 | except EOFError: 9 | break 10 | -------------------------------------------------------------------------------- /beecrowd/1198.py: -------------------------------------------------------------------------------- 1 | # Ivan Carvalho 2 | # Solution to https://www.beecrowd.com.br/judge/problems/view/1198 3 | #!/usr/bin/env python 4 | # encoding : utf-8 5 | while True: 6 | try: 7 | a, b = [int(i) for i in input().split(" ")] 8 | print(abs(a - b)) 9 | except EOFError: 10 | break 11 | -------------------------------------------------------------------------------- /beecrowd/1199.py: -------------------------------------------------------------------------------- 1 | # Ivan Carvalho 2 | # Solution to https://www.beecrowd.com.br/judge/problems/view/1199 3 | #!/usr/bin/env python 4 | # encoding : utf-8 5 | while True: 6 | entrada = input() 7 | if "-" in entrada: 8 | break 9 | elif "x" in entrada: 10 | print(int(entrada, 16)) 11 | else: 12 | print("0x" + hex(int(entrada))[2:].upper()) 13 | -------------------------------------------------------------------------------- /beecrowd/1214.py: -------------------------------------------------------------------------------- 1 | # Ivan Carvalho 2 | # Solution to https://www.beecrowd.com.br/judge/problems/view/1214 3 | #!/usr/bin/env python 4 | # encoding : utf-8 5 | ordem = int(input()) 6 | for i in range(ordem): 7 | array = [int(i) for i in input().split(" ")] 8 | media = sum(array[1:]) / float(array[0]) 9 | print( 10 | "%.3f%%" % (100.0 * len([k for k in array[1:] if k > media]) / float(array[0])) 11 | ) 12 | -------------------------------------------------------------------------------- /beecrowd/1215.py: -------------------------------------------------------------------------------- 1 | # Ivan Carvalho 2 | # Solution to https://www.beecrowd.com.br/judge/problems/view/1215 3 | #!/usr/bin/env python 4 | # -*- coding : utf-8 -*- 5 | array = [] 6 | 7 | 8 | def funcao(x): 9 | if x.isalpha(): 10 | return x 11 | else: 12 | return " " 13 | 14 | 15 | while True: 16 | try: 17 | entrada = input().lower() 18 | array.append("".join([funcao(k) for k in entrada])) 19 | except EOFError: 20 | break 21 | aquilo = set(" ".join(array).split(" ")) 22 | aquilo.remove("") 23 | for i in sorted(aquilo, key=lambda x: (ord(x[0]), x)): 24 | print(i) 25 | -------------------------------------------------------------------------------- /beecrowd/1216.py: -------------------------------------------------------------------------------- 1 | # Ivan Carvalho 2 | # Solution to https://www.beecrowd.com.br/judge/problems/view/1216 3 | #!/usr/bin/env python 4 | # encoding : utf-8 5 | array = [] 6 | while True: 7 | try: 8 | nome = input() 9 | array.append(float(input())) 10 | except EOFError: 11 | break 12 | print("%.1f" % (sum(array) / float(len(array)))) 13 | -------------------------------------------------------------------------------- /beecrowd/1221.py: -------------------------------------------------------------------------------- 1 | # Ivan Carvalho 2 | # Solution to https://www.beecrowd.com.br/judge/problems/view/1221 3 | #!/usr/bin/env python 4 | # encoding : utf-8 5 | def primo(x): 6 | return x == 2 or x % 2 != 0 and all([x % i for i in range(3, int(x**0.5) + 1, 2)]) 7 | 8 | 9 | ordem = int(input()) 10 | for j in range(ordem): 11 | i = int(input()) 12 | if primo(i): 13 | print("Prime") 14 | else: 15 | print("Not Prime") 16 | -------------------------------------------------------------------------------- /beecrowd/1233.cpp: -------------------------------------------------------------------------------- 1 | // Ivan Carvalho 2 | // Solution to https://www.beecrowd.com.br/judge/problems/view/1233 3 | #include 4 | typedef long long ll; 5 | ll phi(ll n) { 6 | double result = n; 7 | for (ll i = 2; i * i <= n; i++) { 8 | if (n % i == 0) { 9 | while (n % i == 0) n /= i; 10 | result *= (1.0 - (1.0 / (double)i)); 11 | } 12 | } 13 | if (n != 1) result *= (1.0 - (1.0 / (double)n)); 14 | return (ll)result; 15 | } 16 | int main() { 17 | ll n; 18 | while (scanf("%lld", &n) != EOF) { 19 | printf("%lld\n", phi(n) / 2); 20 | } 21 | return 0; 22 | } 23 | -------------------------------------------------------------------------------- /beecrowd/1237.py: -------------------------------------------------------------------------------- 1 | # Ivan Carvalho 2 | # Solution to https://www.beecrowd.com.br/judge/problems/view/1237 3 | #!/usr/bin/env python 4 | # -*- coding : utf-8 5 | while True: 6 | try: 7 | a = input() 8 | except EOFError: 9 | break 10 | b = input() 11 | minor, bigger = sorted([a, b], key=lambda x: len(x)) 12 | index = 1 13 | answer = 0 14 | for i in range(len(a)): 15 | while index <= len(a) and a[i:index] in b: 16 | if index - i > answer: 17 | answer = index - i 18 | index += 1 19 | index = i + 1 20 | print(answer) 21 | -------------------------------------------------------------------------------- /beecrowd/1240.py: -------------------------------------------------------------------------------- 1 | # Ivan Carvalho 2 | # Solution to https://www.beecrowd.com.br/judge/problems/view/1240 3 | #!/usr/bin/env python 4 | # encoding : utf-8 5 | ordem = int(input()) 6 | for i in range(ordem): 7 | a, b = input().split(" ") 8 | ta, tb = [len(a), len(b)] 9 | if tb > ta: 10 | print("nao encaixa") 11 | else: 12 | if b in a[::-1][:tb][::-1]: 13 | print("encaixa") 14 | else: 15 | print("nao encaixa") 16 | -------------------------------------------------------------------------------- /beecrowd/1241.py: -------------------------------------------------------------------------------- 1 | # Ivan Carvalho 2 | # Solution to https://www.beecrowd.com.br/judge/problems/view/1241 3 | #!/usr/bin/env python 4 | # encoding : utf-8 5 | ordem = int(input()) 6 | for i in range(ordem): 7 | a, b = input().split(" ") 8 | a, b = a[::-1], b[::-1] 9 | if len(a) >= len(b): 10 | if all([a[j] == b[j] for j in range(len(b))]): 11 | print("encaixa") 12 | else: 13 | print("nao encaixa") 14 | else: 15 | print("nao encaixa") 16 | -------------------------------------------------------------------------------- /beecrowd/1247.py: -------------------------------------------------------------------------------- 1 | # Ivan Carvalho 2 | # Solution to https://www.beecrowd.com.br/judge/problems/view/1247 3 | #!/usr/bin/env python 4 | # encoding : utf-8 5 | while True: 6 | try: 7 | a, b, c = [int(i) for i in input().split(" ")] 8 | tempo1 = 12.0 / float(b) 9 | tempo2 = (((144) + (a**2)) ** 0.5) / float(c) 10 | if tempo1 >= tempo2: 11 | print("S") 12 | else: 13 | print("N") 14 | except EOFError: 15 | break 16 | -------------------------------------------------------------------------------- /beecrowd/1249.py: -------------------------------------------------------------------------------- 1 | # Ivan Carvalho 2 | # Solution to https://www.beecrowd.com.br/judge/problems/view/1249 3 | #!/usr/bin/env python 4 | # encoding : utf-8 5 | dicio = {} 6 | alfabeto = "abcdefghijklmnopqrstuvwxyz" 7 | for a, b in enumerate([k for k in alfabeto]): 8 | dicio[b] = alfabeto[(a + 13) % 26] 9 | dicio[b.upper()] = dicio[b].upper() 10 | while True: 11 | try: 12 | entrada = input() 13 | print("".join([dicio.get(j, j) for j in entrada])) 14 | except EOFError: 15 | break 16 | -------------------------------------------------------------------------------- /beecrowd/1253.cpp: -------------------------------------------------------------------------------- 1 | // Ivan Carvalho 2 | // Solution to https://www.beecrowd.com.br/judge/problems/view/1253 3 | #include 4 | #include 5 | char entrada[100010]; 6 | int TC, muda; 7 | int main() { 8 | scanf("%d", &TC); 9 | while (TC--) { 10 | scanf("%s", entrada); 11 | scanf("%d", &muda); 12 | for (int i = 0; i < strlen(entrada); i++) { 13 | char novo = ((((entrada[i] - 'A') - muda) % 26) + 26) % 26; 14 | printf("%c", novo + 'A'); 15 | } 16 | printf("\n"); 17 | } 18 | return 0; 19 | } 20 | -------------------------------------------------------------------------------- /beecrowd/1259.py: -------------------------------------------------------------------------------- 1 | # Ivan Carvalho 2 | # Solution to https://www.beecrowd.com.br/judge/problems/view/1259 3 | #!/usr/bin/env python 4 | # encoding : utf-8 5 | ordem = int(input()) 6 | pares = [] 7 | impares = [] 8 | for i in range(ordem): 9 | j = int(input()) 10 | if j % 2 == 0: 11 | pares.append(j) 12 | else: 13 | impares.append(j) 14 | for i in sorted(pares): 15 | print(i) 16 | for i in sorted(impares)[::-1]: 17 | print(i) 18 | -------------------------------------------------------------------------------- /beecrowd/1261.py: -------------------------------------------------------------------------------- 1 | # Ivan Carvalho 2 | # Solution to https://www.beecrowd.com.br/judge/problems/view/1261 3 | #!/usr/bin/env python 4 | # -*- coding : utf-8 -*- 5 | a, b = [int(i) for i in input().split()] 6 | dicio = {} 7 | for caso_da_vez in range(a): 8 | c, d = input().split() 9 | dicio[c] = int(d) 10 | for caso_da_vez in range(b): 11 | resposta = 0 12 | vetor = [] 13 | while True: 14 | texto = input() 15 | if texto == ".": 16 | break 17 | else: 18 | for palavra in texto.split(): 19 | resposta += dicio.get(palavra, 0) 20 | print(resposta) 21 | -------------------------------------------------------------------------------- /beecrowd/1273.py: -------------------------------------------------------------------------------- 1 | # Ivan Carvalho 2 | # Solution to https://www.beecrowd.com.br/judge/problems/view/1273 3 | #!/usr/bin/env python 4 | # -*- coding : utf-8 -*- 5 | verdade = False 6 | while True: 7 | ordem = int(input()) 8 | if ordem == 0: 9 | break 10 | if verdade: 11 | print("") 12 | else: 13 | verdade = True 14 | array = [] 15 | for i in range(ordem): 16 | array.append(input()) 17 | maximo = max([len(k) for k in array]) 18 | for i in array: 19 | print("%s%s" % (" " * (maximo - len(i)), i)) 20 | -------------------------------------------------------------------------------- /beecrowd/1277.py: -------------------------------------------------------------------------------- 1 | # Ivan Carvalho 2 | # Solution to https://www.beecrowd.com.br/judge/problems/view/1277 3 | #!/usr/bin/env python 4 | # -*- coding : utf-8 -*- 5 | casos = int(input()) 6 | for caso_da_vez in range(casos): 7 | numero = int(input()) 8 | alunos = input().split() 9 | presenca = [k.replace("M", "") for k in input().split()] 10 | faltas = [] 11 | for aluno, falta in zip(alunos, presenca): 12 | if falta.count("P") / float(len(falta)) < 0.75: 13 | faltas.append(aluno) 14 | print(" ".join(faltas)) 15 | -------------------------------------------------------------------------------- /beecrowd/1278.py: -------------------------------------------------------------------------------- 1 | # Ivan Carvalho 2 | # Solution to https://www.beecrowd.com.br/judge/problems/view/1278 3 | #!/usr/bin/env python 4 | # -*- coding : utf-8 -*- 5 | exibir = False 6 | while True: 7 | lines = int(input()) 8 | if lines == 0: 9 | break 10 | if exibir: 11 | print("") 12 | else: 13 | exibir = True 14 | array = [] 15 | for i in range(lines): 16 | entrada = input().split() 17 | array.append(" ".join(entrada)) 18 | tamanho = max([len(i) for i in array]) 19 | for i in array: 20 | print("%s%s" % (" " * (tamanho - len(i)), i)) 21 | -------------------------------------------------------------------------------- /beecrowd/1300.cpp: -------------------------------------------------------------------------------- 1 | // Ivan Carvalho 2 | // Solution to https://www.beecrowd.com.br/judge/problems/view/1300 3 | #include 4 | int main() { 5 | int n; 6 | while (scanf("%d", &n) != EOF) { 7 | printf("%c\n", (n % 6) == 0 ? 'Y' : 'N'); 8 | } 9 | return 0; 10 | } 11 | -------------------------------------------------------------------------------- /beecrowd/1307.py: -------------------------------------------------------------------------------- 1 | # Ivan Carvalho 2 | # Solution to https://www.beecrowd.com.br/judge/problems/view/1307 3 | #!/usr/bin/env python 4 | # encoding : utf-8 5 | def gcd(a, b): 6 | x, y = sorted([a, b]) 7 | if y % x == 0: 8 | return x 9 | else: 10 | return gcd(x, y % x) 11 | 12 | 13 | ordem = int(input()) 14 | for i in range(1, ordem + 1): 15 | e1 = int(input(), 2) 16 | e2 = int(input(), 2) 17 | if gcd(e1, e2) == 1: 18 | print("Pair #%d: Love is not all you need!" % (i)) 19 | else: 20 | print("Pair #%d: All you need is love!" % (i)) 21 | -------------------------------------------------------------------------------- /beecrowd/1308.py: -------------------------------------------------------------------------------- 1 | # Ivan Carvalho 2 | # Solution to https://www.beecrowd.com.br/judge/problems/view/1308 3 | #!/usr/bin/env python 4 | # -*- coding : utf-8 -*- 5 | tc = int(input()) 6 | for tcdavez in range(tc): 7 | n = int(input()) 8 | if n == 0: 9 | print(0) 10 | continue 11 | ini = 1 12 | fim = n 13 | resp = -1 14 | while ini <= fim: 15 | meio = (ini + fim) / 2 16 | if ((meio) * (meio + 1)) / 2 <= n: 17 | resp = meio 18 | ini = meio + 1 19 | else: 20 | fim = meio - 1 21 | print(resp) 22 | -------------------------------------------------------------------------------- /beecrowd/1323.cpp: -------------------------------------------------------------------------------- 1 | // Ivan Carvalho 2 | // Solution to https://www.beecrowd.com.br/judge/problems/view/1323 3 | #include 4 | int dp[110]; 5 | int main() { 6 | int n; 7 | for (int i = 1; i <= 100; i++) { 8 | dp[i] = dp[i - 1] + i * i; 9 | } 10 | while (scanf("%d", &n) && n) { 11 | printf("%d\n", dp[n]); 12 | } 13 | return 0; 14 | } 15 | -------------------------------------------------------------------------------- /beecrowd/1329.py: -------------------------------------------------------------------------------- 1 | # Ivan Carvalho 2 | # Solution to https://www.beecrowd.com.br/judge/problems/view/1329 3 | #!/usr/bin/env python 4 | # encoding : utf-8 5 | while True: 6 | ordem = int(input()) 7 | if ordem == 0: 8 | break 9 | else: 10 | array = [int(i) for i in input().split(" ")] 11 | print( 12 | "Mary won %d times and John won %d times" % (array.count(0), array.count(1)) 13 | ) 14 | -------------------------------------------------------------------------------- /beecrowd/1332.py: -------------------------------------------------------------------------------- 1 | # Ivan Carvalho 2 | # Solution to https://www.beecrowd.com.br/judge/problems/view/1332 3 | #!/usr/bin/env python 4 | # encoding : utf-8 5 | ordem = int(input()) 6 | for i in range(ordem): 7 | entrada = input() 8 | if len(entrada) == 3: 9 | if len([l for k, l in enumerate([j for j in entrada]) if "one"[k] == l]) >= 2: 10 | print(1) 11 | elif len([l for k, l in enumerate([j for j in entrada]) if "two"[k] == l]) >= 2: 12 | print(2) 13 | else: 14 | print(3) 15 | -------------------------------------------------------------------------------- /beecrowd/1366.cpp: -------------------------------------------------------------------------------- 1 | // Ivan Carvalho 2 | // Solution to https://www.beecrowd.com.br/judge/problems/view/1366 3 | #include 4 | int main() { 5 | int n; 6 | while (scanf("%d", &n) && n) { 7 | int resposta = 0; 8 | while (n--) { 9 | int x, y; 10 | scanf("%d %d", &y, &x); 11 | resposta += x / 2; 12 | } 13 | printf("%d\n", resposta / 2); 14 | } 15 | return 0; 16 | } 17 | -------------------------------------------------------------------------------- /beecrowd/1371.cpp: -------------------------------------------------------------------------------- 1 | // Ivan Carvalho 2 | // Solution to https://www.beecrowd.com.br/judge/problems/view/1371 3 | #include 4 | typedef long long ll; 5 | int main() { 6 | ll n; 7 | while (scanf("%lld", &n) && n) { 8 | printf("1"); 9 | for (ll i = 2; i * i <= n; i++) { 10 | printf(" %lld", i * i); 11 | } 12 | printf("\n"); 13 | } 14 | return 0; 15 | } 16 | -------------------------------------------------------------------------------- /beecrowd/1387.py: -------------------------------------------------------------------------------- 1 | # Ivan Carvalho 2 | # Solution to https://www.beecrowd.com.br/judge/problems/view/1387 3 | #!/usr/bin/env python 4 | # encoding : utf-8 5 | while True: 6 | a, b = [int(i) for i in input().split(" ")] 7 | if a == 0 and b == 0: 8 | break 9 | else: 10 | print(a + b) 11 | -------------------------------------------------------------------------------- /beecrowd/1393.cpp: -------------------------------------------------------------------------------- 1 | // Ivan Carvalho 2 | // Solution to https://www.beecrowd.com.br/judge/problems/view/1393 3 | #include 4 | #include 5 | int dp[50], vis[50], n; 6 | int solve(int k) { 7 | if (k == n) return 1; 8 | if (k > n) return 0; 9 | if (vis[k]) return dp[k]; 10 | vis[k] = 1; 11 | return dp[k] = solve(k + 1) + solve(k + 2); 12 | } 13 | int main() { 14 | while (scanf("%d", &n) && n) { 15 | memset(dp, 0, sizeof(dp)); 16 | memset(vis, 0, sizeof(vis)); 17 | printf("%d\n", solve(0)); 18 | } 19 | return 0; 20 | } 21 | -------------------------------------------------------------------------------- /beecrowd/1397.cpp: -------------------------------------------------------------------------------- 1 | // Ivan Carvalho 2 | // Solution to https://www.beecrowd.com.br/judge/problems/view/1397 3 | #include 4 | int main() { 5 | int n; 6 | while (scanf("%d", &n) && n) { 7 | int a = 0, b = 0; 8 | while (n--) { 9 | int x, y; 10 | scanf("%d %d", &x, &y); 11 | a += int(x > y); 12 | b += int(x < y); 13 | } 14 | printf("%d %d\n", a, b); 15 | } 16 | return 0; 17 | } 18 | -------------------------------------------------------------------------------- /beecrowd/1398.py: -------------------------------------------------------------------------------- 1 | # Ivan Carvalho 2 | # Solution to https://www.beecrowd.com.br/judge/problems/view/1398 3 | #!/usr/bin/env python 4 | # -*- coding : utf-8 -*- 5 | primo = 131071 6 | entrada = [] 7 | while True: 8 | try: 9 | davez = input() 10 | except EOFError: 11 | break 12 | entrada.append(davez) 13 | numeros = [i for i in "".join(entrada).split("#") if i != ""] 14 | for i in numeros: 15 | if int(i, 2) % primo == 0: 16 | print("YES") 17 | else: 18 | print("NO") 19 | -------------------------------------------------------------------------------- /beecrowd/1429.cpp: -------------------------------------------------------------------------------- 1 | // Ivan Carvalho 2 | // Solution to https://www.beecrowd.com.br/judge/problems/view/1429 3 | #include 4 | int main() { 5 | int n; 6 | while (scanf("%d", &n) && n) { 7 | int resp = 0; 8 | for (int i = 1; i <= 5; i++) { 9 | int temp = 1; 10 | for (int j = 1; j <= i; j++) temp *= j; 11 | resp += (n % 10) * temp; 12 | n /= 10; 13 | } 14 | printf("%d\n", resp); 15 | } 16 | return 0; 17 | } 18 | -------------------------------------------------------------------------------- /beecrowd/1436.py: -------------------------------------------------------------------------------- 1 | # Ivan Carvalho 2 | # Solution to https://www.beecrowd.com.br/judge/problems/view/1436 3 | #!/usr/bin/env python 4 | # encoding : utf-8 5 | ordem = int(input()) 6 | 7 | 8 | def mediana(matriz): 9 | array = sorted(matriz) 10 | tamanho = len(array) 11 | if tamanho % 2 == 0: 12 | return int(array[tamanho / 2] + array[1 + tamanho / 2]) 13 | else: 14 | return int(array[tamanho / 2]) 15 | 16 | 17 | for i in range(ordem): 18 | entrada = [int(k) for k in input().split(" ") if k != ""] 19 | print("Case %d: %d" % (i + 1, mediana(entrada[1:]))) 20 | -------------------------------------------------------------------------------- /beecrowd/1449.py: -------------------------------------------------------------------------------- 1 | # Ivan Carvalho 2 | # Solution to https://www.beecrowd.com.br/judge/problems/view/1449 3 | #!/usr/bin/env python 4 | # -*- coding : utf-8 -*- 5 | ordem = int(input()) 6 | exibir = False 7 | for caso_da_vez in range(ordem): 8 | dicio = {} 9 | a, b = [int(i) for i in input().split()] 10 | for i in range(a): 11 | entrada1 = input() 12 | entrada2 = input() 13 | dicio[entrada1] = entrada2 14 | for i in range(b): 15 | print(" ".join([dicio.get(j, j) for j in input().split()])) 16 | print("") 17 | -------------------------------------------------------------------------------- /beecrowd/1457.py: -------------------------------------------------------------------------------- 1 | # Ivan Carvalho 2 | # Solution to https://www.beecrowd.com.br/judge/problems/view/1457 3 | #!/usr/bin/env python 4 | # -*- coding : utf-8 -*- 5 | tc = int(input()) 6 | for teste in range(tc): 7 | entrada = input() 8 | k = entrada.count("!") 9 | n = int(entrada.replace("!", "")) 10 | resposta = 1 11 | while n > 0: 12 | resposta *= n 13 | n -= k 14 | print(resposta) 15 | -------------------------------------------------------------------------------- /beecrowd/1467.py: -------------------------------------------------------------------------------- 1 | # Ivan Carvalho 2 | # Solution to https://www.beecrowd.com.br/judge/problems/view/1467 3 | #!/usr/bin/env python 4 | # encoding : utf-8 5 | while True: 6 | try: 7 | e = input() 8 | if e in ["0 0 0", "1 1 1"]: 9 | print("*") 10 | elif e in ["1 0 0", "0 1 1"]: 11 | print("A") 12 | elif e in ["1 0 1", "0 1 0"]: 13 | print("B") 14 | else: 15 | print("C") 16 | except EOFError: 17 | break 18 | -------------------------------------------------------------------------------- /beecrowd/1540.py: -------------------------------------------------------------------------------- 1 | # Ivan Carvalho 2 | # Solution to https://www.beecrowd.com.br/judge/problems/view/1540 3 | #!/usr/bin/env python 4 | # -*- coding : utf-8 -*- 5 | casos = int(input()) 6 | for caso in range(casos): 7 | a, b, c, d = [int(i) for i in input().split()] 8 | exibir = "%.3lf" % ((d - b) / float(c - a)) 9 | novoexbir = [i for i in exibir] 10 | novoexbir.pop() 11 | print("".join(novoexbir).replace(".", ",")) 12 | -------------------------------------------------------------------------------- /beecrowd/1544.cpp: -------------------------------------------------------------------------------- 1 | // Ivan Carvalho 2 | // Solution to https://www.beecrowd.com.br/judge/problems/view/1544 3 | #include 4 | int main() { 5 | long long a, b; 6 | while (scanf("%lld %lld", &a, &b) != EOF) { 7 | long long resp = 1; 8 | for (long long i = a - b + 1; i <= a; i++) { 9 | resp *= i; 10 | while (resp % 10LL == 0LL) resp /= 10LL; 11 | resp %= 100000000000LL; 12 | } 13 | printf("%lld\n", resp % 10); 14 | } 15 | return 0; 16 | } 17 | -------------------------------------------------------------------------------- /beecrowd/1546.py: -------------------------------------------------------------------------------- 1 | # Ivan Carvalho 2 | # Solution to https://www.beecrowd.com.br/judge/problems/view/1546 3 | # -*- coding: utf-8 -*- 4 | ordem = int(input()) 5 | casos = [] 6 | for i in range(ordem): 7 | subordem = int(input()) 8 | problemas = [] 9 | for i in range(subordem): 10 | problemas.append(int(input())) 11 | casos.append(problemas) 12 | for teste in casos: 13 | for numero in teste: 14 | print({1: "Rolien", 2: "Naej", 3: "Elehcim", 4: "Odranoel"}[numero]) 15 | -------------------------------------------------------------------------------- /beecrowd/1547.py: -------------------------------------------------------------------------------- 1 | # Ivan Carvalho 2 | # Solution to https://www.beecrowd.com.br/judge/problems/view/1547 3 | # encoding: utf-8 4 | ordem = int(input()) 5 | casos = [] 6 | alunos = [] 7 | for i in range(ordem): 8 | casos.append([int(i) for i in input().split(" ")]) 9 | alunos.append(input()) 10 | for a, b in enumerate(casos): 11 | qt, s = b 12 | array = [abs(int(k) - s) for k in alunos[a].split(" ")] 13 | print(1 + array.index(min(array))) 14 | -------------------------------------------------------------------------------- /beecrowd/1551.py: -------------------------------------------------------------------------------- 1 | # Ivan Carvalho 2 | # Solution to https://www.beecrowd.com.br/judge/problems/view/1551 3 | # -*- coding: utf-8 -*- 4 | 5 | """ 6 | Escreva a sua solução aqui 7 | Code your solution here 8 | Escriba su solución aquí 9 | """ 10 | ordem = int(input()) 11 | frases = [] 12 | for i in range(ordem): 13 | frases.append(set([j for j in input().replace(",", "").replace(" ", "")])) 14 | for frase in frases: 15 | if len(frase) < 13: 16 | print("frase mal elaborada") 17 | elif len(frase) < 26: 18 | print("frase quase completa") 19 | else: 20 | print("frase completa") 21 | -------------------------------------------------------------------------------- /beecrowd/1553.py: -------------------------------------------------------------------------------- 1 | # Ivan Carvalho 2 | # Solution to https://www.beecrowd.com.br/judge/problems/view/1553 3 | # encoding : utf-8 4 | def frequente(conjunto, numero): 5 | return len([j for j in [conjunto.count(i) for i in set(conjunto)] if j >= numero]) 6 | 7 | 8 | while True: 9 | a, b = [int(i) for i in input().split(" ")] 10 | if a != 0 and b != 0: 11 | print(frequente([int(j) for j in input().split(" ")], b)) 12 | else: 13 | break 14 | -------------------------------------------------------------------------------- /beecrowd/1558.cpp: -------------------------------------------------------------------------------- 1 | // Ivan Carvalho 2 | // Solution to https://www.beecrowd.com.br/judge/problems/view/1558 3 | #include 4 | #define MAXN 30000 5 | bool vetor[MAXN]; 6 | int main() { 7 | for (int i = 0; i <= 100; i++) 8 | for (int j = 0; j <= 100; j++) { 9 | vetor[i * i + j * j] = true; 10 | } 11 | int n; 12 | while (scanf("%d", &n) != EOF) { 13 | if (n < 0) { 14 | printf("NO\n"); 15 | continue; 16 | } 17 | if (vetor[n]) 18 | printf("YES\n"); 19 | else 20 | printf("NO\n"); 21 | } 22 | return 0; 23 | } 24 | -------------------------------------------------------------------------------- /beecrowd/1564.py: -------------------------------------------------------------------------------- 1 | # Ivan Carvalho 2 | # Solution to https://www.beecrowd.com.br/judge/problems/view/1564 3 | # -*- coding: utf-8 -*- 4 | 5 | """ 6 | Escreva a sua solução aqui 7 | Code your solution here 8 | Escriba su solución aquí 9 | """ 10 | while True: 11 | try: 12 | e = int(input()) 13 | if e == 0: 14 | print("vai ter copa!") 15 | else: 16 | print("vai ter duas!") 17 | except EOFError: 18 | break 19 | -------------------------------------------------------------------------------- /beecrowd/1581.py: -------------------------------------------------------------------------------- 1 | # Ivan Carvalho 2 | # Solution to https://www.beecrowd.com.br/judge/problems/view/1581 3 | #!/usr/bin/env python 4 | # encoding : utf-8 5 | ordem = int(input()) 6 | linguas = [] 7 | for i in range(ordem): 8 | subordem = int(input()) 9 | sublinguas = [] 10 | for j in range(subordem): 11 | sublinguas.append(input()) 12 | linguas.append(sublinguas) 13 | for array in linguas: 14 | lingua = array[0] 15 | if all([k == lingua for k in array]): 16 | print(lingua) 17 | else: 18 | print("ingles") 19 | -------------------------------------------------------------------------------- /beecrowd/1585.py: -------------------------------------------------------------------------------- 1 | # Ivan Carvalho 2 | # Solution to https://www.beecrowd.com.br/judge/problems/view/1585 3 | # -*- coding: utf-8 -*- 4 | 5 | """ 6 | Escreva a sua solução aqui 7 | Code your solution here 8 | Escriba su solución aquí 9 | """ 10 | ordem = int(input()) 11 | for i in range(ordem): 12 | a, b = [int(i) for i in input().split(" ")] 13 | print("%s cm2" % str(a * b / 2)) 14 | -------------------------------------------------------------------------------- /beecrowd/1589.py: -------------------------------------------------------------------------------- 1 | # Ivan Carvalho 2 | # Solution to https://www.beecrowd.com.br/judge/problems/view/1589 3 | #!/usr/bin/env python 4 | # encoding : utf-8 5 | ordem = int(input()) 6 | for i in range(ordem): 7 | print(sum([int(i) for i in input().split(" ")])) 8 | -------------------------------------------------------------------------------- /beecrowd/1593.py: -------------------------------------------------------------------------------- 1 | # Ivan Carvalho 2 | # Solution to https://www.beecrowd.com.br/judge/problems/view/1593 3 | #!/usr/bin/env python 4 | # -*- coding : utf-8 -*- 5 | casos = int(input()) 6 | for i in range(casos): 7 | print(str(bin(int(input()))).count("1")) 8 | -------------------------------------------------------------------------------- /beecrowd/1609.cpp: -------------------------------------------------------------------------------- 1 | // Ivan Carvalho 2 | // Solution to https://www.beecrowd.com.br/judge/problems/view/1609 3 | #include 4 | #include 5 | using namespace std; 6 | int main() { 7 | int TC; 8 | scanf("%d", &TC); 9 | while (TC--) { 10 | set carneiros; 11 | int n; 12 | scanf("%d", &n); 13 | while (n--) { 14 | int davez; 15 | scanf("%d", &davez); 16 | carneiros.insert(davez); 17 | } 18 | printf("%d\n", (int)carneiros.size()); 19 | } 20 | return 0; 21 | } 22 | -------------------------------------------------------------------------------- /beecrowd/1620.py: -------------------------------------------------------------------------------- 1 | # Ivan Carvalho 2 | # Solution to https://www.beecrowd.com.br/judge/problems/view/1620 3 | # -*- coding: utf-8 -*- 4 | 5 | """ 6 | Escreva a sua solução aqui 7 | Code your solution here 8 | Escriba su solución aquí 9 | """ 10 | while True: 11 | a = float(input()) 12 | if a == 0: 13 | break 14 | else: 15 | print("%.6f" % ((a - 3) / a)) 16 | -------------------------------------------------------------------------------- /beecrowd/1641.cpp: -------------------------------------------------------------------------------- 1 | // Ivan Carvalho 2 | // Solution to https://www.beecrowd.com.br/judge/problems/view/1641 3 | #include 4 | int pizza; 5 | int main() { 6 | int r, l, w; 7 | while (scanf("%d", &r) && r) { 8 | scanf("%d %d", &w, &l); 9 | pizza++; 10 | int delta = 4 * r * r - w * w - l * l; 11 | if (delta >= 0) 12 | printf("Pizza %d fits on the table.\n", pizza); 13 | else 14 | printf("Pizza %d does not fit on the table.\n", pizza); 15 | } 16 | return 0; 17 | } 18 | -------------------------------------------------------------------------------- /beecrowd/1663.cpp: -------------------------------------------------------------------------------- 1 | // Ivan Carvalho 2 | // Solution to https://www.beecrowd.com.br/judge/problems/view/1663 3 | #include 4 | int vetor[100010]; 5 | int main() { 6 | int n; 7 | while (scanf("%d", &n) && n) { 8 | for (int i = 1; i <= n; i++) { 9 | scanf("%d", &vetor[i]); 10 | } 11 | int ambiguo = 1; 12 | for (int i = 1; i <= n; i++) { 13 | if (vetor[vetor[i]] != i) { 14 | ambiguo = 0; 15 | break; 16 | } 17 | } 18 | printf("%s\n", ambiguo ? "ambiguous" : "not ambiguous"); 19 | } 20 | return 0; 21 | } 22 | -------------------------------------------------------------------------------- /beecrowd/1672.py: -------------------------------------------------------------------------------- 1 | # Ivan Carvalho 2 | # Solution to https://www.beecrowd.com.br/judge/problems/view/1672 3 | #!/usr/bin/env python 4 | # -*- coding : utf-8 -*- 5 | from math import log, floor 6 | 7 | while True: 8 | entrada = input() 9 | n = int(entrada[0] + entrada[1]) * 10 ** int(entrada[3]) 10 | if n == 0: 11 | break 12 | expo = floor(log(n) / log(2)) 13 | exibir = n - (2**expo) 14 | exibir *= 2 15 | exibir += 1 16 | print("%d" % (exibir)) 17 | -------------------------------------------------------------------------------- /beecrowd/1728.py: -------------------------------------------------------------------------------- 1 | # Ivan Carvalho 2 | # Solution to https://www.beecrowd.com.br/judge/problems/view/1728 3 | #!/usr/bin/env python 4 | # *- coding : utf-8 -*- 5 | while True: 6 | entrada = input() 7 | if entrada == "0+0=0": 8 | print(True) 9 | break 10 | numeros = [int(i) for i in entrada[::-1].replace("=", "+").split("+")] 11 | print(numeros[0] == numeros[2] + numeros[1]) 12 | -------------------------------------------------------------------------------- /beecrowd/1739.py: -------------------------------------------------------------------------------- 1 | # Ivan Carvalho 2 | # Solution to https://www.beecrowd.com.br/judge/problems/view/1739 3 | #!/usr/bin/env python 4 | # -*- coding : utf-8 -*- 5 | fibo = [1, 1] 6 | tamanho = 0 7 | lista = [] 8 | while tamanho < 60: 9 | proximo = fibo[-1] + fibo[-2] 10 | fibo.append(proximo) 11 | if proximo % 3 == 0 or "3" in str(proximo): 12 | tamanho += 1 13 | lista.append(proximo) 14 | while True: 15 | try: 16 | a = int(input()) 17 | except EOFError: 18 | break 19 | print(lista[a - 1]) 20 | -------------------------------------------------------------------------------- /beecrowd/1743.cpp: -------------------------------------------------------------------------------- 1 | // Ivan Carvalho 2 | // Solution to https://www.beecrowd.com.br/judge/problems/view/1743 3 | #include 4 | int vetor1[10], vetor2[10]; 5 | int main() { 6 | for (int i = 0; i < 5; i++) scanf("%d", &vetor1[i]); 7 | for (int i = 0; i < 5; i++) scanf("%d", &vetor2[i]); 8 | for (int i = 0; i < 5; i++) 9 | if (vetor1[i] == vetor2[i]) { 10 | printf("N\n"); 11 | return 0; 12 | } 13 | printf("Y\n"); 14 | return 0; 15 | } 16 | -------------------------------------------------------------------------------- /beecrowd/1759.py: -------------------------------------------------------------------------------- 1 | # Ivan Carvalho 2 | # Solution to https://www.beecrowd.com.br/judge/problems/view/1759 3 | #!/usr/bin/env python 4 | # encoding : utf-8 5 | entrada = int(input()) 6 | print(" ".join(["Ho" for i in range(entrada)]) + "!") 7 | -------------------------------------------------------------------------------- /beecrowd/1789.py: -------------------------------------------------------------------------------- 1 | # Ivan Carvalho 2 | # Solution to https://www.beecrowd.com.br/judge/problems/view/1789 3 | #!/usr/bin/env python 4 | # encoding : utf-8 5 | while True: 6 | try: 7 | ordem = int(input()) 8 | maximo = max([int(i) for i in input().split(" ")]) 9 | if maximo < 10: 10 | print(1) 11 | elif maximo < 20: 12 | print(2) 13 | else: 14 | print(3) 15 | except EOFError: 16 | break 17 | -------------------------------------------------------------------------------- /beecrowd/1794.py: -------------------------------------------------------------------------------- 1 | # Ivan Carvalho 2 | # Solution to https://www.beecrowd.com.br/judge/problems/view/1794 3 | # -*- coding: utf-8 -*- 4 | 5 | """ 6 | Escreva a sua solução aqui 7 | Code your solution here 8 | Escriba su solución aquí 9 | """ 10 | n = int(input()) 11 | min1, max1 = [int(i) for i in input().split(" ")] 12 | min2, max2 = [int(i) for i in input().split(" ")] 13 | if n >= min1 and n >= min2 and n <= max1 and n <= max2: 14 | print("possivel") 15 | else: 16 | print("impossivel") 17 | -------------------------------------------------------------------------------- /beecrowd/1795.cpp: -------------------------------------------------------------------------------- 1 | // Ivan Carvalho 2 | // Solution to https://www.beecrowd.com.br/judge/problems/view/1795 3 | #include 4 | int main() { 5 | int n; 6 | long long resposta = 1; 7 | scanf("%d", &n); 8 | while (n--) resposta *= 3; 9 | printf("%lld\n", resposta); 10 | return 0; 11 | } 12 | -------------------------------------------------------------------------------- /beecrowd/1796.py: -------------------------------------------------------------------------------- 1 | # Ivan Carvalho 2 | # Solution to https://www.beecrowd.com.br/judge/problems/view/1796 3 | # -*- coding: utf-8 -*- 4 | 5 | """ 6 | Escreva a sua solução aqui 7 | Code your solution here 8 | Escriba su solución aquí 9 | """ 10 | ordem = int(input()) 11 | opinioes = [int(i) for i in input().split(" ")] 12 | sim = opinioes.count(0) 13 | nao = opinioes.count(1) 14 | if nao >= sim: 15 | print("N") 16 | else: 17 | print("Y") 18 | -------------------------------------------------------------------------------- /beecrowd/1800.py: -------------------------------------------------------------------------------- 1 | # Ivan Carvalho 2 | # Solution to https://www.beecrowd.com.br/judge/problems/view/1800 3 | #!/usr/bin/env python 4 | # encoding : utf-8 5 | q, e = [int(i) for i in input().split(" ")] 6 | jaesteve = [int(k) for k in input().split(" ")] 7 | for l in range(q): 8 | agora = int(input()) 9 | if agora in jaesteve: 10 | print(0) 11 | else: 12 | print(1) 13 | jaesteve.append(agora) 14 | -------------------------------------------------------------------------------- /beecrowd/1802.py: -------------------------------------------------------------------------------- 1 | # Ivan Carvalho 2 | # Solution to https://www.beecrowd.com.br/judge/problems/view/1802 3 | #!/usr/bin/env python 4 | # encoding : utf-8 5 | entrada = [] 6 | for i in range(5): 7 | entrada.append(sorted([int(j) for j in input().split(" ")[1:]])) 8 | ordem = int(input()) 9 | grupos = [] 10 | for a1 in entrada[0]: 11 | for a2 in entrada[1]: 12 | for a3 in entrada[2]: 13 | for a4 in entrada[3]: 14 | for a5 in entrada[4]: 15 | grupos.append(a1 + a2 + a3 + a4 + a5) 16 | print(sum(sorted(grupos)[::-1][:ordem])) 17 | -------------------------------------------------------------------------------- /beecrowd/1803.py: -------------------------------------------------------------------------------- 1 | # Ivan Carvalho 2 | # Solution to https://www.beecrowd.com.br/judge/problems/view/1803 3 | #!/usr/bin/env python 4 | # encoding : utf-8 5 | entrada = [] 6 | while True: 7 | try: 8 | entrada.append([i for i in input()]) 9 | except EOFError: 10 | break 11 | matring = [int("".join(k)) for k in zip(*entrada)] 12 | f = matring[0] 13 | l = matring[-1] 14 | matring.pop(0) 15 | matring.pop(-1) 16 | caracteres = [] 17 | for i in matring: 18 | caracteres.append(chr((f * i + l) % 257)) 19 | print("".join(caracteres)) 20 | -------------------------------------------------------------------------------- /beecrowd/1805.py: -------------------------------------------------------------------------------- 1 | # Ivan Carvalho 2 | # Solution to https://www.beecrowd.com.br/judge/problems/view/1805 3 | #!/usr/bin/env python 4 | # encoding : utf-8 5 | a, b = [int(i) for i in input().split(" ")] 6 | soma = lambda x: ((x) * (x + 1)) / 2 7 | print(soma(b) - soma(a - 1)) 8 | -------------------------------------------------------------------------------- /beecrowd/1807.cpp: -------------------------------------------------------------------------------- 1 | // Ivan Carvalho 2 | // Solution to https://www.beecrowd.com.br/judge/problems/view/1807 3 | #include 4 | typedef long long ll; 5 | ll exp(ll n) { 6 | if (n == 0) return 1; 7 | if (n % 2 == 1) return (3 * exp(n - 1)) % 2147483647; 8 | ll valor = (exp(n / 2)) % 2147483647; 9 | valor *= valor; 10 | valor %= 2147483647; 11 | return valor; 12 | } 13 | int main() { 14 | ll entrada; 15 | scanf("%lld", &entrada); 16 | printf("%lld\n", exp(entrada)); 17 | return 0; 18 | } 19 | -------------------------------------------------------------------------------- /beecrowd/1816.py: -------------------------------------------------------------------------------- 1 | # Ivan Carvalho 2 | # Solution to https://www.beecrowd.com.br/judge/problems/view/1816 3 | #!/usr/bin/env/python 4 | # -*- coding : utf -*- 5 | instancia = 1 6 | while True: 7 | ordem = int(input()) 8 | if ordem == 0: 9 | break 10 | print("Instancia %d" % instancia) 11 | instancia += 1 12 | resposta = [] 13 | array = [i for i in "ABCDEFGHIJKLMNOPQRSTUVWXYZ"] 14 | entrada = [int(i) for i in input().split()] 15 | for i in entrada: 16 | resposta.append(array[i - 1]) 17 | antigo = array.pop(i - 1) 18 | array.insert(0, antigo) 19 | print("".join(resposta)) 20 | print("") 21 | -------------------------------------------------------------------------------- /beecrowd/1837.cpp: -------------------------------------------------------------------------------- 1 | // Ivan Carvalho 2 | // Solution to https://www.beecrowd.com.br/judge/problems/view/1837 3 | #include 4 | #include 5 | int main() { 6 | int a, b, q, r; 7 | scanf("%d %d", &a, &b); 8 | q = a / b; 9 | r = a % b; 10 | if (r < 0) { 11 | for (r = 0; r <= abs(b); r++) { 12 | q = (a - r) / b; 13 | if (a == b * q + r) break; 14 | } 15 | } 16 | printf("%d %d\n", q, r); 17 | return 0; 18 | } 19 | -------------------------------------------------------------------------------- /beecrowd/1865.py: -------------------------------------------------------------------------------- 1 | # Ivan Carvalho 2 | # Solution to https://www.beecrowd.com.br/judge/problems/view/1865 3 | #!/usr/bin/env python 4 | # encoding : utf-8 5 | ordem = int(input()) 6 | for i in range(ordem): 7 | a, b = input().split(" ") 8 | if a == "Thor": 9 | print("Y") 10 | else: 11 | print("N") 12 | -------------------------------------------------------------------------------- /beecrowd/1866.py: -------------------------------------------------------------------------------- 1 | # Ivan Carvalho 2 | # Solution to https://www.beecrowd.com.br/judge/problems/view/1866 3 | # -*- coding: utf-8 -*- 4 | ordem = int(input()) 5 | for i in range(ordem): 6 | print(int(input()) % 2) 7 | -------------------------------------------------------------------------------- /beecrowd/1869.py: -------------------------------------------------------------------------------- 1 | # Ivan Carvalho 2 | # Solution to https://www.beecrowd.com.br/judge/problems/view/1869 3 | #!/usr/bin/env python 4 | # -*- coding : utf -8 -*- 5 | alfabeto = "0123456789ABCDEFGHIJKLMNOPQRSTUV" 6 | dicio = {} 7 | for i in range(len(alfabeto)): 8 | dicio[i] = alfabeto[i] 9 | while True: 10 | n = int(input()) 11 | if n == 0: 12 | print("0") 13 | break 14 | invertido = [] 15 | while n > 0: 16 | invertido.append(dicio[n % 32]) 17 | n /= 32 18 | print("".join(invertido)[::-1]) 19 | -------------------------------------------------------------------------------- /beecrowd/1871.py: -------------------------------------------------------------------------------- 1 | # Ivan Carvalho 2 | # Solution to https://www.beecrowd.com.br/judge/problems/view/1871 3 | #!/usr/bin/env python 4 | # encoding : utf-8 5 | while True: 6 | a, b = [int(i) for i in input().split(" ")] 7 | if a == 0 and b == 0: 8 | break 9 | else: 10 | print(str(a + b).replace("0", "")) 11 | -------------------------------------------------------------------------------- /beecrowd/1890.cpp: -------------------------------------------------------------------------------- 1 | // Ivan Carvalho 2 | // Solution to https://www.beecrowd.com.br/judge/problems/view/1890 3 | #include 4 | int main() { 5 | int casos; 6 | scanf("%d", &casos); 7 | while (casos--) { 8 | int x, y, resposta = 1; 9 | scanf("%d %d", &x, &y); 10 | if (x == 0 && y == 0) { 11 | printf("0\n"); 12 | continue; 13 | } 14 | while (x--) resposta *= 26; 15 | while (y--) resposta *= 10; 16 | printf("%d\n", resposta); 17 | } 18 | return 0; 19 | } 20 | -------------------------------------------------------------------------------- /beecrowd/1893.cpp: -------------------------------------------------------------------------------- 1 | // Ivan Carvalho 2 | // Solution to https://www.beecrowd.com.br/judge/problems/view/1893 3 | #include 4 | int main() { 5 | int a, b; 6 | scanf("%d%d", &a, &b); 7 | if (3 <= b && b <= 96 && b > a) 8 | printf("crescente\n"); 9 | else if (3 <= b && b <= 96 && b < a) 10 | printf("minguante\n"); 11 | else if (0 <= b && b <= 2) 12 | printf("nova\n"); 13 | else if (97 <= b && b <= 100) 14 | printf("cheia\n"); 15 | return 0; 16 | } 17 | -------------------------------------------------------------------------------- /beecrowd/1895.py: -------------------------------------------------------------------------------- 1 | # Ivan Carvalho 2 | # Solution to https://www.beecrowd.com.br/judge/problems/view/1895 3 | #!/usr/bin/env python 4 | # encoding : utf-8 5 | n, to, l = [int(i) for i in input().split(" ")] 6 | counta = 0 7 | countb = 0 8 | for i in range(n - 1): 9 | e = int(input()) 10 | if abs(e - to) <= l: 11 | if i % 2 == 0: 12 | counta += abs(e - to) 13 | else: 14 | countb += abs(e - to) 15 | to = e 16 | print("%d %d" % (counta, countb)) 17 | -------------------------------------------------------------------------------- /beecrowd/1901.py: -------------------------------------------------------------------------------- 1 | # Ivan Carvalho 2 | # Solution to https://www.beecrowd.com.br/judge/problems/view/1901 3 | # -*- coding: utf-8 -*- 4 | 5 | """ 6 | Escreva a sua solução aqui 7 | Code your solution here 8 | Escriba su solución aquí 9 | """ 10 | ordem = int(input()) 11 | array = [] 12 | for i in range(ordem): 13 | array.append([int(k) for k in input().split(" ")]) 14 | pares = [] 15 | for j in range(ordem * 2): 16 | pares.append([int(l) - 1 for l in input().split(" ")]) 17 | encontrados = [] 18 | for c, d in pares: 19 | encontrados.append(array[c][d]) 20 | print(len(set(encontrados))) 21 | -------------------------------------------------------------------------------- /beecrowd/1914.py: -------------------------------------------------------------------------------- 1 | # Ivan Carvalho 2 | # Solution to https://www.beecrowd.com.br/judge/problems/view/1914 3 | #!/usr/bin/env python 4 | # encoding : utf-8 5 | ordem = int(input()) 6 | for i in range(ordem): 7 | a, b, c, d = input().split(" ") 8 | e, f = [int(k) for k in input().split(" ")] 9 | if b == "PAR": 10 | if (e + f) % 2 == 0: 11 | print(a) 12 | else: 13 | print(c) 14 | else: 15 | if (e + f) % 2 == 0: 16 | print(c) 17 | else: 18 | print(a) 19 | -------------------------------------------------------------------------------- /beecrowd/1921.py: -------------------------------------------------------------------------------- 1 | # Ivan Carvalho 2 | # Solution to https://www.beecrowd.com.br/judge/problems/view/1921 3 | # -*- coding: utf-8 -*- 4 | 5 | """ 6 | Escreva a sua solução aqui 7 | Code your solution here 8 | Escriba su solución aquí 9 | """ 10 | entrada = int(input()) 11 | print((entrada * (entrada - 3)) / 2) 12 | -------------------------------------------------------------------------------- /beecrowd/1924.py: -------------------------------------------------------------------------------- 1 | # Ivan Carvalho 2 | # Solution to https://www.beecrowd.com.br/judge/problems/view/1924 3 | #!/usr/bin/env python 4 | # encoding : utf-8 5 | ordem = int(input()) 6 | for i in range(ordem): 7 | nome = input() 8 | print("Ciencia da Computacao") 9 | -------------------------------------------------------------------------------- /beecrowd/1929.py: -------------------------------------------------------------------------------- 1 | # Ivan Carvalho 2 | # Solution to https://www.beecrowd.com.br/judge/problems/view/1929 3 | # -*- coding: utf-8 -*- 4 | 5 | """ 6 | Escreva a sua solução aqui 7 | Code your solution here 8 | Escriba su solución aquí 9 | """ 10 | 11 | 12 | def istriangle(x, y, z): 13 | return x + y > z and x + z > y and z + y > x 14 | 15 | 16 | a, b, c, d = sorted([int(i) for i in input().split(" ")]) 17 | if ( 18 | istriangle(a, b, c) 19 | or istriangle(a, b, d) 20 | or istriangle(a, c, d) 21 | or istriangle(b, c, d) 22 | ): 23 | print("S") 24 | else: 25 | print("N") 26 | -------------------------------------------------------------------------------- /beecrowd/1930.py: -------------------------------------------------------------------------------- 1 | # Ivan Carvalho 2 | # Solution to https://www.beecrowd.com.br/judge/problems/view/1930 3 | #!/usr/bin/env python 4 | # encoding : utf-8 5 | entrada = [int(i) for i in input().split()] 6 | print(1 + sum(entrada) - len(entrada)) 7 | -------------------------------------------------------------------------------- /beecrowd/1933.py: -------------------------------------------------------------------------------- 1 | # Ivan Carvalho 2 | # Solution to https://www.beecrowd.com.br/judge/problems/view/1933 3 | # -*- coding: utf-8 -*- 4 | 5 | """ 6 | Escreva a sua solução aqui 7 | Code your solution here 8 | Escriba su solución aquí 9 | """ 10 | print(max([int(i) for i in input().split(" ") if i != ""])) 11 | -------------------------------------------------------------------------------- /beecrowd/1936.cpp: -------------------------------------------------------------------------------- 1 | // Ivan Carvalho 2 | // Solution to https://www.beecrowd.com.br/judge/problems/view/1936 3 | #include 4 | int fatorial(int x) { 5 | if (x == 0 || x == 1) return 1; 6 | return x * fatorial(x - 1); 7 | } 8 | int main() { 9 | int n, resposta = 0; 10 | scanf("%d", &n); 11 | for (int fat = 9; fat > 0; fat--) { 12 | int davez = fatorial(fat); 13 | resposta += n / davez; 14 | n %= davez; 15 | } 16 | printf("%d\n", resposta); 17 | return 0; 18 | } 19 | -------------------------------------------------------------------------------- /beecrowd/1943.py: -------------------------------------------------------------------------------- 1 | # Ivan Carvalho 2 | # Solution to https://www.beecrowd.com.br/judge/problems/view/1943 3 | #!/usr/bin/env python 4 | # encoding : utf-8 5 | e = int(input()) 6 | if e == 1: 7 | print("Top 1") 8 | elif e <= 3: 9 | print("Top 3") 10 | elif e <= 5: 11 | print("Top 5") 12 | elif e <= 10: 13 | print("Top 10") 14 | elif e <= 25: 15 | print("Top 25") 16 | elif e <= 50: 17 | print("Top 50") 18 | else: 19 | print("Top 100") 20 | -------------------------------------------------------------------------------- /beecrowd/1957.py: -------------------------------------------------------------------------------- 1 | # Ivan Carvalho 2 | # Solution to https://www.beecrowd.com.br/judge/problems/view/1957 3 | # -*- coding: utf-8 -*- 4 | entrada = int(input()) 5 | print(hex(entrada).upper()[2:]) 6 | -------------------------------------------------------------------------------- /beecrowd/1958.py: -------------------------------------------------------------------------------- 1 | # Ivan Carvalho 2 | # Solution to https://www.beecrowd.com.br/judge/problems/view/1958 3 | #!/usr/bin/env python 4 | # encoding : utf-8 5 | entrada = input() 6 | numero = float(entrada) 7 | if entrada in ["0", "+0", "-0"]: 8 | print({"-0": "-0.0000E+00", "0": "+0.0000E+00", "+0": "+0.0000E+00"}[entrada]) 9 | else: 10 | texto = "%.4e" % (abs(numero)) 11 | print("%s%s" % (["-", "+"][numero > 0], texto.upper())) 12 | -------------------------------------------------------------------------------- /beecrowd/1959.py: -------------------------------------------------------------------------------- 1 | # Ivan Carvalho 2 | # Solution to https://www.beecrowd.com.br/judge/problems/view/1959 3 | # -*- coding: utf-8 -*- 4 | 5 | """ 6 | Escreva a sua solução aqui 7 | Code your solution here 8 | Escriba su solución aquí 9 | """ 10 | a, b = [int(i) for i in input().split(" ")] 11 | print(a * b) 12 | -------------------------------------------------------------------------------- /beecrowd/1961.py: -------------------------------------------------------------------------------- 1 | # Ivan Carvalho 2 | # Solution to https://www.beecrowd.com.br/judge/problems/view/1961 3 | #!/usr/bin/env python 4 | # encoding : utf-8 5 | a, b = [int(i) for i in input().split(" ") if i != ""] 6 | array = [int(i) for i in input().split(" ") if i != ""] 7 | for i, j in zip(array[1:], array): 8 | if abs(i - j) > a: 9 | print("GAME OVER") 10 | break 11 | else: 12 | print("YOU WIN") 13 | -------------------------------------------------------------------------------- /beecrowd/1963.py: -------------------------------------------------------------------------------- 1 | # Ivan Carvalho 2 | # Solution to https://www.beecrowd.com.br/judge/problems/view/1963 3 | #!/usr/bin/env python 4 | # encoding : utf-8 5 | a, b = [float(i) for i in input().split(" ")] 6 | print("%.2f%%" % (100 * ((b / a) - 1.00))) 7 | -------------------------------------------------------------------------------- /beecrowd/1980.cpp: -------------------------------------------------------------------------------- 1 | // Ivan Carvalho 2 | // Solution to https://www.beecrowd.com.br/judge/problems/view/1980 3 | #include 4 | #include 5 | typedef unsigned long long int llu; 6 | int main() { 7 | char davez[20]; 8 | while (scanf("%s", davez)) { 9 | if (davez[0] == '0') break; 10 | llu resposta = 1; 11 | llu tamanho = llu(strlen(davez)); 12 | while (tamanho) { 13 | resposta *= tamanho--; 14 | } 15 | printf("%llu\n", resposta); 16 | } 17 | return 0; 18 | } 19 | -------------------------------------------------------------------------------- /beecrowd/1983.py: -------------------------------------------------------------------------------- 1 | # Ivan Carvalho 2 | # Solution to https://www.beecrowd.com.br/judge/problems/view/1983 3 | #!/usr/bin/env python 4 | # encoding : utf-8 5 | array = [] 6 | ordem = int(input()) 7 | for i in range(ordem): 8 | a, b = [float(i) for i in input().split(" ")] 9 | array.append(a + b * 1j) 10 | array.sort(key=lambda x: x.imag) 11 | maximo = array[-1] 12 | if maximo.imag >= 8: 13 | print(int(maximo.real)) 14 | else: 15 | print("Minimum note not reached") 16 | -------------------------------------------------------------------------------- /beecrowd/1984.cpp: -------------------------------------------------------------------------------- 1 | // Ivan Carvalho 2 | // Solution to https://www.beecrowd.com.br/judge/problems/view/1984 3 | #include 4 | #include 5 | #define endl '\n' 6 | using namespace std; 7 | int main() { 8 | ios_base::sync_with_stdio(0); 9 | cin.tie(0); 10 | string numero; 11 | cin >> numero; 12 | reverse(numero.begin(), numero.end()); 13 | cout << numero << endl; 14 | return 0; 15 | } 16 | -------------------------------------------------------------------------------- /beecrowd/1985.py: -------------------------------------------------------------------------------- 1 | # Ivan Carvalho 2 | # Solution to https://www.beecrowd.com.br/judge/problems/view/1985 3 | #!/usr/bin/env python 4 | # -*- coding : utf-8 -*- 5 | dicio = {1001: 1.5, 1002: 2.5, 1003: 3.5, 1004: 4.5, 1005: 5.5} 6 | casos = int(input()) 7 | resposta = 0 8 | for i in range(casos): 9 | a, b = [int(j) for j in input().split(" ")] 10 | resposta += dicio.get(a, 0) * b 11 | print("%.2f" % resposta) 12 | -------------------------------------------------------------------------------- /beecrowd/1987.cpp: -------------------------------------------------------------------------------- 1 | // Ivan Carvalho 2 | // Solution to https://www.beecrowd.com.br/judge/problems/view/1987 3 | #include 4 | int main() { 5 | int n; 6 | while (scanf("%d", &n) != EOF) { 7 | getchar(); 8 | int soma = 0; 9 | for (int i = 0; i < n; i++) { 10 | char davez; 11 | scanf("%c", &davez); 12 | soma += int(davez - '1' + 1); 13 | } 14 | if (!(soma % 3)) 15 | printf("%d sim\n", soma); 16 | else 17 | printf("%d nao\n", soma); 18 | } 19 | return 0; 20 | } 21 | -------------------------------------------------------------------------------- /beecrowd/2003.py: -------------------------------------------------------------------------------- 1 | # Ivan Carvalho 2 | # Solution to https://www.beecrowd.com.br/judge/problems/view/2003 3 | #!/usr/bin/env python 4 | # encoding : utf-8 5 | while True: 6 | try: 7 | a, b = [int(i) for i in input().split(":")] 8 | horas = a * 60 + b 9 | if horas <= 420: 10 | print("Atraso maximo: 0") 11 | else: 12 | print("Atraso maximo: %d" % (horas - 420)) 13 | except EOFError: 14 | break 15 | -------------------------------------------------------------------------------- /beecrowd/2006.py: -------------------------------------------------------------------------------- 1 | # Ivan Carvalho 2 | # Solution to https://www.beecrowd.com.br/judge/problems/view/2006 3 | #!/usr/bin/env python 4 | # -*- coding : utf-8 -*- 5 | cha = input() 6 | print(input().split().count(cha)) 7 | -------------------------------------------------------------------------------- /beecrowd/2028.py: -------------------------------------------------------------------------------- 1 | # Ivan Carvalho 2 | # Solution to https://www.beecrowd.com.br/judge/problems/view/2028 3 | #!/usr/bin/env python 4 | # -*- coidng : utf-8 -*- 5 | caso = 1 6 | while True: 7 | try: 8 | ordem = int(input()) 9 | except EOFError: 10 | break 11 | vetor = ["0"] 12 | if ordem == 0: 13 | print("Caso %d: 1 numero\n0\n" % caso) 14 | caso += 1 15 | continue 16 | for i in range(1, ordem + 1): 17 | vetor.extend([str(i)] * i) 18 | print("Caso %d: %d numeros\n%s\n" % (caso, len(vetor), " ".join(vetor))) 19 | caso += 1 20 | -------------------------------------------------------------------------------- /beecrowd/2029.py: -------------------------------------------------------------------------------- 1 | # Ivan Carvalho 2 | # Solution to https://www.beecrowd.com.br/judge/problems/view/2029 3 | #!/usr/bin/env python 4 | # encoding : utf-8 5 | while True: 6 | try: 7 | volume = float(input()) 8 | diametro = float(input()) 9 | print("ALTURA = %.2f" % (4.0 * volume / (3.14 * (diametro**2)))) 10 | print("AREA = %.2f" % (3.14 * (diametro**2) / 4.0)) 11 | except EOFError: 12 | break 13 | -------------------------------------------------------------------------------- /beecrowd/2044.cpp: -------------------------------------------------------------------------------- 1 | // Ivan Carvalho 2 | // Solution to https://www.beecrowd.com.br/judge/problems/view/2044 3 | #include 4 | int main() { 5 | int n; 6 | while (scanf("%d", &n) && n > 0) { 7 | int soma = 0; 8 | int resp = 0; 9 | while (n--) { 10 | int davez; 11 | scanf("%d", &davez); 12 | soma += davez; 13 | soma %= 100; 14 | resp += (soma == 0); 15 | } 16 | printf("%d\n", resp); 17 | } 18 | return 0; 19 | } 20 | -------------------------------------------------------------------------------- /beecrowd/2049.py: -------------------------------------------------------------------------------- 1 | # Ivan Carvalho 2 | # Solution to https://www.beecrowd.com.br/judge/problems/view/2049 3 | #!/usr/bin/env/python 4 | # -*- coding : utf-8 -*- 5 | instancia = 1 6 | while True: 7 | entrada = input() 8 | if entrada == "0": 9 | break 10 | if instancia != 1: 11 | print("") 12 | checar = input() 13 | print("Instancia %d" % instancia) 14 | instancia += 1 15 | if entrada in checar: 16 | print("verdadeira") 17 | else: 18 | print("falsa") 19 | -------------------------------------------------------------------------------- /beecrowd/2057.py: -------------------------------------------------------------------------------- 1 | # Ivan Carvalho 2 | # Solution to https://www.beecrowd.com.br/judge/problems/view/2057 3 | #!/usr/bin/env python 4 | # encoding : utf-8 5 | numero = sum([int(i) for i in input().split(" ")]) 6 | if numero < 0: 7 | print(numero + 24) 8 | elif numero < 24: 9 | print(numero) 10 | else: 11 | print(numero - 24) 12 | -------------------------------------------------------------------------------- /beecrowd/2058.py: -------------------------------------------------------------------------------- 1 | # Ivan Carvalho 2 | # Solution to https://www.beecrowd.com.br/judge/problems/view/2058 3 | # -*- coding: utf-8 -*- 4 | 5 | """ 6 | Escreva a sua solução aqui 7 | Code your solution here 8 | Escriba su solución aquí 9 | """ 10 | print(int(input()) - 2) 11 | -------------------------------------------------------------------------------- /beecrowd/2060.py: -------------------------------------------------------------------------------- 1 | # Ivan Carvalho 2 | # Solution to https://www.beecrowd.com.br/judge/problems/view/2060 3 | #!/usr/bin/env python 4 | # encoding : utf-8 5 | ordem = int(input()) 6 | array = [int(i) for i in input().split(" ")] 7 | for j in [2, 3, 4, 5]: 8 | print("%d Multiplo(s) de %d" % (len([i for i in array if i % j == 0]), j)) 9 | -------------------------------------------------------------------------------- /beecrowd/2061.py: -------------------------------------------------------------------------------- 1 | # Ivan Carvalho 2 | # Solution to https://www.beecrowd.com.br/judge/problems/view/2061 3 | #!/usr/bin/env python 4 | # encoding : utf-8 5 | a, b = [int(i) for i in input().split(" ")] 6 | abriu = 0 7 | fechou = 0 8 | for i in range(b): 9 | entrada = input() 10 | if entrada == "fechou": 11 | fechou += 1 12 | else: 13 | abriu += 1 14 | print(a + fechou - abriu) 15 | -------------------------------------------------------------------------------- /beecrowd/2062.py: -------------------------------------------------------------------------------- 1 | # Ivan Carvalho 2 | # Solution to https://www.beecrowd.com.br/judge/problems/view/2062 3 | #!/usr/bin/env python 4 | # encoding : utf-8 5 | ordem = int(input()) 6 | array = input().split() 7 | for i in range(len(array)): 8 | t = array[i] 9 | if len(t) == 3: 10 | if "OB" in t: 11 | array[i] = "OBI" 12 | elif "UR" in t: 13 | array[i] = "URI" 14 | print(" ".join(array)) 15 | -------------------------------------------------------------------------------- /beecrowd/2091.cpp: -------------------------------------------------------------------------------- 1 | // Ivan Carvalho 2 | // Solution to https://www.beecrowd.com.br/judge/problems/view/2091 3 | #include 4 | typedef long long ll; 5 | int main() { 6 | int n; 7 | while (scanf("%d", &n) && n) { 8 | ll resp = 0; 9 | while (n--) { 10 | ll davez; 11 | scanf("%lld", &davez); 12 | resp ^= davez; 13 | } 14 | printf("%lld\n", resp); 15 | } 16 | return 0; 17 | } 18 | -------------------------------------------------------------------------------- /beecrowd/2108.py: -------------------------------------------------------------------------------- 1 | # Ivan Carvalho 2 | # Solution to https://www.beecrowd.com.br/judge/problems/view/2108 3 | #!/usr/bin/env python 4 | # -*- coding : utf-8 -*- 5 | maior = 0 6 | palavra = "" 7 | while True: 8 | entrada = input().split() 9 | resposta = [] 10 | if entrada == ["0"]: 11 | break 12 | for i in entrada: 13 | tamanho = len(i) 14 | if tamanho >= maior: 15 | maior = tamanho 16 | palavra = i 17 | resposta.append(str(tamanho)) 18 | print("-".join(resposta)) 19 | print("\nThe biggest word: %s" % palavra) 20 | -------------------------------------------------------------------------------- /beecrowd/2129.cpp: -------------------------------------------------------------------------------- 1 | // Ivan Carvalho 2 | // Solution to https://www.beecrowd.com.br/judge/problems/view/2129 3 | #include 4 | #define MAXN 1000001 5 | typedef long long ll; 6 | ll vetor[MAXN]; 7 | int main() { 8 | vetor[0] = 1LL; 9 | for (ll i = 1; i < MAXN; i++) { 10 | vetor[i] = (i * vetor[i - 1]); 11 | while (!(vetor[i] % 10)) vetor[i] /= 10; 12 | vetor[i] %= 100000; 13 | } 14 | ll instancia = 0, n; 15 | while (scanf("%lld", &n) != EOF) { 16 | printf("Instancia %lld\n%lld\n\n", ++instancia, vetor[n] % 10); 17 | } 18 | return 0; 19 | } 20 | -------------------------------------------------------------------------------- /beecrowd/2134.py: -------------------------------------------------------------------------------- 1 | # Ivan Carvalho 2 | # Solution to https://www.beecrowd.com.br/judge/problems/view/2134 3 | #!/usr/bin/env python 4 | # -*- coding : utf-8 -*- 5 | count = 1 6 | while True: 7 | try: 8 | ordem = int(input()) 9 | except EOFError: 10 | break 11 | lista = [] 12 | for i in range(ordem): 13 | a, b = input().split() 14 | lista.append((-int(b), a)) 15 | lista.sort() 16 | print("Instancia %d" % count) 17 | count += 1 18 | print(lista[-1][1]) 19 | print("") 20 | -------------------------------------------------------------------------------- /beecrowd/2146.cpp: -------------------------------------------------------------------------------- 1 | // Ivan Carvalho 2 | // Solution to https://www.beecrowd.com.br/judge/problems/view/2146 3 | #include 4 | int main() { 5 | int n; 6 | while (scanf("%d", &n) != EOF) { 7 | printf("%d\n", n - 1); 8 | } 9 | return 0; 10 | } 11 | -------------------------------------------------------------------------------- /beecrowd/2147.py: -------------------------------------------------------------------------------- 1 | # Ivan Carvalho 2 | # Solution to https://www.beecrowd.com.br/judge/problems/view/2147 3 | #!/usr/bin/env python 4 | # -*- coding : utf-8 -*- 5 | casos = int(input()) 6 | for caso_da_vez in range(casos): 7 | print("%.2f" % (float(len(input())) / 100.0)) 8 | -------------------------------------------------------------------------------- /beecrowd/2152.py: -------------------------------------------------------------------------------- 1 | # Ivan Carvalho 2 | # Solution to https://www.beecrowd.com.br/judge/problems/view/2152 3 | #!/usr/bin/env python 4 | # -*- coding : utf-8 -*- 5 | dicio = {x: "0%d" % (x) for x in range(0, 10)} 6 | for x in range(10, 61): 7 | dicio[x] = str(x) 8 | casos = int(input()) 9 | for caso in range(casos): 10 | a, b, c = [int(i) for i in input().split()] 11 | a = dicio[a] 12 | b = dicio[b] 13 | c = {1: "- A porta abriu!", 0: "- A porta fechou!"}[c] 14 | print("%s:%s %s" % (a, b, c)) 15 | -------------------------------------------------------------------------------- /beecrowd/2153.py: -------------------------------------------------------------------------------- 1 | # Ivan Carvalho 2 | # Solution to https://www.beecrowd.com.br/judge/problems/view/2153 3 | #!/usr/bin/env python 4 | # -*- coding : utf-8 -*- 5 | while True: 6 | try: 7 | entrada = input()[::-1] 8 | except EOFError: 9 | break 10 | tamanho = len(entrada) 11 | i = 1 12 | while entrada.count(entrada[:i]) > 1 and i <= tamanho: 13 | i += 1 14 | trecho = entrada[: i - 1] 15 | entrada = entrada.replace(trecho, "", entrada.count(trecho) - 1) 16 | print(entrada[::-1]) 17 | -------------------------------------------------------------------------------- /beecrowd/2157.py: -------------------------------------------------------------------------------- 1 | # Ivan Carvalho 2 | # Solution to https://www.beecrowd.com.br/judge/problems/view/2157 3 | #!/usr/bbin/env python 4 | # -*- coding : utf-8 -*- 5 | tc = int(input()) 6 | for algo in range(tc): 7 | a, b = [int(i) for i in input().split()] 8 | lista = [] 9 | reverso = [] 10 | for i in range(a, b + 1): 11 | lista.append(str(i)) 12 | reverso.append(str(i)[::-1]) 13 | print("".join(lista + reverso[::-1])) 14 | -------------------------------------------------------------------------------- /beecrowd/2158.py: -------------------------------------------------------------------------------- 1 | # Ivan Carvalho 2 | # Solution to https://www.beecrowd.com.br/judge/problems/view/2158 3 | #!/usr/bin/env python 4 | # -*- coding : utf-8 -*- 5 | molecula = 0 6 | while True: 7 | try: 8 | a, b = [int(i) for i in input().split()] 9 | except EOFError: 10 | break 11 | molecula += 1 12 | print("Molecula #%d.:." % (molecula)) 13 | ligacoes = (a * 5 + b * 6) / 2 14 | atomos = 2 - a - b + ligacoes 15 | print("Possui %d atomos e %d ligacoes" % (atomos, ligacoes)) 16 | print("") 17 | -------------------------------------------------------------------------------- /beecrowd/2159.py: -------------------------------------------------------------------------------- 1 | # Ivan Carvalho 2 | # Solution to https://www.beecrowd.com.br/judge/problems/view/2159 3 | #!/usr/bin/env python 4 | # -*- coding : utf-8 -*- 5 | from math import log 6 | 7 | n = int(input()) 8 | print("%.1f %.1f" % (n / log(n), 1.25506 * n / log(n))) 9 | -------------------------------------------------------------------------------- /beecrowd/2160.py: -------------------------------------------------------------------------------- 1 | # Ivan Carvalho 2 | # Solution to https://www.beecrowd.com.br/judge/problems/view/2160 3 | #!/usr/bin/env python 4 | # -*- coding : utf-8 -*- 5 | entrada = input() 6 | if len(entrada) <= 80: 7 | print("YES") 8 | else: 9 | print("NO") 10 | -------------------------------------------------------------------------------- /beecrowd/2164.cpp: -------------------------------------------------------------------------------- 1 | // Ivan Carvalho 2 | // Solution to https://www.beecrowd.com.br/judge/problems/view/2164 3 | #include 4 | #define MAXN 60 5 | double sequencia[MAXN]; 6 | double funcao(int x) { 7 | if (x == 0) return sequencia[0] = 0; 8 | if (x == 1) return sequencia[1] = 1; 9 | if (sequencia[x] != 0) return sequencia[x]; 10 | return sequencia[x] = funcao(x - 1) + funcao(x - 2); 11 | } 12 | int main() { 13 | int n; 14 | scanf("%d", &n); 15 | printf("%.1lf\n", funcao(n)); 16 | return 0; 17 | } 18 | -------------------------------------------------------------------------------- /beecrowd/2165.py: -------------------------------------------------------------------------------- 1 | # Ivan Carvalho 2 | # Solution to https://www.beecrowd.com.br/judge/problems/view/2165 3 | #!/usr/bin/env python 4 | # -*- coding : utf-8 -*- 5 | entrada = input() 6 | if len(entrada) <= 140: 7 | print("TWEET") 8 | else: 9 | print("MUTE") 10 | -------------------------------------------------------------------------------- /beecrowd/2167.cpp: -------------------------------------------------------------------------------- 1 | // Ivan Carvalho 2 | // Solution to https://www.beecrowd.com.br/judge/problems/view/2167 3 | #include 4 | int main() { 5 | int primeiro[10000]; 6 | int casos; 7 | scanf("%d", &casos); 8 | for (int i = 1; i <= casos; i++) scanf("%d", &primeiro[i]); 9 | for (int i = 2; i <= casos; i++) { 10 | if (primeiro[i] < primeiro[i - 1]) { 11 | printf("%i\n", i); 12 | return 0; 13 | } 14 | } 15 | printf("0\n"); 16 | return 0; 17 | } 18 | -------------------------------------------------------------------------------- /beecrowd/2174.cpp: -------------------------------------------------------------------------------- 1 | // Ivan Carvalho 2 | // Solution to https://www.beecrowd.com.br/judge/problems/view/2174 3 | #include 4 | #include 5 | #include 6 | #define endl '\n' 7 | using namespace std; 8 | int main() { 9 | ios_base::sync_with_stdio(0); 10 | cin.tie(0); 11 | set pokemons; 12 | int n; 13 | cin >> n; 14 | while (n--) { 15 | string davez; 16 | cin >> davez; 17 | pokemons.insert(davez); 18 | } 19 | cout << "Falta(m) " << 151 - pokemons.size() << " pomekon(s)." << endl; 20 | return 0; 21 | } 22 | -------------------------------------------------------------------------------- /beecrowd/2175.cpp: -------------------------------------------------------------------------------- 1 | // Ivan Carvalho 2 | // Solution to https://www.beecrowd.com.br/judge/problems/view/2175 3 | #include 4 | int main() { 5 | double otavio, bruno, flavio; 6 | scanf("%lf %lf %lf", &otavio, &bruno, &flavio); 7 | if (otavio < bruno && otavio < flavio) 8 | printf("Otavio\n"); 9 | else if (bruno < otavio && bruno < flavio) 10 | printf("Bruno\n"); 11 | else if (flavio < otavio && flavio < bruno) 12 | printf("Ian\n"); 13 | else 14 | printf("Empate\n"); 15 | return 0; 16 | } 17 | -------------------------------------------------------------------------------- /beecrowd/2176.cpp: -------------------------------------------------------------------------------- 1 | // Ivan Carvalho 2 | // Solution to https://www.beecrowd.com.br/judge/problems/view/2176 3 | #include 4 | #include 5 | #define endl '\n' 6 | using namespace std; 7 | int main() { 8 | ios_base::sync_with_stdio(0); 9 | cin.tie(0); 10 | string entrada; 11 | cin >> entrada; 12 | int uns = 0; 13 | for (int i = 0; i < entrada.size(); i++) uns += (int)(entrada[i] == '1'); 14 | cout << entrada; 15 | if (uns % 2 == 0) 16 | cout << "0" << endl; 17 | else 18 | cout << "1" << endl; 19 | return 0; 20 | } 21 | -------------------------------------------------------------------------------- /beecrowd/2177.cpp: -------------------------------------------------------------------------------- 1 | // Ivan Carvalho 2 | // Solution to https://www.beecrowd.com.br/judge/problems/view/2177 3 | #include 4 | int main() { 5 | long long x, y, pontos, contador = 0; 6 | scanf("%lld %lld %lld", &x, &y, &pontos); 7 | for (long long i = 1; i <= pontos; i++) { 8 | long long u, v, t; 9 | scanf("%lld %lld %lld", &u, &v, &t); 10 | if ((x - u) * (x - u) + (y - v) * (y - v) < t * t) { 11 | if (contador) printf(" "); 12 | printf("%lld", i); 13 | contador++; 14 | } 15 | } 16 | if (contador == 0) printf("-1"); 17 | printf("\n"); 18 | return 0; 19 | } 20 | -------------------------------------------------------------------------------- /beecrowd/2187.cpp: -------------------------------------------------------------------------------- 1 | // Ivan Carvalho 2 | // Solution to https://www.beecrowd.com.br/judge/problems/view/2187 3 | #include 4 | int main() { 5 | int n, teste = 1; 6 | while (scanf("%d", &n) && n) { 7 | printf("Teste %d\n", teste++); 8 | printf("%d ", n / 50); 9 | n %= 50; 10 | printf("%d ", n / 10); 11 | n %= 10; 12 | printf("%d ", n / 5); 13 | n %= 5; 14 | printf("%d\n\n", n); 15 | } 16 | return 0; 17 | } 18 | -------------------------------------------------------------------------------- /beecrowd/2217.cpp: -------------------------------------------------------------------------------- 1 | // Ivan Carvalho 2 | // Solution to https://www.beecrowd.com.br/judge/problems/view/2217 3 | #include 4 | int main() { 5 | int t; 6 | scanf("%d", &t); 7 | while (t--) { 8 | int n; 9 | scanf("%d", &n); 10 | printf("%d\n", (n % 2 == 0) ? 1 : 9); 11 | } 12 | return 0; 13 | } 14 | -------------------------------------------------------------------------------- /beecrowd/2229.cpp: -------------------------------------------------------------------------------- 1 | // Ivan Carvalho 2 | // Solution to https://www.beecrowd.com.br/judge/problems/view/2229 3 | #include 4 | int main() { 5 | int n, teste = 1; 6 | while (scanf("%d", &n) && (n + 1)) { 7 | int inteiro = ((1 << n) + 1); 8 | inteiro *= inteiro; 9 | printf("Teste %d\n%d\n\n", teste++, inteiro); 10 | } 11 | return 0; 12 | } 13 | -------------------------------------------------------------------------------- /beecrowd/2232.cpp: -------------------------------------------------------------------------------- 1 | // Ivan Carvalho 2 | // Solution to https://www.beecrowd.com.br/judge/problems/view/2232 3 | #include 4 | int main() { 5 | int n, davez; 6 | scanf("%d", &n); 7 | for (int i = 0; i < n; i++) { 8 | scanf("%d", &davez); 9 | printf("%d\n", (1 << davez) - 1); 10 | } 11 | return 0; 12 | } 13 | -------------------------------------------------------------------------------- /beecrowd/2234.cpp: -------------------------------------------------------------------------------- 1 | // Ivan Carvalho 2 | // Solution to https://www.beecrowd.com.br/judge/problems/view/2234 3 | #include 4 | double a, b; 5 | int main() { 6 | scanf("%lf %lf", &a, &b); 7 | printf("%.2lf\n", a / b); 8 | return 0; 9 | } 10 | -------------------------------------------------------------------------------- /beecrowd/2235.cpp: -------------------------------------------------------------------------------- 1 | // Ivan Carvalho 2 | // Solution to https://www.beecrowd.com.br/judge/problems/view/2235 3 | #include 4 | int main() { 5 | int a, b, c; 6 | scanf("%d %d %d", &a, &b, &c); 7 | if (a == b || a == c || b == c || (a + b) == c || (a + c) == b || 8 | (b + c) == a) 9 | printf("S\n"); 10 | else 11 | printf("N\n"); 12 | return 0; 13 | } 14 | -------------------------------------------------------------------------------- /beecrowd/2247.cpp: -------------------------------------------------------------------------------- 1 | // Ivan Carvalho 2 | // Solution to https://www.beecrowd.com.br/judge/problems/view/2247 3 | #include 4 | int main() { 5 | int n, teste = 1; 6 | while (scanf("%d", &n) && n) { 7 | printf("Teste %d\n", teste++); 8 | int saldo = 0; 9 | while (n--) { 10 | int x, y; 11 | scanf("%d %d", &x, &y); 12 | saldo += x - y; 13 | printf("%d\n", saldo); 14 | } 15 | printf("\n"); 16 | } 17 | return 0; 18 | } 19 | -------------------------------------------------------------------------------- /beecrowd/2251.cpp: -------------------------------------------------------------------------------- 1 | // Ivan Carvalho 2 | // Solution to https://www.beecrowd.com.br/judge/problems/view/2251 3 | #include 4 | #include 5 | int main() { 6 | int n, count = 1; 7 | while (1) { 8 | scanf("%d", &n); 9 | if (n == 0) break; 10 | printf("Teste %d\n", count++); 11 | printf("%.0f\n\n", pow(2, n) - 1.0); 12 | } 13 | return 0; 14 | } 15 | -------------------------------------------------------------------------------- /beecrowd/2291.cpp: -------------------------------------------------------------------------------- 1 | // Ivan Carvalho 2 | // Solution to https://www.beecrowd.com.br/judge/problems/view/2291 3 | #include 4 | #define MAXN 1000001 5 | typedef long long ll; 6 | ll soma[MAXN], acumulada[MAXN]; 7 | int main() { 8 | for (ll i = 1; i < MAXN; i++) { 9 | for (ll j = i; j < MAXN; j += i) { 10 | soma[j] += i; 11 | } 12 | } 13 | for (ll i = 1; i < MAXN; i++) { 14 | acumulada[i] = acumulada[i - 1] + soma[i]; 15 | } 16 | int n; 17 | while (scanf("%d", &n) && n) { 18 | printf("%lld\n", acumulada[n]); 19 | } 20 | return 0; 21 | } 22 | -------------------------------------------------------------------------------- /beecrowd/2295.cpp: -------------------------------------------------------------------------------- 1 | // Ivan Carvalho 2 | // Solution to https://www.beecrowd.com.br/judge/problems/view/2295 3 | #include 4 | int main() { 5 | double a, g, ra, rg; 6 | scanf("%lf %lf %lf %lf", &a, &g, &ra, &rg); 7 | if (ra / a > rg / g) 8 | printf("A\n"); 9 | else 10 | printf("G\n"); 11 | return 0; 12 | } 13 | -------------------------------------------------------------------------------- /beecrowd/2321.cpp: -------------------------------------------------------------------------------- 1 | // Ivan Carvalho 2 | // Solution to https://www.beecrowd.com.br/judge/problems/view/2321 3 | #include 4 | #include 5 | using namespace std; 6 | int main() { 7 | int a, b, c, d, e, f, g, h; 8 | scanf("%d %d %d %d %d %d %d %d", &a, &b, &c, &d, &e, &f, &g, &h); 9 | int xmin = max(a, e); 10 | int xmax = min(c, g); 11 | if (xmin > xmax) { 12 | printf("0\n"); 13 | return 0; 14 | } 15 | int ymin = max(b, f); 16 | int ymax = min(d, h); 17 | if (ymin > ymax) { 18 | printf("0\n"); 19 | return 0; 20 | } 21 | printf("1\n"); 22 | return 0; 23 | } 24 | -------------------------------------------------------------------------------- /beecrowd/2322.cpp: -------------------------------------------------------------------------------- 1 | // Ivan Carvalho 2 | // Solution to https://www.beecrowd.com.br/judge/problems/view/2322 3 | #include 4 | #define MAXN 1001 5 | int vetor[MAXN]; 6 | int main() { 7 | int n; 8 | scanf("%d", &n); 9 | for (int i = 1; i < n; i++) { 10 | int x; 11 | scanf("%d", &x); 12 | vetor[x] = 1; 13 | } 14 | for (int i = 1; i <= n; i++) 15 | if (!vetor[i]) { 16 | printf("%d\n", i); 17 | break; 18 | } 19 | return 0; 20 | } 21 | -------------------------------------------------------------------------------- /beecrowd/2328.cpp: -------------------------------------------------------------------------------- 1 | // Ivan Carvalho 2 | // Solution to https://www.beecrowd.com.br/judge/problems/view/2328 3 | #include 4 | int main() { 5 | int n, soma = 0; 6 | scanf("%d", &n); 7 | for (int i = 1; i <= n; i++) { 8 | int x; 9 | scanf("%d", &x); 10 | soma += x; 11 | } 12 | printf("%d\n", soma - n); 13 | return 0; 14 | } 15 | -------------------------------------------------------------------------------- /beecrowd/2339.cpp: -------------------------------------------------------------------------------- 1 | // Ivan Carvalho 2 | // Solution to https://www.beecrowd.com.br/judge/problems/view/2339 3 | #include 4 | int main() { 5 | int c, p, f; 6 | scanf("%d %d %d", &c, &p, &f); 7 | if (c * f <= p) { 8 | printf("S\n"); 9 | } else { 10 | printf("N\n"); 11 | } 12 | return 0; 13 | } 14 | -------------------------------------------------------------------------------- /beecrowd/2340.cpp: -------------------------------------------------------------------------------- 1 | // Ivan Carvalho 2 | // Solution to https://www.beecrowd.com.br/judge/problems/view/2340 3 | #include 4 | #include 5 | int main() { 6 | int resposta = 0, n; 7 | double maximo = 0.0; 8 | scanf("%d", &n); 9 | for (int i = 0; i < n; i++) { 10 | int x, y; 11 | scanf("%d %d", &x, &y); 12 | double davez = y * log(x); 13 | if (davez > maximo) { 14 | maximo = davez; 15 | resposta = i; 16 | } 17 | } 18 | printf("%d\n", resposta); 19 | return 0; 20 | } 21 | -------------------------------------------------------------------------------- /beecrowd/2341.cpp: -------------------------------------------------------------------------------- 1 | // Ivan Carvalho 2 | // Solution to https://www.beecrowd.com.br/judge/problems/view/2341 3 | #include 4 | int vetor[1010]; 5 | int min(int x, int y) { 6 | if (x < y) return x; 7 | return y; 8 | } 9 | int main() { 10 | int n, k, resposta = 2147483647; 11 | scanf("%d %d", &n, &k); 12 | while (n--) { 13 | int davez; 14 | scanf("%d", &davez); 15 | vetor[davez]++; 16 | } 17 | for (int i = 1; i <= k; i++) resposta = min(resposta, vetor[i]); 18 | printf("%d\n", resposta); 19 | return 0; 20 | } 21 | -------------------------------------------------------------------------------- /beecrowd/2342.cpp: -------------------------------------------------------------------------------- 1 | // Ivan Carvalho 2 | // Solution to https://www.beecrowd.com.br/judge/problems/view/2342 3 | #include 4 | int main() { 5 | int a, b, c; 6 | char digito; 7 | scanf("%d", &a); 8 | scanf("%d %c %d", &b, &digito, &c); 9 | if (digito == 43) { 10 | if (a >= (b + c)) { 11 | printf("OK\n"); 12 | } else { 13 | printf("OVERFLOW\n"); 14 | } 15 | } else { 16 | if (a >= (b * c)) { 17 | printf("OK\n"); 18 | } else { 19 | printf("OVERFLOW\n"); 20 | } 21 | } 22 | return 0; 23 | } 24 | -------------------------------------------------------------------------------- /beecrowd/2344.cpp: -------------------------------------------------------------------------------- 1 | // Ivan Carvalho 2 | // Solution to https://www.beecrowd.com.br/judge/problems/view/2344 3 | #include 4 | int main() { 5 | int nota; 6 | scanf("%d", ¬a); 7 | if (nota >= 86) { 8 | printf("A\n"); 9 | } else if (nota >= 61) { 10 | printf("B\n"); 11 | } else if (nota >= 36) { 12 | printf("C\n"); 13 | } else if (nota >= 1) { 14 | printf("D\n"); 15 | } else { 16 | printf("E\n"); 17 | } 18 | return 0; 19 | } 20 | -------------------------------------------------------------------------------- /beecrowd/2345.cpp: -------------------------------------------------------------------------------- 1 | // Ivan Carvalho 2 | // Solution to https://www.beecrowd.com.br/judge/problems/view/2345 3 | #include 4 | #include 5 | #include 6 | using namespace std; 7 | int main() { 8 | int a, b, c, d; 9 | scanf("%d %d %d %d", &a, &b, &c, &d); 10 | int pos1 = abs(a + b - c - d); 11 | pos1 = min(pos1, abs(a + c - b - d)); 12 | pos1 = min(pos1, abs(a + d - b - c)); 13 | pos1 = min(pos1, abs(b + d - a - c)); 14 | pos1 = min(pos1, abs(b + c - a - d)); 15 | pos1 = min(pos1, abs(c + d - a - b)); 16 | printf("%d\n", pos1); 17 | return 0; 18 | } 19 | -------------------------------------------------------------------------------- /beecrowd/2349.cpp: -------------------------------------------------------------------------------- 1 | // Ivan Carvalho 2 | // Solution to https://www.beecrowd.com.br/judge/problems/view/2349 3 | #include 4 | int vetor[101]; 5 | int main() { 6 | int n, c, s; 7 | scanf("%d %d %d", &n, &c, &s); 8 | int ini = 1; 9 | vetor[ini]++; 10 | while (c--) { 11 | int comando; 12 | scanf("%d", &comando); 13 | if (comando == 1) { 14 | ini++; 15 | if (ini == n + 1) ini = 1; 16 | } else { 17 | ini--; 18 | if (ini == 0) ini = n; 19 | } 20 | vetor[ini]++; 21 | } 22 | printf("%d\n", vetor[s]); 23 | return 0; 24 | } 25 | -------------------------------------------------------------------------------- /beecrowd/2353.cpp: -------------------------------------------------------------------------------- 1 | // Ivan Carvalho 2 | // Solution to https://www.beecrowd.com.br/judge/problems/view/2353 3 | #include 4 | typedef long long ll; 5 | bool isprime(ll x) { 6 | if (x == 2) return true; 7 | if (x % 2 == 0) return false; 8 | for (ll i = 3; i * i <= x; i += 2) { 9 | if (x % i == 0) return false; 10 | } 11 | return true; 12 | } 13 | int main() { 14 | ll n; 15 | scanf("%lld", &n); 16 | while (n > 0) { 17 | if (isprime(n)) { 18 | printf("%lld\n", n); 19 | return 0; 20 | } 21 | n--; 22 | } 23 | return 0; 24 | } 25 | -------------------------------------------------------------------------------- /beecrowd/2366.cpp: -------------------------------------------------------------------------------- 1 | // Ivan Carvalho 2 | // Solution to https://www.beecrowd.com.br/judge/problems/view/2366 3 | #include 4 | int vetor[10010]; 5 | int main() { 6 | int n, m; 7 | scanf("%d %d", &n, &m); 8 | vetor[n] = 42195; 9 | for (int i = 0; i < n; i++) scanf("%d", &vetor[i]); 10 | for (int i = 1; i <= n; i++) { 11 | if (vetor[i] - vetor[i - 1] > m) { 12 | printf("N\n"); 13 | return 0; 14 | } 15 | } 16 | printf("S\n"); 17 | return 0; 18 | } 19 | -------------------------------------------------------------------------------- /beecrowd/2369.cpp: -------------------------------------------------------------------------------- 1 | // Ivan Carvalho 2 | // Solution to https://www.beecrowd.com.br/judge/problems/view/2369 3 | #include 4 | int main() { 5 | int a; 6 | scanf("%d", &a); 7 | if (a <= 10) 8 | printf("7\n"); 9 | else if (a <= 30) 10 | printf("%d\n", a - 3); 11 | else if (a <= 100) 12 | printf("%d\n", 27 + (a - 30) * 2); 13 | else 14 | printf("%d\n", 167 + (a - 100) * 5); 15 | return 0; 16 | } 17 | -------------------------------------------------------------------------------- /beecrowd/2373.cpp: -------------------------------------------------------------------------------- 1 | // Ivan Carvalho 2 | // Solution to https://www.beecrowd.com.br/judge/problems/view/2373 3 | #include 4 | int main() { 5 | int resp = 0, casos, i; 6 | scanf("%d", &casos); 7 | for (i = 0; i < casos; i++) { 8 | int l, c; 9 | scanf("%d %d", &l, &c); 10 | if (l > c) resp += c; 11 | } 12 | printf("%d\n", resp); 13 | return 0; 14 | } 15 | -------------------------------------------------------------------------------- /beecrowd/2374.cpp: -------------------------------------------------------------------------------- 1 | // Ivan Carvalho 2 | // Solution to https://www.beecrowd.com.br/judge/problems/view/2374 3 | #include 4 | int main() { 5 | int a, b; 6 | scanf("%d", &a); 7 | scanf("%d", &b); 8 | printf("%d\n", a - b); 9 | return 0; 10 | } 11 | -------------------------------------------------------------------------------- /beecrowd/2375.cpp: -------------------------------------------------------------------------------- 1 | // Ivan Carvalho 2 | // Solution to https://www.beecrowd.com.br/judge/problems/view/2375 3 | #include 4 | int main() { 5 | int a, b, c, d; 6 | scanf("%d", &a); 7 | scanf("%d %d %d", &b, &c, &d); 8 | if (a <= b && a <= c && a <= d) 9 | printf("S\n"); 10 | else 11 | printf("N\n"); 12 | return 0; 13 | } 14 | -------------------------------------------------------------------------------- /beecrowd/2377.cpp: -------------------------------------------------------------------------------- 1 | // Ivan Carvalho 2 | // Solution to https://www.beecrowd.com.br/judge/problems/view/2377 3 | #include 4 | int main() { 5 | int a, b, c, d; 6 | scanf("%d %d", &a, &b); 7 | scanf("%d %d", &c, &d); 8 | printf("%d\n", ((a / b) * d) + a * c); 9 | return 0; 10 | } 11 | -------------------------------------------------------------------------------- /beecrowd/2378.cpp: -------------------------------------------------------------------------------- 1 | // Ivan Carvalho 2 | // Solution to https://www.beecrowd.com.br/judge/problems/view/2378 3 | #include 4 | int main() { 5 | int n, c, i, total = 0, excedeu = 0; 6 | scanf("%d %d", &n, &c); 7 | for (i = 0; i < n; i++) { 8 | int a, b; 9 | scanf("%d %d", &a, &b); 10 | total += b; 11 | total -= a; 12 | if (total > c) { 13 | excedeu = 1; 14 | } 15 | } 16 | if (excedeu == 0) 17 | printf("N\n"); 18 | else 19 | printf("S\n"); 20 | return 0; 21 | } 22 | -------------------------------------------------------------------------------- /beecrowd/2381.cpp: -------------------------------------------------------------------------------- 1 | // Ivan Carvalho 2 | // Solution to https://www.beecrowd.com.br/judge/problems/view/2381 3 | #include 4 | #include 5 | #include 6 | using namespace std; 7 | int main() { 8 | std::ios::sync_with_stdio(false); 9 | int a, b, i; 10 | cin >> a >> b; 11 | vector nomes(a); 12 | for (i = 0; i < a; i++) { 13 | cin >> nomes[i]; 14 | } 15 | sort(nomes.begin(), nomes.end()); 16 | cout << nomes[b - 1] << endl; 17 | return 0; 18 | } 19 | -------------------------------------------------------------------------------- /beecrowd/2382.cpp: -------------------------------------------------------------------------------- 1 | // Ivan Carvalho 2 | // Solution to https://www.beecrowd.com.br/judge/problems/view/2382 3 | #include 4 | int main() { 5 | int a, b, c, d; 6 | scanf("%d %d %d %d", &a, &b, &c, &d); 7 | d *= 2; 8 | printf("%c\n", a * a + b * b + c * c <= d * d ? 'S' : 'N'); 9 | return 0; 10 | } 11 | -------------------------------------------------------------------------------- /beecrowd/2385.cpp: -------------------------------------------------------------------------------- 1 | // Ivan Carvalho 2 | // Solution to https://www.beecrowd.com.br/judge/problems/view/2385 3 | #include 4 | typedef long long ll; 5 | ll resposta; 6 | int main() { 7 | int ordem, p, q, r, s, x, y, a, b; 8 | scanf("%d %d %d %d %d %d %d %d %d", &ordem, &p, &q, &r, &s, &x, &y, &a, &b); 9 | for (int i = 1; i <= ordem; i++) { 10 | ll elemento1 = (p * a + q * i) % x; 11 | ll elemento2 = (i * r + s * b) % y; 12 | resposta += elemento1 * elemento2; 13 | } 14 | printf("%lld\n", resposta); 15 | return 0; 16 | } 17 | -------------------------------------------------------------------------------- /beecrowd/2386.cpp: -------------------------------------------------------------------------------- 1 | // Ivan Carvalho 2 | // Solution to https://www.beecrowd.com.br/judge/problems/view/2386 3 | #include 4 | int main() { 5 | int n, resposta = 0, a; 6 | scanf("%d %d", &a, &n); 7 | while (n--) { 8 | int x; 9 | scanf("%d", &x); 10 | if (a * x >= 40000000) resposta++; 11 | } 12 | printf("%d\n", resposta); 13 | return 0; 14 | } 15 | -------------------------------------------------------------------------------- /beecrowd/2388.cpp: -------------------------------------------------------------------------------- 1 | // Ivan Carvalho 2 | // Solution to https://www.beecrowd.com.br/judge/problems/view/2388 3 | #include 4 | int main() { 5 | int n, resposta = 0; 6 | scanf("%d", &n); 7 | while (n--) { 8 | int x, y; 9 | scanf("%d %d", &x, &y); 10 | resposta += x * y; 11 | } 12 | printf("%d\n", resposta); 13 | return 0; 14 | } 15 | -------------------------------------------------------------------------------- /beecrowd/2389.cpp: -------------------------------------------------------------------------------- 1 | // Ivan Carvalho 2 | // Solution to https://www.beecrowd.com.br/judge/problems/view/2389 3 | #include 4 | int resposta, k; 5 | int main() { 6 | scanf("%d", &k); 7 | for (int i = 2; 2 * i * i - 2 * i + 1 <= k; i++) { 8 | if ((k + i - 1) % (2 * i - 1) == 0) resposta++; 9 | } 10 | printf("%d\n", resposta); 11 | return 0; 12 | } 13 | -------------------------------------------------------------------------------- /beecrowd/2392.cpp: -------------------------------------------------------------------------------- 1 | // Ivan Carvalho 2 | // Solution to https://www.beecrowd.com.br/judge/problems/view/2392 3 | #include 4 | int vetor[10000], n, sapos; 5 | int main() { 6 | scanf("%d %d", &n, &sapos); 7 | for (int i = 0; i < sapos; i++) { 8 | int inicial, distancia; 9 | scanf("%d %d", &inicial, &distancia); 10 | for (int k = inicial; k > 0; k -= distancia) vetor[k] = 1; 11 | for (int k = inicial; k <= n; k += distancia) vetor[k] = 1; 12 | } 13 | for (int i = 1; i <= n; i++) printf("%d\n", vetor[i]); 14 | return 0; 15 | } 16 | -------------------------------------------------------------------------------- /beecrowd/2395.cpp: -------------------------------------------------------------------------------- 1 | // Ivan Carvalho 2 | // Solution to https://www.beecrowd.com.br/judge/problems/view/2395 3 | #include 4 | #include 5 | #include 6 | using namespace std; 7 | int a, b, c, x, y, z, resposta; 8 | int main() { 9 | scanf("%d %d %d", &a, &b, &c); 10 | scanf("%d %d %d", &x, &y, &z); 11 | printf("%d\n", (x / a) * (y / b) * (z / c)); 12 | return 0; 13 | } 14 | -------------------------------------------------------------------------------- /beecrowd/2399.cpp: -------------------------------------------------------------------------------- 1 | // Ivan Carvalho 2 | // Solution to https://www.beecrowd.com.br/judge/problems/view/2399 3 | #include 4 | int vetor[1010]; 5 | int main() { 6 | int n; 7 | scanf("%d", &n); 8 | for (int i = 1; i <= n; i++) { 9 | int x; 10 | scanf("%d", &x); 11 | if (x) { 12 | vetor[i - 1]++; 13 | vetor[i]++; 14 | vetor[i + 1]++; 15 | } 16 | } 17 | for (int i = 1; i <= n; i++) printf("%d\n", vetor[i]); 18 | return 0; 19 | } 20 | -------------------------------------------------------------------------------- /beecrowd/2402.cpp: -------------------------------------------------------------------------------- 1 | // Ivan Carvalho 2 | // Solution to https://www.beecrowd.com.br/judge/problems/view/2402 3 | #include 4 | typedef unsigned long long llu; 5 | int main() { 6 | llu n, i; 7 | scanf("%llu", &n); 8 | if (n % 2 == 0) { 9 | printf("S\n"); 10 | return 0; 11 | } 12 | for (i = 3LLU; i * i <= n; i += 2) 13 | if (!(n % i)) { 14 | printf("S\n"); 15 | return 0; 16 | } 17 | printf("N\n"); 18 | return 0; 19 | } 20 | -------------------------------------------------------------------------------- /beecrowd/2410.cpp: -------------------------------------------------------------------------------- 1 | // Ivan Carvalho 2 | // Solution to https://www.beecrowd.com.br/judge/problems/view/2410 3 | #include 4 | #include 5 | using namespace std; 6 | int main() { 7 | std::cout.sync_with_stdio(false); 8 | std::cin.sync_with_stdio(false); 9 | int casos, i, davez; 10 | set notas; 11 | cin >> casos; 12 | for (i = 0; i < casos; i++) { 13 | cin >> davez; 14 | notas.insert(davez); 15 | } 16 | cout << (int)notas.size() << endl; 17 | return 0; 18 | } 19 | -------------------------------------------------------------------------------- /beecrowd/2413.cpp: -------------------------------------------------------------------------------- 1 | // Ivan Carvalho 2 | // Solution to https://www.beecrowd.com.br/judge/problems/view/2413 3 | #include 4 | int main() { 5 | int a; 6 | scanf("%d", &a); 7 | printf("%d\n", 4 * a); 8 | return 0; 9 | } 10 | -------------------------------------------------------------------------------- /beecrowd/2414.cpp: -------------------------------------------------------------------------------- 1 | // Ivan Carvalho 2 | // Solution to https://www.beecrowd.com.br/judge/problems/view/2414 3 | #include 4 | int main() { 5 | int resp = 0; 6 | while (1) { 7 | int davez; 8 | scanf("%d", &davez); 9 | if (davez == 0) { 10 | break; 11 | } else if (davez > resp) { 12 | resp = davez; 13 | } 14 | } 15 | printf("%d\n", resp); 16 | return 0; 17 | } 18 | -------------------------------------------------------------------------------- /beecrowd/2416.cpp: -------------------------------------------------------------------------------- 1 | // Ivan Carvalho 2 | // Solution to https://www.beecrowd.com.br/judge/problems/view/2416 3 | #include 4 | int main() { 5 | int a, b; 6 | scanf("%d %d", &a, &b); 7 | printf("%d\n", a % b); 8 | return 0; 9 | } 10 | -------------------------------------------------------------------------------- /beecrowd/2417.cpp: -------------------------------------------------------------------------------- 1 | // Ivan Carvalho 2 | // Solution to https://www.beecrowd.com.br/judge/problems/view/2417 3 | #include 4 | int main() { 5 | int a, b, c, d, e, f; 6 | scanf("%d %d %d %d %d %d", &a, &b, &c, &d, &e, &f); 7 | if (a * 3 + b == d * 3 + e) { 8 | if (c == f) { 9 | printf("=\n"); 10 | } else if (c > f) { 11 | printf("C\n"); 12 | } else { 13 | printf("F\n"); 14 | } 15 | } else if (a * 3 + b > d * 3 + e) { 16 | printf("C\n"); 17 | } else { 18 | printf("F\n"); 19 | } 20 | return 0; 21 | } 22 | -------------------------------------------------------------------------------- /beecrowd/2418.cpp: -------------------------------------------------------------------------------- 1 | // Ivan Carvalho 2 | // Solution to https://www.beecrowd.com.br/judge/problems/view/2418 3 | #include 4 | #include 5 | using namespace std; 6 | int main() { 7 | int i; 8 | double notas[5]; 9 | for (i = 0; i < 5; i++) { 10 | scanf("%lf", ¬as[i]); 11 | } 12 | sort(notas, notas + 5); 13 | printf("%.1lf\n", notas[1] + notas[2] + notas[3]); 14 | return 0; 15 | } 16 | -------------------------------------------------------------------------------- /beecrowd/2420.cpp: -------------------------------------------------------------------------------- 1 | // Ivan Carvalho 2 | // Solution to https://www.beecrowd.com.br/judge/problems/view/2420 3 | #include 4 | int main() { 5 | int i, a, resp = 0; 6 | scanf("%d", &a); 7 | int vetor[a]; 8 | for (i = 0; i < a; i++) { 9 | int davez; 10 | scanf("%d", &davez); 11 | resp += davez; 12 | vetor[i] = resp; 13 | } 14 | for (i = 0; i < a; i++) { 15 | if (2 * vetor[i] == resp) { 16 | printf("%d\n", i + 1); 17 | return 0; 18 | } 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /beecrowd/2423.cpp: -------------------------------------------------------------------------------- 1 | // Ivan Carvalho 2 | // Solution to https://www.beecrowd.com.br/judge/problems/view/2423 3 | #include 4 | int main() { 5 | int a, b, c, a2, b2, c2; 6 | scanf("%d %d %d", &a, &b, &c); 7 | a2 = a / 2; 8 | b2 = b / 3; 9 | c2 = c / 5; 10 | if (a2 <= b2 && a2 <= c2) { 11 | printf("%d\n", a2); 12 | } else if (b2 <= c2 && b2 <= a2) { 13 | printf("%d\n", b2); 14 | } else { 15 | printf("%d\n", c2); 16 | } 17 | return 0; 18 | } 19 | -------------------------------------------------------------------------------- /beecrowd/2424.cpp: -------------------------------------------------------------------------------- 1 | // Ivan Carvalho 2 | // Solution to https://www.beecrowd.com.br/judge/problems/view/2424 3 | #include 4 | int main() { 5 | int a, b; 6 | scanf("%d %d", &a, &b); 7 | if (a >= 0 && b >= 0 && a <= 432 && b <= 468) { 8 | printf("dentro\n"); 9 | } else { 10 | printf("fora\n"); 11 | } 12 | return 0; 13 | } 14 | -------------------------------------------------------------------------------- /beecrowd/2428.cpp: -------------------------------------------------------------------------------- 1 | // Ivan Carvalho 2 | // Solution to https://www.beecrowd.com.br/judge/problems/view/2428 3 | #include 4 | int main() { 5 | double a, b, c, d; 6 | scanf("%lf %lf %lf %lf", &a, &b, &c, &d); 7 | if (a / b == c / d || a / b == d / c || a / c == b / d || a / c == d / b || 8 | a / d == b / c || a / d == c / b) 9 | printf("S\n"); 10 | else 11 | printf("N\n"); 12 | return 0; 13 | } 14 | -------------------------------------------------------------------------------- /beecrowd/2433.cpp: -------------------------------------------------------------------------------- 1 | // Ivan Carvalho 2 | // Solution to https://www.beecrowd.com.br/judge/problems/view/2433 3 | #include 4 | #include 5 | using namespace std; 6 | #define MAX 100010 7 | #define LIM 2147483647 8 | int vetor[MAX], n, k, i, resposta = LIM; 9 | int main() { 10 | scanf("%d %d", &n, &k); 11 | for (int i = 0; i < n; i++) scanf("%d", &vetor[i]); 12 | sort(vetor, vetor + n); 13 | for (int i = 0; i <= k; i++) 14 | if (vetor[i + (n - k) - 1] - vetor[i] < resposta) 15 | resposta = vetor[i + (n - k) - 1] - vetor[i]; 16 | printf("%d\n", resposta); 17 | return 0; 18 | } 19 | -------------------------------------------------------------------------------- /beecrowd/2434.cpp: -------------------------------------------------------------------------------- 1 | // Ivan Carvalho 2 | // Solution to https://www.beecrowd.com.br/judge/problems/view/2434 3 | #include 4 | int min(int x, int y) { 5 | if (x < y) return x; 6 | return y; 7 | } 8 | int main() { 9 | int n, atual, menor; 10 | scanf("%d %d", &n, &atual); 11 | menor = atual; 12 | while (n--) { 13 | int davez; 14 | scanf("%d", &davez); 15 | atual += davez; 16 | menor = min(atual, menor); 17 | } 18 | printf("%d\n", menor); 19 | return 0; 20 | } 21 | -------------------------------------------------------------------------------- /beecrowd/2435.cpp: -------------------------------------------------------------------------------- 1 | // Ivan Carvalho 2 | // Solution to https://www.beecrowd.com.br/judge/problems/view/2435 3 | #include 4 | int main() { 5 | int a, b, c, d, e, f; 6 | scanf("%d %d %d", &a, &b, &c); 7 | scanf("%d %d %d", &d, &e, &f); 8 | if (b / (c * 1.0) < (e / (f * 1.0))) 9 | printf("%d\n", a); 10 | else 11 | printf("%d\n", d); 12 | return 0; 13 | } 14 | -------------------------------------------------------------------------------- /beecrowd/2437.cpp: -------------------------------------------------------------------------------- 1 | // Ivan Carvalho 2 | // Solution to https://www.beecrowd.com.br/judge/problems/view/2437 3 | #include 4 | #include 5 | int main() { 6 | int x1, y1, x2, y2; 7 | scanf("%d %d %d %d", &x1, &y1, &x2, &y2); 8 | printf("%d\n", abs(x1 - x2) + abs(y1 - y2)); 9 | return 0; 10 | } 11 | -------------------------------------------------------------------------------- /beecrowd/2438.cpp: -------------------------------------------------------------------------------- 1 | // Ivan Carvalho 2 | // Solution to https://www.beecrowd.com.br/judge/problems/view/2438 3 | #include 4 | long long resposta; 5 | int n, vetor[1000001], sequencias[9], soma; 6 | int main() { 7 | scanf("%d", &n); 8 | sequencias[0] = 1; 9 | for (int i = 1; i <= n; i++) { 10 | int x; 11 | scanf("%d", &x); 12 | soma += x; 13 | resposta += sequencias[soma % 8]; 14 | sequencias[soma % 8]++; 15 | } 16 | printf("%lld\n", resposta); 17 | return 0; 18 | } 19 | -------------------------------------------------------------------------------- /beecrowd/2441.cpp: -------------------------------------------------------------------------------- 1 | // Ivan Carvalho 2 | // Solution to https://www.beecrowd.com.br/judge/problems/view/2441 3 | #include 4 | #define MAXN 601 5 | int vetor[MAXN]; 6 | int main() { 7 | int a, b, c; 8 | scanf("%d %d %d", &a, &b, &c); 9 | for (int i = 0; i < 200; i++) { 10 | vetor[a + i] = 1; 11 | vetor[b + i] = 1; 12 | vetor[c + i] = 1; 13 | } 14 | int resposta = 0; 15 | for (int i = 0; i < 600; i++) { 16 | if (vetor[i] == 0) resposta++; 17 | } 18 | printf("%d\n", resposta * 100); 19 | return 0; 20 | } 21 | -------------------------------------------------------------------------------- /beecrowd/2443.cpp: -------------------------------------------------------------------------------- 1 | // Ivan Carvalho 2 | // Solution to https://www.beecrowd.com.br/judge/problems/view/2443 3 | #include 4 | #include 5 | using namespace std; 6 | int gcd(int x, int y) { 7 | if (x < y) swap(x, y); 8 | if ((x % y) == 0) return y; 9 | return gcd(y, x % y); 10 | } 11 | int main() { 12 | int n1, d1, n2, d2; 13 | scanf("%d %d %d %d", &n1, &d1, &n2, &d2); 14 | int cima = n1 * d2 + n2 * d1; 15 | int debaixo = d1 * d2; 16 | int mdc = gcd(cima, debaixo); 17 | printf("%d %d\n", cima / mdc, debaixo / mdc); 18 | return 0; 19 | } 20 | -------------------------------------------------------------------------------- /beecrowd/2444.cpp: -------------------------------------------------------------------------------- 1 | // Ivan Carvalho 2 | // Solution to https://www.beecrowd.com.br/judge/problems/view/2444 3 | #include 4 | #include 5 | using namespace std; 6 | int main() { 7 | int v, t; 8 | scanf("%d %d", &v, &t); 9 | while (t--) { 10 | int a; 11 | scanf("%d", &a); 12 | v = min(100, max(v + a, 0)); 13 | } 14 | printf("%d\n", v); 15 | return 0; 16 | } 17 | -------------------------------------------------------------------------------- /beecrowd/2449.cpp: -------------------------------------------------------------------------------- 1 | // Ivan Carvalho 2 | // Solution to https://www.beecrowd.com.br/judge/problems/view/2449 3 | #include 4 | #include 5 | #include 6 | using namespace std; 7 | int main() { 8 | int n, tamanho, vetor[1010], resposta = 0; 9 | scanf("%d %d", &n, &tamanho); 10 | for (int i = 0; i < n; i++) scanf("%d", &vetor[i]); 11 | for (int i = 0; i < n; i++) { 12 | int diferenca = tamanho - vetor[i]; 13 | resposta += abs(diferenca); 14 | vetor[i + 1] += diferenca; 15 | } 16 | printf("%d\n", resposta); 17 | return 0; 18 | } 19 | -------------------------------------------------------------------------------- /beecrowd/2453.cpp: -------------------------------------------------------------------------------- 1 | // Ivan Carvalho 2 | // Solution to https://www.beecrowd.com.br/judge/problems/view/2453 3 | #include 4 | int main() { 5 | char davez; 6 | bool ep = false; 7 | while (scanf("%c", &davez) != EOF) { 8 | if (davez == ' ') { 9 | printf(" "); 10 | continue; 11 | } 12 | if (!ep) 13 | ep = true; 14 | else { 15 | ep = false; 16 | printf("%c", davez); 17 | } 18 | } 19 | printf("\n"); 20 | return 0; 21 | } 22 | -------------------------------------------------------------------------------- /beecrowd/2454.cpp: -------------------------------------------------------------------------------- 1 | // Ivan Carvalho 2 | // Solution to https://www.beecrowd.com.br/judge/problems/view/2454 3 | #include 4 | int main() { 5 | int p, r; 6 | scanf("%d %d", &p, &r); 7 | if (p == 1) { 8 | if (r == 0) 9 | printf("B\n"); 10 | else 11 | printf("A\n"); 12 | } else 13 | printf("C\n"); 14 | return 0; 15 | } 16 | -------------------------------------------------------------------------------- /beecrowd/2455.cpp: -------------------------------------------------------------------------------- 1 | // Ivan Carvalho 2 | // Solution to https://www.beecrowd.com.br/judge/problems/view/2455 3 | #include 4 | int main() { 5 | int a, b, c, d; 6 | scanf("%d %d %d %d", &a, &b, &c, &d); 7 | if (a * b == c * d) 8 | printf("0\n"); 9 | else if (a * b > c * d) 10 | printf("-1\n"); 11 | else 12 | printf("1\n"); 13 | return 0; 14 | } 15 | -------------------------------------------------------------------------------- /beecrowd/2456.cpp: -------------------------------------------------------------------------------- 1 | // Ivan Carvalho 2 | // Solution to https://www.beecrowd.com.br/judge/problems/view/2456 3 | #include 4 | int main() { 5 | int a, b, c, d, e; 6 | scanf("%d %d %d %d %d", &a, &b, &c, &d, &e); 7 | if (a >= b && b >= c && c >= d && d >= e) { 8 | printf("D\n"); 9 | } else if (a <= b && b <= c && c <= d && d <= e) { 10 | printf("C\n"); 11 | } else { 12 | printf("N\n"); 13 | } 14 | return 0; 15 | } 16 | -------------------------------------------------------------------------------- /beecrowd/2463.cpp: -------------------------------------------------------------------------------- 1 | // Ivan Carvalho 2 | // Solution to https://www.beecrowd.com.br/judge/problems/view/2463 3 | #include 4 | #include 5 | using namespace std; 6 | int main() { 7 | int n, m1 = 0, m2 = 0, d; 8 | scanf("%d", &n); 9 | while (n--) { 10 | scanf("%d", &d); 11 | m1 = max(0, m1 + d); 12 | m2 = max(m1, m2); 13 | } 14 | printf("%d\n", m2); 15 | return 0; 16 | } 17 | -------------------------------------------------------------------------------- /beecrowd/2464.cpp: -------------------------------------------------------------------------------- 1 | // Ivan Carvalho 2 | // Solution to https://www.beecrowd.com.br/judge/problems/view/2464 3 | #include 4 | #include 5 | char conv[1000], entrada[10100]; 6 | int main() { 7 | for (char c = 'a'; c <= 'z'; c++) { 8 | scanf("%c", &conv[c]); 9 | } 10 | scanf("%s", entrada); 11 | for (int i = 0; i < strlen(entrada); i++) { 12 | printf("%c", conv[entrada[i]]); 13 | } 14 | printf("\n"); 15 | return 0; 16 | } 17 | -------------------------------------------------------------------------------- /beecrowd/2472.cpp: -------------------------------------------------------------------------------- 1 | // Ivan Carvalho 2 | // Solution to https://www.beecrowd.com.br/judge/problems/view/2472 3 | #include 4 | typedef long long ll; 5 | int main() { 6 | ll a, b; 7 | scanf("%lld %lld", &a, &b); 8 | ll val = (a - b + 1) * (a - b + 1); 9 | val += b - 1; 10 | printf("%lld\n", val); 11 | return 0; 12 | } 13 | -------------------------------------------------------------------------------- /beecrowd/2482.py: -------------------------------------------------------------------------------- 1 | # Ivan Carvalho 2 | # Solution to https://www.beecrowd.com.br/judge/problems/view/2482 3 | #!/usr/bin/env python 4 | # -*- coding : utf-8 -*- 5 | linguas = int(input()) 6 | dicio = {} 7 | for i in range(linguas): 8 | lingua = input() 9 | mensagem = input() 10 | dicio[lingua] = mensagem 11 | nomes = int(input()) 12 | for i in range(nomes): 13 | nome = input() 14 | lingua = input() 15 | print(nome) 16 | print(dicio[lingua]) 17 | print("") 18 | -------------------------------------------------------------------------------- /beecrowd/2483.py: -------------------------------------------------------------------------------- 1 | # Ivan Carvalho 2 | # Solution to https://www.beecrowd.com.br/judge/problems/view/2483 3 | #!/usr/bin/env python 4 | # -*- coding : utf-8 -*- 5 | mensagem = "Feliz n*tal!" 6 | repeticoes = int(input()) 7 | print(mensagem.replace("a", "a" * repeticoes).replace("*", "a")) 8 | -------------------------------------------------------------------------------- /beecrowd/2514.cpp: -------------------------------------------------------------------------------- 1 | // Ivan Carvalho 2 | // Solution to https://www.beecrowd.com.br/judge/problems/view/2514 3 | #include 4 | #include 5 | using namespace std; 6 | int gcd(int a, int b) { 7 | if (a < b) swap(a, b); 8 | if (b == 0) return a; 9 | return gcd(b, a % b); 10 | } 11 | int mmc(int a, int b) { return a * (b / gcd(a, b)); } 12 | int mmc(int a, int b, int c) { return mmc(mmc(a, b), c); } 13 | int main() { 14 | int m, l1, l2, l3; 15 | while (scanf("%d", &m) != EOF) { 16 | scanf("%d %d %d", &l1, &l2, &l3); 17 | printf("%d\n", -m + mmc(l1, l2, l3)); 18 | } 19 | return 0; 20 | } 21 | -------------------------------------------------------------------------------- /beecrowd/2651.py: -------------------------------------------------------------------------------- 1 | # Ivan Carvalho 2 | # Solution to https://www.beecrowd.com.br/judge/problems/view/2651 3 | entrada = input() 4 | if "zelda" in entrada.lower(): 5 | print("Link Bolado") 6 | else: 7 | print("Link Tranquilo") 8 | -------------------------------------------------------------------------------- /beecrowd/2653.cpp: -------------------------------------------------------------------------------- 1 | // Ivan Carvalho 2 | // Solution to https://www.beecrowd.com.br/judge/problems/view/2653 3 | #include 4 | using namespace std; 5 | int main() { 6 | string s; 7 | set cjt; 8 | while (cin >> s) { 9 | cjt.insert(s); 10 | } 11 | cout << cjt.size() << endl; 12 | return 0; 13 | } 14 | -------------------------------------------------------------------------------- /beecrowd/2661.cpp: -------------------------------------------------------------------------------- 1 | // Ivan Carvalho 2 | // Solution to https://www.beecrowd.com.br/judge/problems/view/2661 3 | #include 4 | using namespace std; 5 | typedef long long ll; 6 | int main() { 7 | ll n; 8 | cin >> n; 9 | ll x = n; 10 | ll qtd = 0; 11 | for (ll i = 2; i * i <= n; i++) { 12 | if (x % i != 0) continue; 13 | while (x % i == 0) x /= i; 14 | qtd++; 15 | } 16 | if (x != 1) qtd++; 17 | ll resp = (1LL << qtd) - qtd - 1; 18 | cout << max(0LL, resp) << endl; 19 | return 0; 20 | } 21 | -------------------------------------------------------------------------------- /beecrowd/2663.cpp: -------------------------------------------------------------------------------- 1 | // Ivan Carvalho 2 | // Solution to https://www.beecrowd.com.br/judge/problems/view/2663 3 | #include 4 | using namespace std; 5 | int main() { 6 | vector entrada; 7 | int n, k; 8 | cin >> n >> k; 9 | while (n--) { 10 | int x; 11 | cin >> x; 12 | entrada.push_back(-x); 13 | } 14 | sort(entrada.begin(), entrada.end()); 15 | while (k < entrada.size() && entrada[k - 1] == entrada[k]) { 16 | k++; 17 | } 18 | cout << k << endl; 19 | return 0; 20 | } 21 | -------------------------------------------------------------------------------- /beecrowd/2667.cpp: -------------------------------------------------------------------------------- 1 | // Ivan Carvalho 2 | // Solution to https://www.beecrowd.com.br/judge/problems/view/2667 3 | #include 4 | using namespace std; 5 | int main() { 6 | int resp = 0; 7 | string s; 8 | cin >> s; 9 | for (int i = 0; i < s.size(); i++) resp += (s[i] - '0'); 10 | if (resp % 3 == 1) 11 | printf("1\n"); 12 | else if (resp % 3 == 2) 13 | printf("2\n"); 14 | else 15 | printf("0\n"); 16 | return 0; 17 | } 18 | -------------------------------------------------------------------------------- /beecrowd/2670.cpp: -------------------------------------------------------------------------------- 1 | // Ivan Carvalho 2 | // Solution to https://www.beecrowd.com.br/judge/problems/view/2670 3 | #include 4 | using namespace std; 5 | int main() { 6 | int a, b, c; 7 | cin >> a >> b >> c; 8 | int resp = 2 * a + b; 9 | resp = min(resp, a + c); 10 | resp = min(resp, b + 2 * c); 11 | cout << 2 * resp << endl; 12 | return 0; 13 | } 14 | -------------------------------------------------------------------------------- /beecrowd/2679.py: -------------------------------------------------------------------------------- 1 | # Ivan Carvalho 2 | # Solution to https://www.beecrowd.com.br/judge/problems/view/2679 3 | a = int(input()) 4 | if a % 2 == 0: 5 | print(a + 2) 6 | else: 7 | print(a + 1) 8 | -------------------------------------------------------------------------------- /beecrowd/2681.py: -------------------------------------------------------------------------------- 1 | # Ivan Carvalho 2 | # Solution to https://www.beecrowd.com.br/judge/problems/view/2681 3 | #!/usr/bin/env python 4 | # -*- coding : utf-8 -*- 5 | a = int(input()) 6 | resp = pow(2, a, 60 * 60 * 24) - 1 7 | resp %= 60 * 60 * 24 8 | a = resp / (60 * 60) 9 | resp %= 60 * 60 10 | b = resp / 60 11 | resp %= 60 12 | l1 = str(a) 13 | if len(l1) == 1: 14 | l1 = "0" + l1 15 | l2 = str(b) 16 | if len(l2) == 1: 17 | l2 = "0" + l2 18 | l3 = str(resp) 19 | if len(l3) == 1: 20 | l3 = "0" + l3 21 | print("%s:%s:%s" % (l1, l2, l3)) 22 | -------------------------------------------------------------------------------- /beecrowd/2702.py: -------------------------------------------------------------------------------- 1 | # Ivan Carvalho 2 | # Solution to https://www.beecrowd.com.br/judge/problems/view/2702 3 | #!/usr/bin/env python 4 | # -*- coding : utf-8 -*- 5 | a, b, c = [int(i) for i in input().split()] 6 | d, e, f = [int(i) for i in input().split()] 7 | print(max(-a + d, 0) + max(-b + e, 0) + max(-c + f, 0)) 8 | -------------------------------------------------------------------------------- /beecrowd/2779.py: -------------------------------------------------------------------------------- 1 | # Ivan Carvalho 2 | # Solution to https://www.beecrowd.com.br/judge/problems/view/2779 3 | # -*- coding : utf-8 -*- 4 | 5 | N = int(eval(input())) 6 | M = int(eval(input())) 7 | cjt = set() 8 | 9 | for i in range(M): 10 | x = int(eval(input())) 11 | cjt.add(x) 12 | 13 | print((N - len(cjt))) 14 | -------------------------------------------------------------------------------- /beecrowd/2780.py: -------------------------------------------------------------------------------- 1 | # Ivan Carvalho 2 | # Solution to https://www.beecrowd.com.br/judge/problems/view/2780 3 | # -*- coding : utf-8 -*- 4 | 5 | D = int(eval(input())) 6 | if D <= 800: 7 | print((1)) 8 | elif D <= 1400: 9 | print((2)) 10 | else: 11 | print((3)) 12 | -------------------------------------------------------------------------------- /beecrowd/2783.py: -------------------------------------------------------------------------------- 1 | # Ivan Carvalho 2 | # Solution to https://www.beecrowd.com.br/judge/problems/view/2783 3 | # -*- coding : utf-8 -*- 4 | 5 | N, C, M = [int(i) for i in input().split()] 6 | cjt1 = set([int(i) for i in input().split()]) 7 | cjt2 = set([int(i) for i in input().split()]) 8 | 9 | print((len(cjt1 - cjt2))) 10 | -------------------------------------------------------------------------------- /beecrowd/2786.py: -------------------------------------------------------------------------------- 1 | # Ivan Carvalho 2 | # Solution to https://www.beecrowd.com.br/judge/problems/view/2786 3 | # -*- coding : utf-8 -*- 4 | 5 | L = int(eval(input())) 6 | C = int(eval(input())) 7 | 8 | print((L * C + (L - 1) * (C - 1))) 9 | print(((L + C - 2) * 2)) 10 | -------------------------------------------------------------------------------- /beecrowd/2787.py: -------------------------------------------------------------------------------- 1 | # Ivan Carvalho 2 | # Solution to https://www.beecrowd.com.br/judge/problems/view/2787 3 | # -*- coding : utf-8 -*- 4 | 5 | L = int(eval(input())) 6 | C = int(eval(input())) 7 | 8 | print(((L + C + 1) % 2)) 9 | -------------------------------------------------------------------------------- /beecrowd/2879.cpp: -------------------------------------------------------------------------------- 1 | // Ivan Carvalho 2 | // Solution to https://www.beecrowd.com.br/judge/problems/view/2879 3 | #include 4 | using namespace std; 5 | 6 | int main() { 7 | int N; 8 | cin >> N; 9 | int ans = N; 10 | for (int i = 1; i <= N; i++) { 11 | int x; 12 | cin >> x; 13 | if (x == 1) ans--; 14 | } 15 | 16 | cout << ans << endl; 17 | 18 | return 0; 19 | } 20 | --------------------------------------------------------------------------------