├── .DS_Store ├── .gitignore ├── .vscode └── settings.json ├── 51Nod ├── 1000(A+B).cpp ├── 1005(大数加法).py ├── 1006(LCS+dp).cpp ├── 1008(模乘).cpp ├── 1011(GCD).cpp ├── 1012(LCM).cpp ├── 1018(排序).cpp ├── 1019(归并排序求逆序对).cpp ├── 1019(树状数组求逆序对).cpp ├── 1027(大数乘法).py ├── 1046(快速幂).cpp ├── 1049(最大子段和).cpp ├── 1057(大数阶乘).cpp ├── 1058(斯特林公式).cpp ├── 1066(Bash博弈).cpp ├── 1069(Nim博弈).cpp ├── 1072(威佐夫博弈).cpp ├── 1073(约瑟夫环)(循环节).cpp ├── 1079(中国剩余定理).cpp ├── 1081(前缀和).cpp ├── 1085(01背包).cpp ├── 1088(最长回文子串).cpp ├── 1089(manacher).cpp ├── 1106(质数筛).cpp ├── 1118(dp).cpp ├── 1130(斯特林公式).cpp ├── 1134(LIS)(dp).cpp ├── 1135(原根).cpp ├── 1136(欧拉函数).cpp ├── 1137(矩阵乘法).cpp ├── 1174(RMQ).cpp ├── 1174(水题).cpp ├── 1174(线段树).cpp ├── 1181(素数筛).cpp ├── 1183(编辑距离)(dp).cpp ├── 1185(威佐夫博弈+大数乘法模拟).cpp ├── 1212(最小生成树)(Kruskal).cpp ├── 1240(Mobius函数).cpp ├── 1242(斐波那契数列)(矩阵快速幂).cpp ├── 1256(乘法逆元)(exgcd).cpp ├── 1264(计算几何)(线段相交).cpp ├── 1265(计算几何)(四点共面).cpp ├── 1298(计算几何)(线段与圆的交点).cpp ├── 1384(全排列).cpp ├── 1459(最短路径)(Dij).cpp ├── 1459(最短路径)(spfa).cpp └── README.md ├── ACdream ├── 1000(A+B).cpp ├── 1001(大水题).cpp ├── 1003(DFS).cpp ├── 1006(数学推导).cpp ├── 1007(数学+快速幂).cpp ├── 1008(几何计数+数学推导).cpp ├── 1012(正弦定理).cpp ├── 1013(水题).cpp ├── 1014(dp)(PE240).cpp ├── 1017(网络流sap).cpp ├── 1019(树状数组+Hash).cpp ├── 1023(异或+数学).cpp ├── 1025(dp).cpp ├── 1029(前缀和+数学).cpp ├── 1038(模拟).cpp ├── 1044(脑洞题).cpp ├── 1055(离散化+树状数组).cpp ├── 1056(判断二分图)(BFS).cpp ├── 1056(判断二分图)(并查集).cpp ├── 1060(找循环节代码).cpp ├── 1060(矩阵快速幂+找循环节).cpp ├── 1061(坑人水题).cpp ├── 1062(递推推结论).cpp ├── 1063(字典树).cpp ├── 1064(数位dp).cpp ├── 1065(几何+数学).cpp ├── 1066 (数学).cpp ├── 1067(数学推导).cpp ├── 1068(水题).cpp ├── 1069 (水题).cpp ├── 1070(数学).cpp ├── 1071(数学计数+容斥原理).cpp ├── 1072(dp).cpp ├── 1073(贪心).cpp ├── 1075(广义斐波那契数列求循环节).cpp ├── 1076(dp+置换+康拓展开).cpp ├── 1077(数学)(LCM).cpp ├── 1079(dp).cpp ├── 1080(水题).cpp ├── 1081(组合数学).cpp ├── 1082(模拟+make_pair).cpp ├── 1083(博弈+有向无环图dp).cpp ├── 1084(数学)(阶乘K进制下0的个数).cpp ├── 1086(背包+dp).cpp ├── 1088(构造).cpp ├── 1089(二分).cpp ├── 1090(博弈).cpp ├── 1092(概率dp).cpp ├── 1093(矩阵快速幂+重载矩阵运算).cpp ├── 1094(几何+求外心).cpp ├── 1095(模拟).cpp ├── 1096(异或).cpp ├── 1097(计算几何+直线与线段相交).cpp ├── 1098(简单几何).cpp ├── 1099(nth_element).cpp ├── 1100(Flody+完全背包).cpp ├── 1100(SpFa+dp).cpp ├── 1101(线段树)(区间替换+区间查询LCIS).cpp ├── 1102(树形dp).cpp ├── 1102(树形dp)(背包dp).cpp ├── 1103(树链剖分+最小费用最大流).cpp ├── 1104(Splay+Hash+二分).cpp ├── 1105 (DFS).cpp ├── 1106 (计算几何).cpp ├── 1107(计算几何+确认抛物线).cpp ├── 1108(莫队算法).cpp ├── 1109(难题).cpp ├── 1110(dp+多重背包).cpp ├── 1111(水题).cpp ├── 1112(SG函数).cpp ├── 1113(概率dp).cpp ├── 1114(莫比乌斯反演).cpp ├── 1115(dfs打表).cpp ├── 1115(打表&数学推导).cpp ├── 1116(扩展KMP+矩阵快速幂).cpp └── README.md ├── AtCoder └── abc139 │ ├── .vscode │ └── settings.json │ ├── A - Tenki.cpp │ ├── B - Power Socket.cpp │ ├── C - Lower.cpp │ ├── D - ModSum.cpp │ ├── E - League.cpp │ ├── F - Engines.cpp │ └── main ├── BZOJ ├── 1000(A+B).cpp ├── 1001(对偶图求最小割).cpp ├── 1026(数位dp).cpp ├── 2301(莫比乌斯反演).cpp ├── 2820(莫比乌斯反演).cpp ├── 3209(数位dp).cpp ├── 3224(splay模板).cpp ├── 3944(杜教筛).cpp ├── BZOJ 1013 (高斯消元).cpp ├── BZOJ 3456(多项式求逆+NTT).cpp ├── BZOJ 4555(多项式求逆).cpp ├── BZOJ1061(对偶原则+单纯形).cpp ├── BZOJ3112(对偶原则+单纯形).cpp ├── BZOJ3265(1061加强版).cpp └── BZOJ3550(单纯形)(权限题).cpp ├── Codeforces ├── .vscode │ └── settings.json └── Math │ ├── 1225A.cpp │ ├── 1227A.cpp │ ├── 1227F1.cpp │ ├── 1227F2.cpp │ ├── 1242A.cpp │ ├── 1245A.cpp │ ├── 1253C.cpp │ ├── 1254B1.cpp │ ├── 1255A.cpp │ ├── 1256A.cpp │ ├── 1257A.cpp │ ├── 1257B.cpp │ ├── 1257G.cpp │ ├── 1260A.cpp │ ├── 1260B.cpp │ ├── 1260C.cpp │ ├── 1261F.cpp │ ├── 1263A.cpp │ ├── 1263C.cpp │ ├── 1265B.cpp │ ├── 1265E(期望dp).cpp │ ├── 1266A.cpp │ ├── 1266B.cpp │ ├── 1267G.cpp │ ├── 1267J.cpp │ ├── 1267K.cpp │ ├── 1269A.cpp │ ├── 1271A.cpp │ ├── 1271B.cpp │ ├── 1271E.cpp │ ├── 1272A.cpp │ ├── 1276C.cpp │ ├── 1277D.cpp │ ├── 1278B.cpp │ ├── 1280A(modnum).cpp │ ├── main │ └── run.sh ├── FZU ├── 1001(A+B).cpp ├── 1013(随机输出)(人品题).cpp ├── 2203(二分).cpp ├── 2229(水题).cpp ├── 2230(博弈).cpp └── 2252(贪心).cpp ├── HDUOJ ├── 1000(A+B).cpp ├── 1001(水题).cpp ├── 1002(大数加法).cpp ├── 1003(dp).cpp ├── 1004(字符串统计).cpp ├── 1005(dp).cpp ├── 1006(模拟).cpp ├── 1007.cpp ├── 1008(模拟).cpp ├── 1010.cpp ├── 1012(数学题).cpp ├── 1013(数值计算).cpp ├── 1014(GCD).cpp ├── 1015.cpp ├── 1016.cpp ├── 1017(暴力枚举).cpp ├── 1018.cpp ├── 1019(LCM).cpp ├── 1021(找规律).cpp ├── 1022.cpp ├── 1026.cpp ├── 1027.cpp ├── 1028(dp).cpp ├── 1029(水题).cpp ├── 1030.cpp ├── 1032(暴力).cpp ├── 1035.cpp ├── 1040(水题).cpp ├── 1048(字符串).cpp ├── 1051.cpp ├── 1056(数学题).cpp ├── 1058(打表+暴力).cpp ├── 1060(求最左位公式).cpp ├── 1061(快速幂).cpp ├── 1065.cpp ├── 1070(数学水题).cpp ├── 1071.cpp ├── 1072.cpp ├── 1075.cpp ├── 1076(数学题).cpp ├── 1089.cpp ├── 1090.cpp ├── 1091.cpp ├── 1092.cpp ├── 1093.cpp ├── 1094.cpp ├── 1095.cpp ├── 1096.cpp ├── 1097(快速幂).cpp ├── 1098(费马小定理).cpp ├── 1106.cpp ├── 1108.cpp ├── 1115.cpp ├── 1128.cpp ├── 1134(高精度卡特兰数).cpp ├── 1141.cpp ├── 1157.cpp ├── 1162.cpp ├── 1163.cpp ├── 1164.cpp ├── 1165.cpp ├── 1166 (线段树 单点增减求和).cpp ├── 1170.cpp ├── 1174(叉积).cpp ├── 1175.cpp ├── 1180.cpp ├── 1181.cpp ├── 1194.cpp ├── 1196.cpp ├── 1197.cpp ├── 1201.cpp ├── 1202.cpp ├── 1205.cpp ├── 1209.cpp ├── 1210.cpp ├── 1212.cpp ├── 1215.cpp ├── 1219(字母统计).cpp ├── 1220.cpp ├── 1222.cpp ├── 1228.cpp ├── 1229.cpp ├── 1230.cpp ├── 1233.cpp ├── 1234.cpp ├── 1235.cpp ├── 1236.cpp ├── 1237.cpp ├── 1238.cpp ├── 1239.cpp ├── 1240.cpp ├── 1241.cpp ├── 1242.cpp ├── 1248.cpp ├── 1253.cpp ├── 1254.cpp ├── 1259.cpp ├── 1266.cpp ├── 1276.cpp ├── 1279.cpp ├── 1282.cpp ├── 1283.cpp ├── 1286.cpp ├── 1302.cpp ├── 1303.cpp ├── 1312.cpp ├── 1323.cpp ├── 1326.cpp ├── 1330.cpp ├── 1334.cpp ├── 1335.cpp ├── 1337.cpp ├── 1339.cpp ├── 1342.cpp ├── 1370(中国剩余定理).cpp ├── 1372.cpp ├── 1390.cpp ├── 1391.cpp ├── 1393.cpp ├── 1394 (线段树)单点增减求和.cpp ├── 1394(树状数组).cpp ├── 1402(FFT模板题).cpp ├── 1405.cpp ├── 1406.cpp ├── 1407.cpp ├── 1408.cpp ├── 1412.cpp ├── 1418.cpp ├── 1420.cpp ├── 1465.cpp ├── 1491.cpp ├── 1492.cpp ├── 1500(dp).cpp ├── 1501(dfs).cpp ├── 1502(dp+手写大数).cpp ├── 1506.cpp ├── 1509(优先队列).cpp ├── 1511(dp+思维).cpp ├── 1512(左偏树).cpp ├── 1515(dfs).cpp ├── 1518(dfs).cpp ├── 1539(dfs).cpp ├── 1544(回文子串个数).cpp ├── 1548.cpp ├── 1555.cpp ├── 1556(树状数组)(区间更新+单点查询).cpp ├── 1557.cpp ├── 1562.cpp ├── 1563.cpp ├── 1576(欧几里得求逆元).cpp ├── 1576(费马小定理求逆元).cpp ├── 1577.cpp ├── 1587.cpp ├── 1593.cpp ├── 1597.cpp ├── 1671.cpp ├── 1673.cpp ├── 1677.cpp ├── 1678.cpp ├── 1695 (容斥原理).cpp ├── 1698 (线段树)成段替换.cpp ├── 1701.cpp ├── 1702.cpp ├── 1708.cpp ├── 1716.cpp ├── 1718.cpp ├── 1720.cpp ├── 1722.cpp ├── 1727.cpp ├── 1728.cpp ├── 1754(线段树) 单点替换求最值.cpp ├── 1785.cpp ├── 1798.cpp ├── 1799.cpp ├── 1800 (2).cpp ├── 1800.cpp ├── 1840.cpp ├── 1859.cpp ├── 1862.cpp ├── 1868.cpp ├── 1870.cpp ├── 1877.cpp ├── 1896.cpp ├── 1898.cpp ├── 1976.cpp ├── 1977.cpp ├── 1981.cpp ├── 1983.cpp ├── 1984.cpp ├── 1985.cpp ├── 1986.cpp ├── 1987.cpp ├── 1988.cpp ├── 1990.cpp ├── 1992 (2)(状压dp).cpp ├── 1992(dp).cpp ├── 1993.cpp ├── 1994.cpp ├── 1997(模拟)(汉诺塔).cpp ├── 1998(Merzirac奇数幻方生成法构造).cpp ├── 1999.cpp ├── 2000.cpp ├── 2001.cpp ├── 2002.cpp ├── 2003.cpp ├── 2004.cpp ├── 2005.cpp ├── 2006.cpp ├── 2007.cpp ├── 2008 .cpp ├── 2009.cpp ├── 2010.cpp ├── 2011.cpp ├── 2012.cpp ├── 2013.cpp ├── 2014.cpp ├── 2015.cpp ├── 2016.cpp ├── 2017.cpp ├── 2018.cpp ├── 2019.cpp ├── 2020.cpp ├── 2021.cpp ├── 2022.cpp ├── 2023.cpp ├── 2024.cpp ├── 2025.cpp ├── 2026.cpp ├── 2027.cpp ├── 2028.cpp ├── 2029.cpp ├── 2030.cpp ├── 2031.cpp ├── 2032.cpp ├── 2033.cpp ├── 2034.cpp ├── 2035.cpp ├── 2036.cpp ├── 2037.cpp ├── 2039.cpp ├── 2040.cpp ├── 2041.cpp ├── 2042.cpp ├── 2043.cpp ├── 2044.cpp ├── 2045.cpp ├── 2046.cpp ├── 2047.cpp ├── 2048.cpp ├── 2049.cpp ├── 2051.cpp ├── 2052.cpp ├── 2053.cpp ├── 2054.java ├── 2055.cpp ├── 2056.cpp ├── 2058.cpp ├── 2059.cpp ├── 2060.cpp ├── 2061.cpp ├── 2062.cpp ├── 2063(二分图匹配).cpp ├── 2064(汉诺塔).cpp ├── 2065.cpp ├── 2066.cpp ├── 2067.cpp ├── 2068.cpp ├── 2069.cpp ├── 2070.cpp ├── 2071.cpp ├── 2073.cpp ├── 2074.cpp ├── 2075.cpp ├── 2076.cpp ├── 2077(汉诺塔).cpp ├── 2078.cpp ├── 2079.cpp ├── 2080.cpp ├── 2081.cpp ├── 2082(普通母函数).cpp ├── 2082(母函数).cpp ├── 2083.cpp ├── 2084.cpp ├── 2085.cpp ├── 2086.cpp ├── 2087.cpp ├── 2088.cpp ├── 2089 (2).cpp ├── 2089(数位dp).cpp ├── 2090.cpp ├── 2091.cpp ├── 2092.cpp ├── 2093.cpp ├── 2094.cpp ├── 2095.cpp ├── 2096.cpp ├── 2097.cpp ├── 2098.cpp ├── 2099.cpp ├── 2101.cpp ├── 2102.cpp ├── 2103.cpp ├── 2104.cpp ├── 2105.cpp ├── 2106.cpp ├── 2107.cpp ├── 2108.cpp ├── 2109.cpp ├── 2113.cpp ├── 2114.cpp ├── 2115.cpp ├── 2116.cpp ├── 2117.cpp ├── 2123.cpp ├── 2131.cpp ├── 2132.cpp ├── 2133.cpp ├── 2134.cpp ├── 2135.cpp ├── 2136.cpp ├── 2137.cpp ├── 2138.cpp ├── 2139.cpp ├── 2141.cpp ├── 2143.cpp ├── 2148.cpp ├── 2153.cpp ├── 2156.cpp ├── 2161.cpp ├── 2162.cpp ├── 2164.cpp ├── 2175(汉诺塔).cpp ├── 2178.cpp ├── 2183(构造幻方).cpp ├── 2184(汉诺塔)(递归).cpp ├── 2186.cpp ├── 2192.cpp ├── 2197(数学+容斥).cpp ├── 2200.cpp ├── 2201.cpp ├── 2212.cpp ├── 2303(素数筛选+同余定理).cpp ├── 2304.cpp ├── 2309.cpp ├── 2317.cpp ├── 2368(水题).cpp ├── 2370(模拟).cpp ├── 2374(模拟).cpp ├── 2393.cpp ├── 2401.cpp ├── 2438.cpp ├── 2500.cpp ├── 2502.cpp ├── 2503.cpp ├── 2504.cpp ├── 2511(汉诺塔).cpp ├── 2519.cpp ├── 2520.cpp ├── 2521.cpp ├── 2522(分数循环节).cpp ├── 2523.cpp ├── 2524.cpp ├── 2527(哈夫曼树).cpp ├── 2529.cpp ├── 2535.cpp ├── 2537.cpp ├── 2539.cpp ├── 2544(经典最短路).cpp ├── 2547.cpp ├── 2548.cpp ├── 2549.cpp ├── 2550.cpp ├── 2551.cpp ├── 2552.cpp ├── 2553.cpp ├── 2554.cpp ├── 2555.cpp ├── 2560.cpp ├── 2561.cpp ├── 2562.cpp ├── 2563.cpp ├── 2566.cpp ├── 2567.cpp ├── 2568.cpp ├── 2600(贪心).cpp ├── 2601.cpp ├── 2603.cpp ├── 2605(贪食蛇)(搜索难题)(好题).cpp ├── 2612.cpp ├── 2614.cpp ├── 2615(贪心).cpp ├── 2665(主席树).cpp ├── 2700.cpp ├── 2701.cpp ├── 2703(dp).cpp ├── 2710.cpp ├── 2711(线段树)(求区间第K大).cpp ├── 2714(模拟).cpp ├── 2715(暴力).cpp ├── 2717.cpp ├── 2725(模拟).cpp ├── 2795 (线段树)区间查询最大值.cpp ├── 2993(斜率优化+fread).cpp ├── 3555(数位dp).cpp ├── 3652.cpp ├── 3652(数位DP).cpp ├── 4003 (2).cpp ├── 4003(树形dp).cpp ├── 4007(暴力枚举).cpp ├── 4093(FFT+容斥原理).cpp ├── 4152.cpp ├── 4609(FFT).cpp ├── 4820(线段树).cpp ├── 5452(在线LCA).cpp ├── 5462(半平面交).cpp ├── 5628(Dirichlet卷积)(狄利克雷卷积).cpp ├── 5690.cpp ├── 5694.cpp ├── 5695.cpp ├── 5718.cpp ├── 5719.cpp ├── 5720.cpp ├── 5721.cpp ├── 5722.cpp ├── 5723(最小生成树+期望).cpp ├── 5724.cpp ├── 5725.cpp ├── 5726.cpp ├── 5727.cpp ├── 5728.cpp ├── 5729.cpp ├── 5733.cpp ├── 5747.cpp ├── 5748.cpp ├── 5749 .cpp ├── 5750.cpp ├── 5751 (2).cpp ├── 5751(FFT+线段树).cpp ├── 5776.cpp ├── 5777.cpp ├── 5778.cpp ├── 5779.cpp ├── 5780.cpp ├── 5781.cpp ├── 5782(....).cpp ├── 5783.cpp ├── 5784 (2).cpp ├── 5784.cpp ├── 5785.cpp ├── 5791.cpp ├── 5793.cpp ├── 5794.cpp ├── 5795.cpp ├── 5798(....).cpp ├── 5799.cpp ├── 5804.cpp ├── 5805.cpp ├── 5806.cpp ├── 5807(3维).cpp ├── 5808.cpp ├── 5816(状压dp).cpp ├── 5829(NTT).cpp ├── 5833(高斯消元).cpp ├── 5898(数位dp).cpp ├── 5901(Lehmer素数计数).cpp ├── 5902.cpp ├── 5907.cpp ├── 5908.cpp ├── 5909(树形dp+FWT).cpp ├── 5976.cpp ├── 6202(魔方大模拟).cpp ├── README.md └── 操作格子(线段树)(单点修改,区间求最值,区间求和).cpp ├── LICENSE ├── LibreOJ ├── 1.zip ├── 100(矩阵乘法).cpp ├── 101(dinic).cpp ├── 102(最小费用最大流).cpp ├── 103(KMP).cpp ├── 104(Splay).cpp ├── 104(pb_ds).cpp ├── 105(Splay).cpp ├── 105(rope)(区间翻转).cpp ├── 106(Splay)(104基础上加区间).cpp ├── 106(线段树套Splay).cpp ├── 108(FFT).cpp ├── 108(NTT).cpp ├── 109(并查集).cpp ├── 110(exgcd求逆元).cpp ├── 110(乘法逆元)(奇葩快速幂).cpp ├── 118(正则表达式).cpp ├── 119(Spfa).cpp ├── 1(A+B).cpp ├── 2000(莫比乌斯反演).cpp ├── 2002(容斥+dp+矩阵快速幂).cpp ├── 2(水).cpp ├── 3(水).cpp ├── 4(脑洞题).py ├── 5.zip ├── 6.cpp ├── 6.zip ├── 6083(数学).cpp ├── 6084(dfs).cpp ├── 6085(模拟).cpp ├── 6086(数学题).cpp ├── 6090(构造).cpp ├── 6091(构造).cpp ├── 6092(构造).cpp ├── 6093_spj.cpp ├── 6093(贪心).cpp ├── 6094(DP)(好题).cpp ├── 6159(树形dp).cpp ├── 6160(组合数学+递推).cpp ├── 6161(二分).cpp ├── 6162(期望与概率).cpp ├── 6163(区间dp).cpp ├── 6164(莫队算法).cpp ├── 6165(线性筛).cpp ├── 6175(树形dp+贪心).cpp ├── 6176(数学题)(难).cpp ├── 6177(状压dp).cpp ├── 6217(背包dp).cpp ├── 6220(数学).cpp ├── 6229(杜教筛+Moebius).cpp ├── 6242(拉马努金阶乘近似).py └── README.md ├── README.md ├── Retired_code ├── CDQ Divide and Conquer │ ├── 51NOD 1376 (LIS)(二维偏序).cpp │ ├── BZOJ 1176(二维偏序).cpp │ ├── BZOJ 1935 (强行cdq分治) (二维偏序).cpp │ ├── BZOJ 3295(动态逆序对).cpp │ ├── HDU 4742(三维偏序).cpp │ ├── HDU 5126(三维偏序).cpp │ ├── HDU 5618(三维偏序).cpp │ ├── bzoj 3262(三维偏序).cpp │ └── luogu P3374 (强行cdq分治).cpp ├── Guass │ ├── BZOJ 1013 (高斯消元).cpp │ └── 洛谷 P3389(高斯消元).cpp ├── Number-theory │ ├── BZOJ 1467 (EXBSGS).cpp │ ├── BZOJ 2242(BSGS).cpp │ └── HDU 2815 (EXBSGS).cpp ├── Polynomial │ ├── BZOJ 3456(多项式求逆+NTT).cpp │ ├── BZOJ 4555(多项式求逆).cpp │ ├── 洛谷 P4238(多项式求逆).cpp │ └── 洛谷 P4245(任意模数NTT) .cpp ├── README.md ├── Simplex │ ├── BZOJ1061(对偶原则+单纯形).cpp │ ├── BZOJ3112(对偶原则+单纯形).cpp │ ├── BZOJ3265(1061加强版).cpp │ ├── BZOJ3550(单纯形)(权限题).cpp │ ├── POJ1275.cpp │ ├── README.md │ ├── Simplex Algorithm.pdf │ └── UOJ#179. 线性规划(模板题).cpp └── String │ ├── BZOJ 1009 (AC自动机+矩阵乘法优化dp).cpp │ ├── BZOJ 1030(AC自动机+dp).cpp │ ├── BZOJ 3172(AC自动机).cpp │ ├── 洛谷 P2292(AC自动机+dp).cpp │ ├── 洛谷 P2444 (AC自动机).cpp │ ├── 洛谷 P3796 (AC自动机).cpp │ └── 洛谷 P3808 (AC自动机).cpp ├── Xiangtan Invitation Contest 2017 ├── 1260(A)(高斯消元).cpp ├── 1261(B)(Kruskal+全局最小割).cpp ├── 1261(B)(全局最小割).cpp ├── 1262(C)(异或方程组高斯消元).cpp ├── 1263(D)(签到题).cpp ├── 1264(E)(脑洞题).cpp ├── 1265(F)(离散化+变形LCS).cpp ├── 1266(G)(贪心).cpp ├── 1267(H)(树上dfs)(树的直径).cpp ├── 1268(I)(数学).cpp ├── 1269(J)(树状数组+dp).cpp ├── xiangtan-2017-solution.pdf ├── xiangtan-2017.pdf └── 交题网址.txt ├── hihocoder ├── 1000(A+B).CPP ├── 1014(tire树).CPP ├── 1015(KMP).cpp ├── 1032(manacher).cpp ├── 1033(数位dp).cpp ├── 1034(离线平衡树).cpp ├── 1035(树形dp).cpp ├── 1036(tire树).cpp ├── 1037(dp).cpp ├── 1038(dp).cpp ├── 1039(字符串).cpp ├── 1040(计算几何).cpp ├── 1041(树上dfs).cpp ├── 1042(枚举).cpp ├── 1043(dp).cpp ├── 1044(状压dp).cpp └── README.md ├── jisuanke ├── 2018Game5 │ ├── A.cpp │ ├── B.cpp │ └── C.cpp └── 2020计蒜之道第一场 │ ├── A.cpp │ └── B.cpp └── 百度之星 ├── 2018 └── 2018-A-Round │ ├── A.cpp │ ├── B.cpp │ └── C.cpp ├── 2019 ├── 1001.cpp ├── 1002.cpp ├── 1003.cpp ├── 1005.cpp └── in.txt ├── 2020 ├── 复赛 │ ├── A.cpp │ ├── B.cpp │ └── C.cpp ├── 第一场 │ ├── A.cpp │ ├── B.cpp │ ├── C.cpp │ ├── D.cpp │ ├── E.cpp │ └── H.cpp └── 第三场 │ ├── A.cpp │ ├── B.cpp │ ├── C.cpp │ ├── D.cpp │ ├── E.cpp │ ├── F.cpp │ └── G.cpp ├── .DS_Store ├── 2016 Astar Contest - Round 2A ├── 1001-All X.cpp ├── 1002-Sitting in Line.cpp ├── 1003-Snacks.cpp ├── 1004-D Game.cpp ├── 1005-BD String.cpp └── 1006-Gym Class.cpp ├── 2016 Astar Contest - Round 2B ├── 1001-区间的价值.cpp ├── 1002-刷题计划.cpp ├── 1003-瞬间移动.cpp ├── 1004-货物运输.cpp ├── 1005-区间交.cpp └── 1006-中位数计数.cpp ├── 2016复赛 ├── 1001.cpp ├── 1002.cpp ├── 1003.cpp ├── 1004.cpp ├── 1005.cpp └── 1006.cpp ├── 百度之星2016-资格赛 ├── A.cpp ├── B.cpp ├── C.cpp └── D.cpp └── 百度之星2017-资格赛 ├── 02(fib堆优化+SW).cpp ├── 02(pairing堆优化+SW).cpp ├── 02(pb_ds).cpp ├── 02(并查集).cpp ├── 03(背包dp).cpp ├── 04(dp).cpp ├── 05(打表+组合数).cpp └── 1(Floyd求最小环).cpp /.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lzyrapx/Competitive-Programming/6b0eea727f9a6444700a6966209397ac7011226f/.DS_Store -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Compiled Object files 2 | *.slo 3 | *.lo 4 | *.o 5 | *.obj 6 | 7 | # Precompiled Headers 8 | *.gch 9 | *.pch 10 | 11 | # Compiled Dynamic libraries 12 | *.so 13 | *.dylib 14 | *.dll 15 | 16 | # Fortran module files 17 | *.mod 18 | *.smod 19 | 20 | # Compiled Static libraries 21 | *.lai 22 | *.la 23 | *.a 24 | *.lib 25 | 26 | # Executables 27 | *.exe 28 | *.out 29 | *.app 30 | .DS_Store 31 | .vscode/ 32 | .ipynb_checkpoints/ 33 | -------------------------------------------------------------------------------- /.vscode/settings.json: -------------------------------------------------------------------------------- 1 | { 2 | "files.associations": { 3 | "ostream": "cpp", 4 | "__bit_reference": "cpp", 5 | "__hash_table": "cpp", 6 | "__split_buffer": "cpp", 7 | "__tree": "cpp", 8 | "array": "cpp", 9 | "deque": "cpp", 10 | "initializer_list": "cpp", 11 | "iterator": "cpp", 12 | "list": "cpp", 13 | "map": "cpp", 14 | "set": "cpp", 15 | "string": "cpp", 16 | "string_view": "cpp", 17 | "unordered_map": "cpp", 18 | "vector": "cpp", 19 | "bitset": "cpp", 20 | "queue": "cpp", 21 | "stack": "cpp", 22 | "utility": "cpp", 23 | "tuple": "cpp", 24 | "iosfwd": "cpp", 25 | "__locale": "cpp", 26 | "ios": "cpp" 27 | } 28 | } -------------------------------------------------------------------------------- /51Nod/1000(A+B).cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | int main() 5 | { 6 | int a,b; 7 | while(cin >> a >> b) 8 | { 9 | cout << a + b << endl; 10 | } 11 | return 0; 12 | } -------------------------------------------------------------------------------- /51Nod/1005(大数加法).py: -------------------------------------------------------------------------------- 1 | a = int(input()) 2 | b = int(input()) 3 | print(a + b) 4 | -------------------------------------------------------------------------------- /51Nod/1008(模乘).cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | int main() 5 | { 6 | int n,p; 7 | scanf("%d%d",&n,&p); 8 | long long ans=1; 9 | for(int i=2;i<=n;i++){ 10 | ans=ans*i%p; 11 | } 12 | printf("%lld\n",ans); 13 | return 0; 14 | } -------------------------------------------------------------------------------- /51Nod/1011(GCD).cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | int main() 5 | { 6 | int a,b; 7 | cin>>a>>b; 8 | cout<<(__gcd(a,b))< 2 | using namespace std; 3 | 4 | int main() 5 | { 6 | long long a,b; 7 | cin>>a>>b; 8 | cout<<(a/(__gcd(a,b))*b)< 2 | using namespace std; 3 | const int maxn = 50000+10; 4 | int n, a[maxn]; 5 | int main() 6 | { 7 | scanf("%d", &n); 8 | for(int i = 0; i < n; i++) 9 | scanf("%d", a + i); 10 | sort(a, a + n); 11 | for(int i = 0; i < n; i++) 12 | printf("%d\n", a[i]); 13 | return 0; 14 | } 15 | -------------------------------------------------------------------------------- /51Nod/1027(大数乘法).py: -------------------------------------------------------------------------------- 1 | a = int(input()) 2 | 3 | b = int(input()) 4 | 5 | print(a * b) -------------------------------------------------------------------------------- /51Nod/1046(快速幂).cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | typedef long long LL; 4 | int q_mod(LL a,LL b,LL c) //a^c mod c 5 | { 6 | LL ans=1; 7 | 8 | while(b>0){ 9 | if(b&1) 10 | ans=(ans*a)%c; 11 | 12 | b>>=1; 13 | a=(a*a)%c; 14 | } 15 | return ans; 16 | } 17 | int main() 18 | { 19 | LL a,b,p; 20 | cin>>a>>b>>p; 21 | cout< 2 | using namespace std; 3 | typedef long long ll; 4 | ll now; 5 | ll n; 6 | ll ans=-9999999999; 7 | ll x; 8 | int main() 9 | { 10 | cin>>n; 11 | for(int i=1;i<=n;i++) 12 | { 13 | if(now<0){ 14 | now=0; 15 | } 16 | cin>>x; 17 | now+=x; 18 | if(now>ans) 19 | { 20 | ans=now; 21 | } 22 | } 23 | cout< 2 | int a[9999]={1,0}; 3 | int n,i,c,len,j; 4 | int main() 5 | { 6 | scanf("%d", &n); 7 | for ( len=1,j=2;j<=n; ++j) 8 | { 9 | for (c=0,i=0; i0)++len; 15 | } 16 | printf("%d",a[--len]); 17 | for(;len;) 18 | printf("%05d", a[--len]); 19 | return 0; 20 | } -------------------------------------------------------------------------------- /51Nod/1058(斯特林公式).cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | const double Pi=3.1415926; 4 | //斯特林公式:n!=sqrt(2*PI*n)*(n/e)^n 5 | int main() 6 | { 7 | int n; 8 | cin>>n; 9 | cout<<(int)((0.5*log(2*Pi*n)+n*log(n)-n)/log(10))+1< 2 | using namespace std; 3 | const double Pi=3.1415926; 4 | 5 | int main() 6 | { 7 | int t; 8 | cin>>t; 9 | while(t--) 10 | { 11 | int n,k; 12 | cin>>n>>k; 13 | if(n%(k+1))puts("A"); 14 | else puts("B"); 15 | } 16 | return 0; 17 | } -------------------------------------------------------------------------------- /51Nod/1069(Nim博弈).cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | const double Pi=3.1415926; 4 | 5 | int main() 6 | { 7 | int t; 8 | cin>>t; 9 | int ans=0; 10 | while(t--) 11 | { 12 | int n,k; 13 | cin>>n; 14 | ans^=n; 15 | } 16 | if(ans)puts("A"); 17 | else puts("B"); 18 | return 0; 19 | } -------------------------------------------------------------------------------- /51Nod/1072(威佐夫博弈).cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | int t, a, b; 4 | int main() 5 | { 6 | cin>>t; 7 | while(t--) 8 | { 9 | cin>>a>>b; 10 | if(a>b)swap(a,b); 11 | int k=(int)(b - a) * (1 + sqrt(5)) * 0.5; 12 | if(a==k)puts("B"); 13 | else puts("A"); 14 | } 15 | return 0; 16 | } 17 | -------------------------------------------------------------------------------- /51Nod/1073(约瑟夫环)(循环节).cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | typedef long long ll; 4 | int main() 5 | { 6 | int n,k; 7 | int ans = 0; 8 | cin>>n>>k; 9 | for(int i=2;i<=n;i++) 10 | { 11 | ans=(ans+k)%i; 12 | } 13 | cout< 2 | using namespace std; 3 | typedef long long ll; 4 | ll a[50005]; 5 | ll sum[50005]; 6 | int main() 7 | { 8 | int n; 9 | cin>>n; 10 | for(int i=1;i<=n;i++) 11 | { 12 | cin>>a[i]; 13 | sum[i]=sum[i-1]+a[i]; 14 | } 15 | int q; 16 | cin>>q; 17 | while(q--) 18 | { 19 | int x,y; 20 | cin>>x>>y; 21 | cout< 2 | using namespace std; 3 | int dp[123][12345]; 4 | int w[123]; 5 | int v[123]; 6 | int main() 7 | { 8 | int n,V; 9 | cin>>n>>V; 10 | for(int i=1;i<=n;i++) 11 | { 12 | cin>>w[i]>>v[i]; 13 | } 14 | for(int i=1;i<=n;i++) 15 | { 16 | for(int j=0;j<=V;j++) 17 | { 18 | if(j>=w[i]) 19 | { 20 | dp[i][j]=max(dp[i-1][j],dp[i-1][j-w[i]]+v[i]); 21 | } 22 | else 23 | { 24 | dp[i][j]=dp[i-1][j]; 25 | } 26 | } 27 | } 28 | cout< 2 | using namespace std; 3 | const int N=1234; 4 | 5 | bool check(int n) 6 | { 7 | if(n<=1)return false; 8 | if(n<=3)return true; 9 | if(n%2==0)return false; 10 | for(int i=3;i*i<=n;i++) 11 | { 12 | if(n%i==0)return false; 13 | } 14 | return true; 15 | } 16 | int main() 17 | { 18 | int t; 19 | cin>>t; 20 | while(t--) 21 | { 22 | int n; 23 | cin>>n; 24 | if(check(n)){ 25 | puts("Yes"); 26 | } 27 | else puts("No"); 28 | } 29 | return 0; 30 | } -------------------------------------------------------------------------------- /51Nod/1118(dp).cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | long long dp[1001][1001]; 4 | int main() 5 | { 6 | int n,m; 7 | cin>>n>>m; 8 | dp[1][0]=1; 9 | for(int i=1;i<=n;i++) 10 | { 11 | for(int j=1;j<=m;j++) 12 | { 13 | dp[i][j]=(dp[i-1][j]+dp[i][j-1])%1000000007; 14 | } 15 | } 16 | cout< 2 | using namespace std; 3 | const double Pi=3.1415926; 4 | //斯特林公式:n!=sqrt(2*PI*n)*(n/e)^n 5 | int main() 6 | { 7 | int n; 8 | int t; 9 | cin>>t; 10 | while(t--) 11 | { 12 | cin>>n; 13 | cout<<(long long)((0.5*log(2*Pi*n)+n*log(n)-n)/log(10))+1< 2 | using namespace std; 3 | int dp[123456];//dp[i]表示长度为i的上升子序列的最小结尾 4 | int a[123456]; 5 | int main() 6 | { 7 | int n,len=1; 8 | cin>>n; 9 | for(int i=1;i<=n;i++)cin>>a[i]; 10 | dp[1]=a[1]; 11 | for(int i=2;i<=n;i++){ 12 | if(a[i]>dp[len]) dp[++len]=a[i]; 13 | else{ 14 | int pos=lower_bound(dp+1,dp+len,a[i])-dp; 15 | dp[pos]=a[i]; 16 | 17 | } 18 | } 19 | cout< 2 | using namespace std; 3 | //求n的欧拉数,单个欧拉函数 4 | int euler(int n) 5 | { 6 | int ret=1,i; 7 | for (i=2;i*i<=n;i++) 8 | if (n%i==0) 9 | { 10 | n/=i,ret*=i-1; 11 | while (n%i==0) 12 | n/=i,ret*=i; 13 | } 14 | if (n>1) 15 | ret*=n-1; 16 | return ret; //n的欧拉数 17 | } 18 | int main() 19 | { 20 | int n; 21 | cin>>n; 22 | cout< 2 | using namespace std; 3 | int a[12345]; 4 | int main() 5 | { 6 | int n; 7 | cin>>n; 8 | for(int i=0;i>a[i]; 9 | int m; 10 | cin>>m; 11 | while(m--) 12 | { 13 | int l,r; int ans =0; 14 | cin>>l>>r; 15 | for(int i=l;i<=r;i++)ans=max(ans,a[i]); 16 | cout< 2 | using namespace std; 3 | const int maxn=1e7+1000; 4 | int prime[maxn],num[maxn],k; 5 | 6 | void init(int n) 7 | { 8 | n=n+1000; 9 | int i,j; 10 | prime[0]=prime[1]=1; 11 | for(i=2;i<=n;i++) 12 | { 13 | if(!prime[i]) 14 | { 15 | for(j=2*i;j<=n;j+=i) 16 | prime[j]=1; //不是素数 17 | } 18 | } 19 | j=0,k=0; 20 | for(i=2;i<=n;i++) 21 | { 22 | if(!prime[i])//是素数 23 | { 24 | j++; 25 | if(prime[j]==0) num[k++]=i; 26 | } 27 | } 28 | } 29 | 30 | int main() 31 | { 32 | ios::sync_with_stdio(false); 33 | int n; 34 | cin>>n; 35 | init(n); 36 | cout<<*lower_bound(num,num+k,n)< 2 | using namespace std; 3 | int dp[1234][1234]; 4 | int main() 5 | { 6 | string s,t; 7 | cin>>s>>t; 8 | int lena=s.length(); 9 | int lenb=t.length(); 10 | for(int i=0;i<=lena;i++) 11 | { 12 | dp[0][i] = i; 13 | } 14 | for(int i=0;i<=lenb;i++) 15 | { 16 | dp[i][0]=i; 17 | } 18 | for(int i=1;i<=lena;i++) 19 | { 20 | for(int j=1;j<=lenb;j++) 21 | { 22 | if(s[i-1]==t[j-1]) 23 | { 24 | dp[i][j]=dp[i-1][j-1]; 25 | } 26 | else 27 | { 28 | dp[i][j]=min( min(dp[i-1][j],dp[i][j-1]),dp[i-1][j-1] )+1; 29 | } 30 | } 31 | } 32 | cout< 2 | using namespace std; 3 | typedef long long ll; 4 | ll Mobius(ll n) 5 | { 6 | ll m = 1; 7 | for(ll i = 2; i * i <= n; i++) 8 | { 9 | if(n % i == 0) 10 | { 11 | m *= -1; 12 | ll k = 0; 13 | do 14 | { 15 | k++; 16 | if(k > 1) { m = 0; break;} 17 | n /= i; 18 | }while ( n % i == 0); 19 | } 20 | } 21 | if(n > 1) m *= -1; 22 | return m; 23 | } 24 | 25 | int main() 26 | { 27 | ll n; 28 | while(cin >> n) 29 | { 30 | cout< 2 | using namespace std; 3 | int exgcd(int a,int b,int &x,int &y) 4 | { 5 | if(b==0) 6 | { 7 | x=1; 8 | y=0; 9 | return a; 10 | } 11 | int res=exgcd(b,a%b,x,y); 12 | int t=x;x=y;y=t-(a/b)*y; 13 | return res; 14 | } 15 | int main() 16 | { 17 | int n,m; 18 | int x,y; 19 | cin>>m>>n; 20 | exgcd(m,n,x,y); 21 | while(x<0){ 22 | x+=n; 23 | } 24 | cout< 2 | using namespace std; 3 | int main() 4 | { 5 | char s[10]; 6 | scanf("%s", s); 7 | int length = strlen(s); 8 | sort(s, s + length); 9 | do 10 | { 11 | printf("%s\n", s); 12 | }while(next_permutation(s, s+length)); 13 | return 0; 14 | } -------------------------------------------------------------------------------- /51Nod/README.md: -------------------------------------------------------------------------------- 1 | # TODO 2 | -------------------------------------------------------------------------------- /ACdream/1000(A+B).cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | int main() 5 | { 6 | int a,b; 7 | while(cin>>a>>b) 8 | { 9 | cout< 2 | using namespace std; 3 | void SwapInt(int *a,int *b) 4 | { 5 | int t=*a; 6 | *a=*b; 7 | *b=t; 8 | } 9 | int main() 10 | { 11 | int a = 3,b = 5; 12 | SwapInt(&a,&b); 13 | cout< 12 | using namespace std; 13 | 14 | int main() 15 | { 16 | int t; 17 | cin>>t; 18 | while(t--) 19 | { 20 | double A,B; 21 | cin>>A>>B; 22 | if(A>B) 23 | { 24 | printf("%.5lf\n",A - 1 + log2( pow(2.0,B - A) + 1 )); 25 | } 26 | else 27 | { 28 | printf("%.5lf\n",B - 1 + log2( pow(2.0,A - B) + 1 )); 29 | } 30 | } 31 | return 0; 32 | } -------------------------------------------------------------------------------- /ACdream/1012(正弦定理).cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * this code is made by LzyRapx 3 | * Problem: 1012 4 | * Verdict: Accepted 5 | * Submission Date: 2017-06-05 13:27:35 6 | * Time: 0MS 7 | * Memory: 1776KB 8 | */ 9 | #include 10 | using namespace std; 11 | #define PI acos(-1.0) 12 | int main() 13 | { 14 | double d,angle; 15 | int n; 16 | while(cin>>n>>d) 17 | { 18 | double sum = 0; 19 | for ( int i = 0; i < n; i++) 20 | { 21 | cin>>angle; 22 | sum += 0.5*d*d*sin(angle*PI/180.0); 23 | } 24 | printf("%.3lf\n",sum); 25 | } 26 | return 0; 27 | } -------------------------------------------------------------------------------- /ACdream/1013(水题).cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * this code is made by LzyRapx 3 | * Problem: 1013 4 | * Verdict: Accepted 5 | * Submission Date: 2017-06-05 15:10:02 6 | * Time: 4MS 7 | * Memory: 1668KB 8 | */ 9 | #include 10 | using namespace std; 11 | 12 | int main() 13 | { 14 | int n; 15 | string s; 16 | while(cin>>n>>s) 17 | { 18 | int len = s.size(); 19 | int diff = n-len; 20 | int L=0,R=0; 21 | for(int i=0;i 2 | using namespace std; 3 | int dp[1234567]; 4 | int main() 5 | { 6 | int a,b; 7 | cin>>a>>b; 8 | if(a>b)return 0*puts("-1"); 9 | memset(dp,63,sizeof(dp)); 10 | dp[a] = 0; 11 | for(int i=a;i<=b;i++) 12 | { 13 | for(int j=1;j*j<=i;j++) 14 | { 15 | if(i%j==0) 16 | { 17 | dp[i + j] = min (dp[i + j],dp[ i ] + 1); 18 | dp[i + i/j] = min( dp[i + i/j] , dp[i] + 1); 19 | } 20 | } 21 | } 22 | cout< 2 | using namespace std; 3 | typedef long long ll; 4 | int main() 5 | { 6 | int t ; 7 | cin>>t; 8 | ll a,b; 9 | while(t--) 10 | { 11 | scanf("%lld%lld",&a,&b);//不AC就上输入挂吧 12 | if(abs(a)==4611686018427387904 &&abs(b)==4611686018427387904&&a!=b) 13 | { 14 | cout<<"9223372036854775808"< 10 | using namespace std; 11 | typedef long long ll; 12 | #define pi acos(-1.0) 13 | int main() 14 | { 15 | //printf("%.10lf\n",pi); 16 | int t; 17 | double n,a; 18 | cin>>t; 19 | while(t--) 20 | { 21 | scanf("%lf%lf",&n,&a); 22 | if(a>=90) a-=90; 23 | if(a==0) 24 | { 25 | printf("%.2lf\n",n*n);continue; 26 | } 27 | a = a*pi/180.0; 28 | double r = n / (1+cos(a)+sin(a)); 29 | printf("%.2lf\n",n*n-r*r*(sin(2*a))); 30 | } 31 | return 0; 32 | } -------------------------------------------------------------------------------- /ACdream/1066 (数学).cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * this code is made by LzyRapx 3 | * Problem: 1066 4 | * Verdict: Accepted 5 | * Submission Date: 2017-06-07 16:42:05 6 | * Time: 0MS 7 | * Memory: 1760KB 8 | */ 9 | #include 10 | using namespace std; 11 | double a[12345]; 12 | double x,ans,sum; 13 | int main() 14 | { 15 | int n; 16 | while(cin>>n) 17 | { 18 | sum = 1; 19 | cin>>a[0]; 20 | for(int i=1;i>a[i]; 22 | sum += a[0]/a[i]; 23 | } 24 | sum = 1.0 / sum; 25 | cin>>x; 26 | ans = sum*a[0]*x; 27 | printf("%.2f\n",ans); 28 | } 29 | return 0; 30 | } -------------------------------------------------------------------------------- /ACdream/1068(水题).cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * this code is made by LzyRapx 3 | * Problem: 1068 4 | * Verdict: Accepted 5 | * Submission Date: 2017-06-07 17:24:57 6 | * Time: 0MS 7 | * Memory: 1664KB 8 | */ 9 | #include 10 | using namespace std; 11 | typedef long long ll; 12 | ll solve(ll a,ll b) 13 | { 14 | ll ans = 0; 15 | while(a) 16 | { 17 | ans += a%10; 18 | a /= 10; 19 | } 20 | if(ans == b) return 1; 21 | return 0; 22 | } 23 | 24 | int main() 25 | { 26 | ll a,b,c; 27 | while(cin>>a>>b>>c) 28 | { 29 | for(ll i=a;i<=b;i++) 30 | { 31 | if(solve(i,c)) 32 | { 33 | cout< 2 | using namespace std;; 3 | 4 | int main() 5 | { 6 | long long n; 7 | while(cin>>n) 8 | { 9 | //cout< 10 | using namespace std; 11 | int ans,n; 12 | int dp[1234]; 13 | int a[1234]; 14 | int main() 15 | { 16 | cin>>n; 17 | for (int i=0;i>a[i]; 20 | 21 | } 22 | dp[0]=a[0]; 23 | dp[1]=min(a[0],a[1]); 24 | for (int i=2;i 10 | using namespace std; 11 | typedef long long ll; 12 | ll n,ans; 13 | char str[123]; 14 | int main() 15 | { 16 | while(~scanf("%s",str+1)) 17 | { 18 | sets; 19 | for(int i=1;str[i];i++) 20 | { 21 | s.insert(str[i]); 22 | } 23 | if(s.size()&1){ 24 | puts("IGNORE HIM!"); 25 | } 26 | else 27 | { 28 | puts("CHAT WITH HER!"); 29 | } 30 | } 31 | return 0; 32 | } -------------------------------------------------------------------------------- /ACdream/1090(博弈).cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * this code is made by LzyRapx 3 | * Problem: 1090 4 | * Verdict: Accepted 5 | * Submission Date: 2017-06-20 15:16:20 6 | * Time: 176MS 7 | * Memory: 1664KB 8 | */ 9 | #include 10 | using namespace std; 11 | typedef long long ll; 12 | const int maxn = 1e6+10; 13 | int main() 14 | { 15 | int t , n; 16 | cin>>t; 17 | while(t--) 18 | { 19 | cin>>n; 20 | cout<<"Dudu"< 10 | using namespace std; 11 | typedef long long ll; 12 | const int maxn = 1e6+10; 13 | int main() 14 | { 15 | int n; 16 | scanf("%d",&n); 17 | ll ans = 0; 18 | ll tmp; 19 | for(int i=0;i 10 | using namespace std; 11 | typedef long long ll; 12 | const int maxn = 5e6+10; 13 | int a[maxn]; 14 | int main() 15 | { 16 | int n; 17 | int m; 18 | while(cin>>n>>m) 19 | { 20 | for(int i=0;i 2 | using namespace std; 3 | char a[123]; 4 | int main() 5 | { 6 | int t; 7 | int ans = 1, num = 1, len; 8 | cin>>t; 9 | getchar(); 10 | while(t--) 11 | { 12 | ans=num=1; 13 | gets(a); 14 | len = strlen(a); 15 | for(int i=0;ians) 21 | { 22 | ans=num; 23 | } 24 | num=1; 25 | } 26 | } 27 | cout< 10 | using namespace std; 11 | typedef long long ll; 12 | //x + 2 = (a + 2)*(b + 2) 13 | //x = 3^p*5^q 14 | bool check(ll n) 15 | { 16 | n = n + 2; 17 | while(n%3==0)n/=3; 18 | while(n%5==0)n/=5; 19 | if(n==1)return true; 20 | else return false; 21 | } 22 | int main() 23 | { 24 | ll n; 25 | while(~scanf("%lld",&n)) 26 | { 27 | if(check(n))printf("Yes\n"); 28 | else printf("No\n"); 29 | } 30 | return 0; 31 | } -------------------------------------------------------------------------------- /ACdream/README.md: -------------------------------------------------------------------------------- 1 | # TODO 2 | -------------------------------------------------------------------------------- /AtCoder/abc139/.vscode/settings.json: -------------------------------------------------------------------------------- 1 | { 2 | "files.associations": { 3 | "ostream": "cpp" 4 | } 5 | } -------------------------------------------------------------------------------- /AtCoder/abc139/A - Tenki.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | string s; 4 | string t; 5 | int main() 6 | { 7 | cin >> t; 8 | cin >> s; 9 | int cnt = 0; 10 | for (int i = 0; i < t.size(); i++) 11 | { 12 | if (s[i] == t[i]) 13 | { 14 | cnt++; 15 | } 16 | } 17 | cout << cnt << endl; 18 | return 0; 19 | } -------------------------------------------------------------------------------- /AtCoder/abc139/B - Power Socket.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | int main() 6 | { 7 | int a, b; 8 | cin >> a >> b; 9 | if (b <= 1) 10 | { 11 | cout << 0 << endl; 12 | exit(0); 13 | } 14 | int now = 1; 15 | int ans = 0; 16 | while (now < b) 17 | { 18 | ans += 1; 19 | now -= 1; 20 | now += a; 21 | } 22 | cout << ans << endl; 23 | return 0; 24 | } -------------------------------------------------------------------------------- /AtCoder/abc139/C - Lower.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | int main() 5 | { 6 | int n; 7 | cin >> n; 8 | int v; 9 | cin >> v; 10 | int tmp = v; 11 | int ans = 0, cnt = 0; 12 | for (int i = 1; i < n; i++) 13 | { 14 | cin >> v; 15 | if (v <= tmp) 16 | { 17 | cnt += 1; 18 | tmp = v; 19 | } 20 | else 21 | { 22 | cnt = 0; 23 | tmp = v; 24 | } 25 | ans = max(ans, cnt); 26 | } 27 | cout << ans << endl; 28 | return 0; 29 | } -------------------------------------------------------------------------------- /AtCoder/abc139/D - ModSum.cpp: -------------------------------------------------------------------------------- 1 | 2 | #include 3 | 4 | using namespace std; 5 | 6 | // {1, 2, 3} => {3, 1, 2} => 3 7 | // {1, 2, 3 4 } => {4, 1, 2, 3} => 6 8 | int main() 9 | { 10 | long long n; 11 | cin >> n; 12 | cout << n * (n - 1) / 2 << endl; 13 | return 0; 14 | } -------------------------------------------------------------------------------- /AtCoder/abc139/main: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lzyrapx/Competitive-Programming/6b0eea727f9a6444700a6966209397ac7011226f/AtCoder/abc139/main -------------------------------------------------------------------------------- /BZOJ/1000(A+B).cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | int main() 4 | { 5 | int a,b; 6 | cin>>a>>b; 7 | cout< 7 | #include 8 | 9 | using namespace std; 10 | 11 | int main(int argc, char const *argv[]) 12 | { 13 | int t; 14 | cin >> t; 15 | while(t--) { 16 | int n; 17 | cin >> n; 18 | int l, r; 19 | int maxl = 0; 20 | int minr = 1e9; 21 | for(int i = 0; i < n; i++) { 22 | cin >> l >> r; 23 | maxl = max(maxl,l); 24 | minr = min(minr, r); 25 | } 26 | cout << max(0, maxl - minr) << endl; 27 | } 28 | return 0; 29 | } 30 | -------------------------------------------------------------------------------- /Codeforces/Math/1253C.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | // A sweet can be eaten at most once 6 | int main() 7 | { 8 | int n, m; 9 | cin >> n >> m; 10 | vector a(n), sum(n); 11 | for (int i = 0; i < n; i++) 12 | { 13 | cin >> a[i]; 14 | } 15 | long long ans = 0; 16 | sort(a.begin(), a.end()); 17 | for (int i = 0; i < n; i++) 18 | { 19 | sum[i % m] += a[i]; 20 | ans += sum[i % m]; 21 | if (i == n - 1) 22 | { 23 | cout << ans << endl; 24 | } 25 | else 26 | { 27 | cout << ans << " "; 28 | } 29 | } 30 | return 0; 31 | } 32 | // g++ -std=c++11 -O3 -o main 1253C.cpp 33 | // ./main -------------------------------------------------------------------------------- /Codeforces/Math/1255A.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | int main() 6 | { 7 | int t; 8 | cin >> t; 9 | while (t--) 10 | { 11 | int ans = 0; 12 | int a, b; 13 | cin >> a >> b; 14 | if (a == b) 15 | { 16 | cout << ans << endl; 17 | continue; 18 | } 19 | if (b > a) 20 | { 21 | swap(a, b); 22 | } 23 | a = a - b; 24 | ans += a / 5; 25 | a = a % 5; 26 | 27 | ans += a / 2; 28 | a = a % 2; 29 | 30 | ans += a; 31 | cout << ans << endl; 32 | } 33 | return 0; 34 | } 35 | // g++ -std=c++11 -O3 -o main 1255A.cpp 36 | // ./main -------------------------------------------------------------------------------- /Codeforces/Math/1257A.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | const int maxn = 123; 5 | 6 | int main() 7 | { 8 | int t; 9 | cin >> t; 10 | vector n(maxn), x(maxn), a(maxn), b(maxn); 11 | for (int i = 0; i < t; i++) 12 | { 13 | cin >> n[i] >> x[i] >> a[i] >> b[i]; 14 | } 15 | int ans = 0; 16 | for (int i = 0; i < t; i++) 17 | { 18 | ans = min(n[i] - 1, abs(a[i] - b[i]) + x[i]); 19 | cout << ans << endl; 20 | } 21 | return 0; 22 | } -------------------------------------------------------------------------------- /Codeforces/Math/1260A.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | 6 | int main() { 7 | int n; 8 | cin >> n; 9 | int c, sum; 10 | for(int i = 0; i < n; i++) { 11 | cin >> c >> sum; 12 | long long ans = 0; 13 | for(int i = 0; i < c; i++) { 14 | int t = sum / (c - i); 15 | sum -= t; 16 | ans += 1LL * t * t; 17 | 18 | } 19 | cout << ans << endl; 20 | } 21 | return 0; 22 | } -------------------------------------------------------------------------------- /Codeforces/Math/1260B.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | int main() 6 | { 7 | int t; 8 | cin >> t; 9 | while (t--) 10 | { 11 | long long a, b; 12 | cin >> a >> b; 13 | if (a > b) 14 | { 15 | swap(a, b); 16 | } 17 | if ((a + b) % 3 == 0 && (2 * a >= b)) 18 | { 19 | cout << "YES" << endl; 20 | } 21 | else 22 | { 23 | cout << "NO" << endl; 24 | } 25 | } 26 | return 0; 27 | } -------------------------------------------------------------------------------- /Codeforces/Math/1263A.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | // needs to eat exactly two candies. 6 | int a, b, c; 7 | int main() 8 | { 9 | int t; 10 | cin >> t; 11 | while (t--) 12 | { 13 | cin >> a >> b >> c; 14 | cout << min(min(min(a + b, b + c), a + c), (a + b + c) / 2) << endl; 15 | } 16 | return 0; 17 | } -------------------------------------------------------------------------------- /Codeforces/Math/1263C.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | using namespace std; 4 | 5 | int main() 6 | { 7 | int t; 8 | cin >> t; 9 | while (t--) 10 | { 11 | int n; 12 | cin >> n; 13 | set se; 14 | se.insert(0); 15 | for (int i = 1; i <= sqrt(n); i++) 16 | { 17 | se.insert(n / i); 18 | se.insert(i); 19 | } 20 | cout << se.size() << endl; 21 | for (auto x : se) 22 | { 23 | cout << x << " "; 24 | } 25 | cout << endl; 26 | } 27 | return 0; 28 | } -------------------------------------------------------------------------------- /Codeforces/Math/1271A.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * @Author: zhaoyang.liang 3 | * @Github: https://github.com/LzyRapx 4 | * @Date: 2019-12-15 22:48:48 5 | */ 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | #include 12 | #include 13 | #include 14 | #include 15 | 16 | using namespace std; 17 | 18 | typedef long long ll; 19 | 20 | 21 | int main() { 22 | int a, b, c, d, e, f; 23 | cin >> a >> b >> c >> d >> e >> f; 24 | int res = f * min(b, min(c, d)) + e * min(max(d - min(b, min(c, d)), 0), a); 25 | int ans = e * min(a, d) + f * min(max(d - min(a, d), 0), min(c, b)); 26 | cout << max(res, ans) << endl; 27 | return 0; 28 | } -------------------------------------------------------------------------------- /Codeforces/Math/main: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lzyrapx/Competitive-Programming/6b0eea727f9a6444700a6966209397ac7011226f/Codeforces/Math/main -------------------------------------------------------------------------------- /Codeforces/Math/run.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # sudo chmod +x run.sh 4 | 5 | cppname=$1 6 | 7 | outname="main" 8 | 9 | g++ -std=c++11 -O3 $cppname -o $outname 10 | 11 | ./$outname -------------------------------------------------------------------------------- /FZU/1001(A+B).cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | using namespace std; 6 | typedef long long ll; 7 | const int maxn=1e6+10; 8 | ll a[10],b[10],c[10]; 9 | int main() 10 | { 11 | int n,m; 12 | while(cin>>n>>m) 13 | { 14 | cout< 2 | #include 3 | #include 4 | #include 5 | #include 6 | using namespace std; 7 | typedef long long ll; 8 | const int maxn=1e6+10; 9 | int main() 10 | { 11 | srand((int)time(0)); 12 | int ans=rand()%50; 13 | cout< 2 | #include 3 | #include 4 | #include 5 | using namespace std; 6 | int dp[23][23][23]; 7 | int DP[23][23]; 8 | int n,ans; 9 | int main() 10 | { 11 | int x,y,z; 12 | while(~scanf("%d%d%d",&x,&y,&z)) 13 | { 14 | ans=x*3+y*2+z*6; 15 | if(ans>=60) puts("I passed the exam."); 16 | else puts("Exam was too hard."); 17 | printf("%d\n",ans); 18 | } 19 | return 0; 20 | } -------------------------------------------------------------------------------- /HDUOJ/1000(A+B).cpp: -------------------------------------------------------------------------------- 1 | #include 2 | int main() 3 | { 4 | int a,b; 5 | while(scanf("%d%d",&a,&b)!=EOF) 6 | { 7 | printf("%d\n",a+b); 8 | } 9 | } -------------------------------------------------------------------------------- /HDUOJ/1001(水题).cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | int main() 4 | { 5 | int n; 6 | while(cin>>n) 7 | { 8 | int sum=0; 9 | for(int i=1;i<=n;++i) 10 | { 11 | sum=sum+i; 12 | } 13 | cout< 2 | #include 3 | #include 4 | using namespace std; 5 | int main() 6 | { 7 | string a[1000]; 8 | int T=0,k=0,i,j; 9 | while(cin>>T){ 10 | if(T==0)break; 11 | int b[1000]={0}; 12 | for( i=1;i<=T;i++){ 13 | // scanf("%s",&a[i]); 14 | cin>>a[i]; 15 | } 16 | for(i=1;i<=T;i++)for( j=1;j<=T;j++){ 17 | if(a[i]==a[j]){ 18 | b[i]++; 19 | } 20 | 21 | } 22 | int maxx=0; 23 | for( i=1;i<=T;i++){ 24 | if (b[i] > b[maxx]) 25 | maxx = i; 26 | } 27 | // printf("%s",a[max]); 28 | cout< 2 | #include 3 | int main() 4 | { 5 | int a,b,n; 6 | while(~scanf("%d%d%d",&a,&b,&n)){ 7 | if(a==0&&b==0&&n==0)break; 8 | int arr[48]; 9 | arr[1]=1; 10 | arr[2]=1; 11 | for(int i=3;i<48;i++) 12 | arr[i]=((a*arr[i-1]+b*arr[i-2])%7); 13 | printf("%d\n",arr[n%48]); 14 | 15 | } 16 | } -------------------------------------------------------------------------------- /HDUOJ/1006(模拟).cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lzyrapx/Competitive-Programming/6b0eea727f9a6444700a6966209397ac7011226f/HDUOJ/1006(模拟).cpp -------------------------------------------------------------------------------- /HDUOJ/1008(模拟).cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lzyrapx/Competitive-Programming/6b0eea727f9a6444700a6966209397ac7011226f/HDUOJ/1008(模拟).cpp -------------------------------------------------------------------------------- /HDUOJ/1010.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lzyrapx/Competitive-Programming/6b0eea727f9a6444700a6966209397ac7011226f/HDUOJ/1010.cpp -------------------------------------------------------------------------------- /HDUOJ/1012(数学题).cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | int f(int n) 4 | { 5 | int i,t; 6 | if(n==0) return 1; 7 | t = 1; 8 | for(i=1;i<=n;i++) t *= i; 9 | return t; 10 | } 11 | int main() 12 | { 13 | int i,j,n; 14 | double t,r; 15 | printf("n e\n"); 16 | printf("- -----------\n"); 17 | for(i=0;i<=9;i++) 18 | { 19 | t = 0.0; 20 | for(j=0;j<=i;j++) 21 | t += 1.0/f(j); 22 | if(i==0||i==1)printf("%d %.0f\n",i,t); 23 | else if(i==2)printf("%d %.1f\n",i,t); 24 | else printf("%d %.9lf\n",i,t); 25 | } 26 | return 0; 27 | } -------------------------------------------------------------------------------- /HDUOJ/1013(数值计算).cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lzyrapx/Competitive-Programming/6b0eea727f9a6444700a6966209397ac7011226f/HDUOJ/1013(数值计算).cpp -------------------------------------------------------------------------------- /HDUOJ/1014(GCD).cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | using namespace std; 4 | int gcd(int a,int b) 5 | { 6 | if(!b)return a; 7 | return gcd(b,a%b); 8 | } 9 | int main() 10 | { 11 | int step,mod; 12 | while(~scanf("%d%d",&step,&mod)){ 13 | int ans=gcd(step,mod); 14 | if(ans==1) printf("%10d%10d Good Choice\n\n",step,mod); 15 | else printf("%10d%10d Bad Choice\n\n",step,mod); 16 | } 17 | 18 | return 0; 19 | } -------------------------------------------------------------------------------- /HDUOJ/1015.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lzyrapx/Competitive-Programming/6b0eea727f9a6444700a6966209397ac7011226f/HDUOJ/1015.cpp -------------------------------------------------------------------------------- /HDUOJ/1016.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lzyrapx/Competitive-Programming/6b0eea727f9a6444700a6966209397ac7011226f/HDUOJ/1016.cpp -------------------------------------------------------------------------------- /HDUOJ/1017(暴力枚举).cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | using namespace std; 4 | int main(){ 5 | int T,n,m,flag=0,result; 6 | cin>>T; 7 | while(T--){ 8 | flag=0; 9 | while(cin>>n>>m){ 10 | if(m==0&&n==0) break; 11 | else{ 12 | flag++; 13 | result=0; 14 | for(int a=1;a 2 | #include 3 | using namespace std; 4 | int main() 5 | { 6 | int n,i,T; 7 | double sum; 8 | cin>>T; 9 | while(T--){ 10 | cin>>n; 11 | sum=0.0; 12 | for(i=2;i<=n;i++){ 13 | sum+=log10(i); 14 | } 15 | cout<<(int)sum+1< 2 | int main() 3 | { 4 | int f1,f2,fn,i,n; 5 | 6 | while (scanf("%d",&n)==1) 7 | { 8 | f1=7,f2=11; 9 | for (i=2;i<=n;i++) 10 | { 11 | fn=(f1+f2)%3; 12 | f1=f2%3; 13 | f2=fn%3; 14 | } 15 | if (fn%3==0) 16 | { 17 | printf("yes\n"); 18 | } 19 | else 20 | { 21 | printf("no\n"); 22 | } 23 | } 24 | } 25 | 26 | -------------------------------------------------------------------------------- /HDUOJ/1026.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lzyrapx/Competitive-Programming/6b0eea727f9a6444700a6966209397ac7011226f/HDUOJ/1026.cpp -------------------------------------------------------------------------------- /HDUOJ/1027.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | int main() 5 | { 6 | int a[1010] ; 7 | int n , m , i , j ; 8 | while(cin >> n >> m) 9 | { 10 | for(i = 0 ; i < n ; i ++) 11 | a[i] = i + 1 ; 12 | for(i = 1 ; i < m ; i ++) 13 | { 14 | next_permutation(a , a + n) ; 15 | if(i == m - 1) 16 | { 17 | for(j = 0 ; j < n -1 ; j ++) 18 | cout << a[j] << " "; 19 | cout << a[n - 1] << endl ; 20 | } 21 | } 22 | } 23 | return 0; 24 | } -------------------------------------------------------------------------------- /HDUOJ/1028(dp).cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | using namespace std; 4 | int main() 5 | { 6 | int dp[122][122]={0}; 7 | int n; 8 | for(int i=0;i<121;i++) 9 | { 10 | dp[i][0]=1; 11 | dp[i][1]=1; 12 | dp[0][i]=1; 13 | dp[1][i]=1; 14 | } 15 | for(int i=2;i<121;i++) 16 | for(int j=2;j<121;j++){ 17 | if(i>=j) 18 | dp[i][j]=dp[i][j-1]+dp[i-j][j]; 19 | else 20 | dp[i][j]=dp[i][i]; 21 | } 22 | 23 | while(scanf("%d",&n)==1) 24 | printf("%d\n",dp[n][n]); 25 | 26 | return 0; 27 | } -------------------------------------------------------------------------------- /HDUOJ/1029(水题).cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | using namespace std; 4 | int a[999999]; 5 | int main() 6 | { 7 | 8 | int n; 9 | while(~scanf("%d",&n)) 10 | { 11 | for(int i=0;i 2 | #include 3 | using namespace std; 4 | 5 | int main() 6 | { 7 | int n,m; 8 | long long ans=0; 9 | while(~scanf("%d%d",&n,&m)){ 10 | printf("%d %d ",n,m); 11 | if(n>m) 12 | swap(n,m); 13 | long long max=0; 14 | for(int i=n;i<=m;i++) 15 | { 16 | long long t=i; 17 | long long cnt=1; 18 | while(t!=1) 19 | { 20 | if(t%2==0) 21 | t/=2; 22 | else 23 | t=(t*3+1); 24 | cnt++; 25 | } 26 | if(cnt>max) 27 | max=cnt; 28 | } 29 | printf("%lld\n",max); 30 | } 31 | 32 | return 0; 33 | } -------------------------------------------------------------------------------- /HDUOJ/1040(水题).cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | using namespace std; 5 | int main() 6 | { 7 | int n,m, a[2000]; 8 | int i; 9 | while (~scanf_s("%d", &n)) 10 | { 11 | 12 | while (n--) 13 | { 14 | scanf_s("%d", &m); 15 | for (i = 1; i <= m; i++) 16 | { 17 | scanf_s("%d", &a[i]); 18 | } 19 | sort(a + 1, a + m + 1); 20 | for (i = 1; i <= m; i++) 21 | { 22 | if (i == m) 23 | { 24 | printf("%d\n", a[i]); 25 | } 26 | else 27 | { 28 | printf("%d ", a[i]); 29 | } 30 | } 31 | } 32 | } 33 | } 34 | 35 | -------------------------------------------------------------------------------- /HDUOJ/1048(字符串).cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lzyrapx/Competitive-Programming/6b0eea727f9a6444700a6966209397ac7011226f/HDUOJ/1048(字符串).cpp -------------------------------------------------------------------------------- /HDUOJ/1051.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lzyrapx/Competitive-Programming/6b0eea727f9a6444700a6966209397ac7011226f/HDUOJ/1051.cpp -------------------------------------------------------------------------------- /HDUOJ/1056(数学题).cpp: -------------------------------------------------------------------------------- 1 | 2 | #include 3 | int main() 4 | { 5 | float a=0.0; 6 | while(1) 7 | { 8 | scanf("%f",&a); 9 | float sum=0; 10 | float i=0; 11 | int count=0; 12 | if(a==0.00) 13 | { 14 | break; 15 | } 16 | for(i=2.0;sum 2 | #include 3 | using namespace std; 4 | int main() 5 | { 6 | int t,N; 7 | double x=0.0; 8 | cin>>t; 9 | while(t--){ 10 | cin>>N; 11 | x=N*log10((double)N); 12 | x-=(long long)x; 13 | x=(int)pow(10,x); 14 | cout< 2 | #include 3 | int qmod(long long a,long long b,int c) 4 | { 5 | int ans=1; 6 | a=a%c; 7 | while(b>0){ 8 | if(b&1) 9 | ans=(ans*a)%c; 10 | b=b>>1; 11 | a=(a*a)%c; 12 | } 13 | return ans; 14 | } 15 | int main() 16 | { 17 | int n; long long t; 18 | scanf("%d",&n); 19 | while(n--) 20 | { 21 | scanf("%lld",&t); 22 | printf("%d\n",qmod(t,t,10)); 23 | } 24 | 25 | return 0; 26 | } -------------------------------------------------------------------------------- /HDUOJ/1065.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | using namespace std; 6 | int main() 7 | { 8 | int t;int times=0; 9 | scanf("%d",&t); 10 | while(t--) 11 | { 12 | double x,y; double res=0; 13 | cin>>x>>y; 14 | res=(x*x+y*y)*(3.1415926)/100; 15 | printf("Property %d: This property will begin eroding in year %d.\n",++times,int(res+1)); 16 | } 17 | puts("END OF OUTPUT."); 18 | return 0; 19 | } -------------------------------------------------------------------------------- /HDUOJ/1070(数学水题).cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | using namespace std; 6 | int main() 7 | { 8 | int T,day; 9 | scanf("%d",&T); 10 | while(T--) 11 | { 12 | int percost=9999999,val=0,n; 13 | string s; 14 | string ans; 15 | cin>>n; 16 | while(n--){ 17 | int cost,v,day; 18 | cin>>s>>cost>>v; 19 | if(v<200)continue; 20 | day=v/200; 21 | if(day>5)day=5; 22 | if(cost/dayval)) 23 | { 24 | percost=cost/day; 25 | val=v; 26 | ans=s; 27 | } 28 | } 29 | cout< 2 | #include 3 | using namespace std; 4 | 5 | int main() 6 | { 7 | int T; 8 | double x1,x2,x3,y1,y2,y3,a,b,c,k,t,x,s1,s2; 9 | cin>>T; 10 | while(T--) 11 | { 12 | cin>>x1>>y1>>x2>>y2>>x3>>y3; 13 | 14 | a=(y2-y1)/((x1-x2)*(x1-x2)); 15 | 16 | b=-2*a*x1; 17 | 18 | c=y1+a*x1*x1; 19 | 20 | k=(y3-y2)/(x3-x2); 21 | 22 | t=y3-(k*x3); 23 | 24 | s1=a/3*x3*x3*x3+(b-k)/2*x3*x3+(c-t)*x3; 25 | s2=a/3*x2*x2*x2+(b-k)/2*x2*x2+(c-t)*x2; 26 | 27 | printf("%.2lf\n",s1-s2); 28 | } 29 | return 0; 30 | } 31 | -------------------------------------------------------------------------------- /HDUOJ/1072.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lzyrapx/Competitive-Programming/6b0eea727f9a6444700a6966209397ac7011226f/HDUOJ/1072.cpp -------------------------------------------------------------------------------- /HDUOJ/1075.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lzyrapx/Competitive-Programming/6b0eea727f9a6444700a6966209397ac7011226f/HDUOJ/1075.cpp -------------------------------------------------------------------------------- /HDUOJ/1076(数学题).cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | int f(int,int); 4 | int main() 5 | { 6 | int N,Y; 7 | int n; 8 | cin>>n; 9 | for(int i=0;i>Y>>N; 12 | cout< 2 | using namespace std; 3 | int main() 4 | { 5 | int a,b; 6 | while(cin>>a>>b) 7 | { 8 | cout< 2 | using namespace std; 3 | int main() 4 | { 5 | int a,b; 6 | int n; 7 | cin>>n; 8 | for(int i=0;i>a>>b; 11 | cout< 2 | using namespace std; 3 | int main(int argc, char *argv[]) 4 | { 5 | int a,b; 6 | while(cin>>a>>b) 7 | { 8 | if(a==0&&b==0) continue; 9 | cout< 2 | using namespace std; 3 | int main(int argc, char *argv[]) 4 | { 5 | int a,b; 6 | while(cin>>a>>b) 7 | { 8 | if(a==0&&b==0) continue; 9 | cout< 2 | int main() 3 | { 4 | int n,i,s; 5 | while(scanf("%d",&n)!=EOF) 6 | { 7 | s=0; 8 | while(n--) 9 | { 10 | scanf("%d",&i); 11 | s=s+i; 12 | } 13 | printf("%d\n",s); 14 | } 15 | return 0; 16 | } -------------------------------------------------------------------------------- /HDUOJ/1095.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | int main() 4 | { 5 | long long n,m; 6 | while(cin>>n>>m){ 7 | cout< 2 | int main() 3 | { 4 | int T,n,a,sum=0,i; 5 | scanf("%d",&T); 6 | while(T--) 7 | { 8 | scanf("%d",&n); 9 | for(i=0;i 2 | #include 3 | typedef long long LL; 4 | 5 | int qmod(LL a,LL b,int c) 6 | { 7 | int ans=1; 8 | a=a%c; 9 | while(b>0){ 10 | if(b&1) 11 | ans=(ans*a)%c; 12 | b=b>>1; 13 | a=(a*a)%c; 14 | } 15 | return ans; 16 | } 17 | 18 | int main() 19 | { 20 | LL a,b; 21 | while(~scanf("%lld%lld",&a,&b)){ 22 | printf("%d\n",qmod(a,b,10)); 23 | } 24 | return 0; 25 | } -------------------------------------------------------------------------------- /HDUOJ/1098(费马小定理).cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | using namespace std; 9 | #define MA 10010 10 | int main() 11 | { 12 | int n,i,k; 13 | while(~scanf("%d",&k)) 14 | { 15 | for(i=1;i<=65;i++) 16 | { 17 | if((18+i*k)%65==0) 18 | { 19 | printf("%d\n",i); 20 | break; 21 | } 22 | } 23 | if(i>=66) 24 | printf("no\n"); 25 | } 26 | 27 | return 0; 28 | } -------------------------------------------------------------------------------- /HDUOJ/1106.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | char s[1005]; 6 | int a[1005]; 7 | char * temp; 8 | int cmp(const void *a,const void *b) 9 | { 10 | return *(int *)a-*(int *)b; 11 | } 12 | int main() 13 | { 14 | int c; 15 | while(gets(s)) 16 | { 17 | a[0]=atoi(strtok(s,"5")); 18 | c=1; 19 | while(temp=strtok(NULL,"5")) 20 | { 21 | a[c++]=atoi(temp); 22 | } 23 | qsort(a,c,sizeof a[0],cmp); 24 | printf("%d",a[0]); 25 | for(int i=1;i 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | using namespace std; 8 | int gcd(int a,int b) 9 | { 10 | if(!b)return a; 11 | return gcd(b,a%b); 12 | } 13 | int main() 14 | { 15 | int n,m; 16 | while(cin>>n>>m){ 17 | printf("%d\n",n*m/gcd(n,m)); 18 | } 19 | return 0; 20 | } 21 | -------------------------------------------------------------------------------- /HDUOJ/1128.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | int a[1000001]={0}; 4 | int main() 5 | { 6 | int i,j,sum=0; 7 | for(i=1;i<=1000000;i++) 8 | { 9 | j=i; 10 | for(sum=j;j;j/=10) 11 | sum+=j%10; 12 | a[sum]=1; 13 | if(!a[i]) 14 | printf("%d\n",i); 15 | } 16 | return 0; 17 | } -------------------------------------------------------------------------------- /HDUOJ/1141.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lzyrapx/Competitive-Programming/6b0eea727f9a6444700a6966209397ac7011226f/HDUOJ/1141.cpp -------------------------------------------------------------------------------- /HDUOJ/1157.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | using namespace std; 9 | int main() 10 | { 11 | 12 | int n,a[100010]; 13 | while(cin>>n){ 14 | for(int i=0;i>a[i]; 16 | sort(a,a+n); 17 | cout< 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | using namespace std; 9 | int main() 10 | { 11 | int n,m; 12 | while(~scanf("%d",&n)){ 13 | if(n==0)break; 14 | m=n; 15 | for(int i=1;i 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | typedef long long LL; 10 | using namespace std; 11 | int prime(int n){ 12 | for(int i=2;i<=sqrt(n);i++){ 13 | if(n%i==0) 14 | return 0; 15 | if(i>n)return 1; 16 | } 17 | } 18 | 19 | int main() 20 | { 21 | int m; 22 | while(cin>>m){ 23 | if(prime(m)){ 24 | printf("%d\n",m);continue; 25 | } 26 | 27 | for(int i=2;i<=sqrt(m);i++){ 28 | if(m%i==0){ 29 | printf("%d*",i); 30 | m/=i; 31 | i=1; 32 | } 33 | } 34 | printf("%d\n",m); 35 | 36 | } 37 | 38 | 39 | return 0; 40 | } 41 | 42 | -------------------------------------------------------------------------------- /HDUOJ/1165.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | 推导公式:m=0时 A(m,n)=n+1; 3 | m=1时 A(m,n)=A(0,A(1,n-1))=A(1,n-1)+1=A(1,n-2)+1+1=……=n+2; 4 | m=2时 A(m,n)=A(m,n-1)+2 =2*n+3 5 | m=3时 A(m,n)=A(2,A(m,n-1))=A(m,n-1)*2+3 6 | */ 7 | 8 | #include 9 | using namespace std; 10 | long long A(long long m,long long n) 11 | { 12 | if(n==0) return A(m-1,1); 13 | else if(m==0)return n+1; 14 | else if(m==1) return n+2; 15 | else if(m==2) return A(m,n-1)+2; 16 | else if(m==3)return A(m,n-1)*2+3; 17 | } 18 | int main() 19 | { 20 | long long n,m; 21 | while(~scanf("%lld%lld",&m,&n)) 22 | printf("%lld\n",A(m,n)); 23 | return 0; 24 | } -------------------------------------------------------------------------------- /HDUOJ/1170.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lzyrapx/Competitive-Programming/6b0eea727f9a6444700a6966209397ac7011226f/HDUOJ/1170.cpp -------------------------------------------------------------------------------- /HDUOJ/1174(叉积).cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lzyrapx/Competitive-Programming/6b0eea727f9a6444700a6966209397ac7011226f/HDUOJ/1174(叉积).cpp -------------------------------------------------------------------------------- /HDUOJ/1175.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lzyrapx/Competitive-Programming/6b0eea727f9a6444700a6966209397ac7011226f/HDUOJ/1175.cpp -------------------------------------------------------------------------------- /HDUOJ/1180.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lzyrapx/Competitive-Programming/6b0eea727f9a6444700a6966209397ac7011226f/HDUOJ/1180.cpp -------------------------------------------------------------------------------- /HDUOJ/1181.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lzyrapx/Competitive-Programming/6b0eea727f9a6444700a6966209397ac7011226f/HDUOJ/1181.cpp -------------------------------------------------------------------------------- /HDUOJ/1194.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lzyrapx/Competitive-Programming/6b0eea727f9a6444700a6966209397ac7011226f/HDUOJ/1194.cpp -------------------------------------------------------------------------------- /HDUOJ/1196.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lzyrapx/Competitive-Programming/6b0eea727f9a6444700a6966209397ac7011226f/HDUOJ/1196.cpp -------------------------------------------------------------------------------- /HDUOJ/1197.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lzyrapx/Competitive-Programming/6b0eea727f9a6444700a6966209397ac7011226f/HDUOJ/1197.cpp -------------------------------------------------------------------------------- /HDUOJ/1201.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lzyrapx/Competitive-Programming/6b0eea727f9a6444700a6966209397ac7011226f/HDUOJ/1201.cpp -------------------------------------------------------------------------------- /HDUOJ/1205.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lzyrapx/Competitive-Programming/6b0eea727f9a6444700a6966209397ac7011226f/HDUOJ/1205.cpp -------------------------------------------------------------------------------- /HDUOJ/1210.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | //数字1的下一位置 = 它的上一位置*2 %(总牌数+1) 3 | int main() 4 | { 5 | int n,t,sum; 6 | int pos;//记录1的位置 7 | while(~scanf("%d",&n)) 8 | { 9 | pos=1;//一开始1在第一个位置 10 | t=2*n+1; 11 | sum=0; 12 | while(1) 13 | { 14 | pos=pos*2%t;//1的下一个位置 15 | sum++; 16 | if(pos==1)//1回到第一个位置 17 | break; 18 | } 19 | printf("%d\n",sum); 20 | } 21 | return 0; 22 | } -------------------------------------------------------------------------------- /HDUOJ/1215.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | int a[500001]; 3 | int main() 4 | { 5 | int n,i,num,j; 6 | scanf("%d",&n); 7 | a[0]=a[1]=1; 8 | for(i=1;i<=500000/2;i++) 9 | for(j=i*2;j<=500000;j+=i) 10 | a[j]+=i; 11 | while(n--) 12 | { 13 | scanf("%d",&num); 14 | printf("%d\n",a[num]); 15 | } 16 | return 0; 17 | } -------------------------------------------------------------------------------- /HDUOJ/1219(字母统计).cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | typedef long long LL; 10 | using namespace std; 11 | 12 | int main() 13 | { 14 | char c[100005]; 15 | while(gets(c)){ 16 | int b[27]={0}; 17 | int k=strlen(c); 18 | for(int i=0;i='a'&&c[i]<='z') 20 | b[c[i]-'a']++; 21 | for(int i=0;i<26;i++) 22 | printf("%c:%d\n",i+'a',b[i]); 23 | puts(""); 24 | } 25 | 26 | return 0; 27 | } 28 | -------------------------------------------------------------------------------- /HDUOJ/1220.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | int main() 4 | { 5 | int n; 6 | while(std::cin>>n) 7 | { 8 | std::cout<<(n*n*n*(n*n*n-1))/2-3*(n*n)*(n-1)< 2 | using namespace std; 3 | 4 | int main() 5 | { 6 | int t; 7 | scanf("%d",&t); 8 | while(t--) 9 | { 10 | int n,m; 11 | scanf("%d%d",&m,&n); 12 | if(__gcd(m,n)==1)puts("NO");//最大公约数大于1,中间一定有空余的洞没有走 13 | else puts("YES"); 14 | } 15 | return 0; 16 | } -------------------------------------------------------------------------------- /HDUOJ/1228.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | map m; 4 | int main() 5 | { 6 | m["one"]=1; 7 | m["two"]=2; 8 | m["three"]=3; 9 | m["four"]=4; 10 | m["five"]=5; 11 | m["six"]=6; 12 | m["seven"]=7; 13 | m["eight"]=8; 14 | m["nine"]=9; 15 | m["zero"]=0; 16 | string a; 17 | int tmp; 18 | while(1) 19 | { 20 | int x=0; 21 | while(cin>>a,a!="+") 22 | { 23 | x=x*10+m[a]; 24 | } 25 | int y=0; 26 | while(cin>>a,a!="=") 27 | { 28 | y=y*10+m[a]; 29 | } 30 | if(x==0&&y==0) 31 | break; 32 | printf("%d\n",x+y); 33 | } 34 | return 0; 35 | } -------------------------------------------------------------------------------- /HDUOJ/1229.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | bool judge(int x,int y,int k) 3 | { 4 | if(k==0) return false; 5 | for(int i=1;i<=k;i++) 6 | { 7 | if((x%10)!=(y%10)) return false; 8 | x/=10; 9 | y/=10; 10 | } 11 | return true; 12 | } 13 | int main() 14 | { 15 | int a,b,k; 16 | while(scanf("%d%d%d",&a,&b,&k)!=EOF) 17 | { 18 | if(a==0&&b==0) break; 19 | if(judge(a,b,k)) printf("-1\n"); 20 | else printf("%d\n",a+b); 21 | } 22 | return 0; 23 | } -------------------------------------------------------------------------------- /HDUOJ/1233.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lzyrapx/Competitive-Programming/6b0eea727f9a6444700a6966209397ac7011226f/HDUOJ/1233.cpp -------------------------------------------------------------------------------- /HDUOJ/1234.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lzyrapx/Competitive-Programming/6b0eea727f9a6444700a6966209397ac7011226f/HDUOJ/1234.cpp -------------------------------------------------------------------------------- /HDUOJ/1235.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | typedef long long LL; 10 | using namespace std; 11 | 12 | 13 | int main() 14 | { 15 | int cnt,i,n; 16 | int grade,score[1001]; 17 | while(cin>>n){ 18 | if(n==0)break; 19 | cnt=0; 20 | for(i=0;i 2 | #include 3 | #include 4 | using namespace std; 5 | double s[200]; 6 | double num; 7 | int main() 8 | { 9 | while(scanf("%lf",&num)!=EOF) 10 | { 11 | int n=0; 12 | s[n++]=num; 13 | char c=getchar(); 14 | if(num==0&&c=='\n') break; 15 | char x; 16 | while(1) 17 | { 18 | scanf("%c %lf",&x,&num); 19 | switch(x) 20 | { 21 | case'+':s[n++]=num;break; 22 | case'-':s[n++]=-num;break; 23 | case'*':s[n-1]*=num;break; 24 | case'/':s[n-1]/=num;break; 25 | } 26 | if(getchar()=='\n')break; 27 | } 28 | double sum=0; 29 | for(int i=0;i 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | typedef long long LL; 10 | using namespace std; 11 | 12 | int main(){ 13 | int i,j,m,n; 14 | int a[3]={150,200,350}; 15 | int dp[10001]; 16 | cin>>n; 17 | while(n--){ 18 | memset(dp,0,sizeof(dp)); 19 | cin>>m; 20 | for(i=0;i<3;i++){ 21 | for(j=a[i];j<=m;j++){ 22 | dp[j]=max(dp[j],dp[j-a[i]]+a[i]); 23 | } 24 | } 25 | // for(int k=0;k<=m;k++){ 26 | // cout< 2 | #include 3 | using namespace std; 4 | int main() 5 | { 6 | int t; 7 | int n; 8 | char c; 9 | scanf("%d",&t); 10 | while(t--) 11 | { 12 | scanf("%d",&n); 13 | int x,y,i; 14 | char a[10] = "#ZJUTACM"; 15 | for(i = 0;i 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | typedef long long LL; 10 | using namespace std; 11 | 12 | int main(){ 13 | int n,m,i,k; 14 | scanf("%d",&n); 15 | for(i=0;i 2 | using namespace std; 3 | int main() 4 | { 5 | int t; 6 | cin>>t; 7 | while(t--) 8 | { 9 | int n; 10 | cin>>n; 11 | int a[n]; 12 | for(int i=1;i 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | typedef long long LL; 10 | using namespace std; 11 | int n[201]; 12 | int main() 13 | { 14 | int t; 15 | char c; 16 | while(cin>>t,t+1){ 17 | memset(n, 0, sizeof(n)); 18 | n[t]=1; 19 | while(cin>>t,t) 20 | n[t]=1; 21 | int count = 0; 22 | 23 | for(int i = 0; i < 200; i++) 24 | if(n[i]) 25 | if(n[2 * i]) 26 | count++; 27 | cout << count < 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | typedef long long LL; 11 | using namespace std; 12 | 13 | int main() 14 | { 15 | int n; 16 | int a[101]; int m=1; 17 | while(cin>>n){ 18 | if(n==0)break; 19 | int sum=0; 20 | for(int i=0;iavg){ 28 | ans+=(a[i]-avg); 29 | } 30 | } 31 | cout<<"Set #"< 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | typedef long long LL; 12 | using namespace std; 13 | int main() 14 | { 15 | int n,i; 16 | double sum; 17 | int flag=1; 18 | 19 | while(scanf("%d",&n)!=EOF) 20 | { 21 | if(flag) 22 | { 23 | printf("# Cards Overhang\n"); 24 | flag=0; 25 | } 26 | sum=0; 27 | for(i=1;i<=n;i++) 28 | { 29 | sum=sum+1.0/(2*i); 30 | } 31 | printf("%5d %.3lf\n",n,sum); 32 | } 33 | return 0; 34 | } -------------------------------------------------------------------------------- /HDUOJ/1334.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | typedef long long LL; 12 | using namespace std; 13 | int main() 14 | { 15 | for(int a=6;a<=200;a++) 16 | for(int b=2;b 2 | int n,a; 3 | int main(){for(;~scanf("%d",&a);n?printf("%d\n",(int)sqrt(a)):n=a);} -------------------------------------------------------------------------------- /HDUOJ/1339.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | typedef long long LL; 12 | using namespace std; 13 | int main() 14 | { 15 | int n,m,T,i,o; 16 | cin>>T; 17 | while(T--) 18 | { 19 | cin>>n; 20 | for( i=0;i<=20;i++) 21 | { 22 | m=(int)pow(2.0,(double)i); //o*m 23 | o=n/m; 24 | if(n%m==0&&o%2==1) break; 25 | } 26 | printf("%d %d\n",o,i); 27 | 28 | } 29 | return 0; 30 | } -------------------------------------------------------------------------------- /HDUOJ/1342.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | int a[20],n,v[6],size; 3 | void dfs(int i,int num) 4 | { 5 | if(i>n) return ; 6 | if(num==6) 7 | { 8 | for(int i=0;i<5;i++) 9 | printf("%d ",v[i]); 10 | printf("%d\n",v[5]); 11 | return ; 12 | } 13 | v[size++]=a[i]; 14 | dfs(i+1,num+1); 15 | size--; 16 | dfs(i+1,num); 17 | } 18 | int main() 19 | { 20 | int cas=0; 21 | while(~scanf("%d",&n),n) 22 | { 23 | size=0; 24 | if(cas++) puts(""); 25 | for(int i=0;i 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | typedef long long LL; 12 | using namespace std; 13 | int main() 14 | { 15 | int x,y,T; 16 | scanf("%d",&T); 17 | while(T--) 18 | { 19 | scanf("%d%d",&x,&y); 20 | if(x==y) 21 | x%2==1? printf("%d\n",x+x-1):printf("%d\n",x+x); 22 | else if(x-y==2) 23 | x%2==1?printf("%d\n",x+y-1):printf("%d\n",x+y); 24 | else printf("No Number\n"); 25 | } 26 | return 0; 27 | 28 | } -------------------------------------------------------------------------------- /HDUOJ/1393.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lzyrapx/Competitive-Programming/6b0eea727f9a6444700a6966209397ac7011226f/HDUOJ/1393.cpp -------------------------------------------------------------------------------- /HDUOJ/1406.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lzyrapx/Competitive-Programming/6b0eea727f9a6444700a6966209397ac7011226f/HDUOJ/1406.cpp -------------------------------------------------------------------------------- /HDUOJ/1407.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lzyrapx/Competitive-Programming/6b0eea727f9a6444700a6966209397ac7011226f/HDUOJ/1407.cpp -------------------------------------------------------------------------------- /HDUOJ/1408.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lzyrapx/Competitive-Programming/6b0eea727f9a6444700a6966209397ac7011226f/HDUOJ/1408.cpp -------------------------------------------------------------------------------- /HDUOJ/1412.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lzyrapx/Competitive-Programming/6b0eea727f9a6444700a6966209397ac7011226f/HDUOJ/1412.cpp -------------------------------------------------------------------------------- /HDUOJ/1418.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lzyrapx/Competitive-Programming/6b0eea727f9a6444700a6966209397ac7011226f/HDUOJ/1418.cpp -------------------------------------------------------------------------------- /HDUOJ/1465.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lzyrapx/Competitive-Programming/6b0eea727f9a6444700a6966209397ac7011226f/HDUOJ/1465.cpp -------------------------------------------------------------------------------- /HDUOJ/1491.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | using namespace std; 5 | int a[12]={31,28,31,30,31,30,31,31,30,31,30,31}; 6 | int i,j,k,l,m,n,x,y; 7 | int main() 8 | { 9 | scanf("%d",&k); 10 | while(k--) 11 | { 12 | scanf("%d%d",&x,&y); 13 | m=0; 14 | for(i=0;i294) 20 | printf("What a pity, it has passed!\n"); 21 | if(m<294) 22 | printf("%d\n",294-m); 23 | } 24 | return 0; 25 | } -------------------------------------------------------------------------------- /HDUOJ/1492.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lzyrapx/Competitive-Programming/6b0eea727f9a6444700a6966209397ac7011226f/HDUOJ/1492.cpp -------------------------------------------------------------------------------- /HDUOJ/1548.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lzyrapx/Competitive-Programming/6b0eea727f9a6444700a6966209397ac7011226f/HDUOJ/1548.cpp -------------------------------------------------------------------------------- /HDUOJ/1555.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | typedef long long LL; 12 | using namespace std; 13 | 14 | int main() 15 | { 16 | int m,k; 17 | while(cin>>m>>k,m&&k) 18 | { 19 | int day=0;int j=0; 20 | while(m>0) 21 | { 22 | day++; 23 | m=m-1; 24 | j++; 25 | if(j==k) m=m+1,j=0; 26 | } 27 | cout< 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | typedef long long LL; 12 | using namespace std; 13 | 14 | int main() 15 | { 16 | int n; 17 | cin>>n; 18 | while(n--){ 19 | int a,b,c,i,j=0; 20 | cin>>a>>b>>c; 21 | for(i=1000;i<10000;i++) 22 | if((i%a==0)&&((i+1)%b==0)&&((i+2)%c==0)){ 23 | j=i; 24 | cout< 2 | using namespace std; 3 | const int mod = 9973; 4 | typedef long long ll; 5 | 6 | //要求(A/B)%9973,但由于A很大, 7 | //我们只给出n(n=A%9973)(我们给定的A必能被B整除,且gcd(B,9973)=1)。 8 | 9 | //(a/c)%mod = (a*inv)%mod 10 | 11 | ll q_mod(ll a,ll n) 12 | { 13 | ll ans=1; 14 | while(n) 15 | { 16 | if(n&1)ans=ans*a%mod; 17 | a=a*a%mod; 18 | n>>=1; 19 | } 20 | return ans; 21 | } 22 | //x*x^(p-2)≡1(mod p),x^(p-2)即为逆元,p为素数 23 | int main() 24 | { 25 | int t; 26 | int n,B; 27 | cin>>t; 28 | while(t--) 29 | { 30 | cin>>n>>B; 31 | ll x = q_mod(B,mod-2);//x为逆元 32 | printf("%lld\n",n*x%mod); 33 | } 34 | return 0; 35 | } -------------------------------------------------------------------------------- /HDUOJ/1577.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | using namespace std; 5 | int gcd ( int a , int b ) 6 | { 7 | return b == 0 ? a:gcd ( b , a%b ); 8 | } 9 | int l,sx,sy,px,py; 10 | int main() 11 | { 12 | while (~scanf ("%d" ,&l ),l) 13 | { 14 | scanf ( "%d%d%d%d" , &sx , &sy , &px , &py ); 15 | int dx = abs ( sx - px ); 16 | int dy = abs ( sy - py ); 17 | int d = gcd ( dx , dy ); 18 | if ( abs ( px )> l || abs( py ) > l ) 19 | { 20 | puts ("Out Of Range"); 21 | continue; 22 | } 23 | if (d ==1) 24 | puts("Yes"); 25 | else puts("No"); 26 | } 27 | return 0; 28 | } -------------------------------------------------------------------------------- /HDUOJ/1587.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | typedef long long LL; 12 | using namespace std; 13 | 14 | int main() 15 | { 16 | int n,m,i; 17 | int a[10000]; 18 | while (cin>>n>>m) 19 | { 20 | for (i=0;i>a[i]; 23 | } 24 | sort(a,a+n); 25 | cout< 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | typedef long long LL; 12 | using namespace std; 13 | 14 | int main() 15 | { 16 | int t,n,a[100]; 17 | cin>>t; 18 | while(t--) 19 | { 20 | cin>>n; 21 | for(int i=0;i>a[i]; 23 | sort(a,a+n); 24 | cout<<(a[n-1]-a[0])*2< 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | typedef long long LL; 12 | using namespace std; 13 | 14 | int main() 15 | { 16 | int a[101],i,num,num1,rank,mark1,mark; 17 | while(cin>>num) 18 | { 19 | memset(a,0,sizeof(a)); 20 | while(cin>>num1>>mark1&&(num1!=0||mark1!=0)) 21 | { 22 | if(num1==num) 23 | mark=mark1; 24 | a[mark1]++; 25 | } 26 | for(i=100,rank=1;i>mark;i--) 27 | rank+=a[i]; 28 | cout< 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | typedef long long LL; 12 | using namespace std; 13 | 14 | int main() 15 | { 16 | int a,b; int sum; 17 | while(~scanf("%x %x",&a,&b)) 18 | { 19 | printf("%d\n",a+b); 20 | } 21 | return 0; 22 | 23 | } -------------------------------------------------------------------------------- /HDUOJ/1722.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | using namespace std; 4 | int main() 5 | { 6 | int a,b; 7 | while(cin>>a>>b) 8 | { 9 | int ans; 10 | ans=a+b-(__gcd(a,b)); 11 | cout< 2 | #include 3 | #include 4 | #include 5 | using namespace std; 6 | 7 | int n,f[3000+5]; 8 | int main() 9 | { 10 | while(~scanf("%d",&n)) 11 | { 12 | int i; 13 | for(i=0;if[i-1])count=1; 19 | else { count++; max = max>count? max:count;} 20 | } 21 | printf("%d\n",max); 22 | } 23 | return 0; 24 | } -------------------------------------------------------------------------------- /HDUOJ/1800.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lzyrapx/Competitive-Programming/6b0eea727f9a6444700a6966209397ac7011226f/HDUOJ/1800.cpp -------------------------------------------------------------------------------- /HDUOJ/1840.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | int main() 3 | { 4 | int t,a,b,c; 5 | scanf("%d",&t); 6 | while(t--) 7 | { 8 | scanf("%d%d%d",&a,&b,&c); 9 | if(a==0&&b==0&&c==0)printf("INF\n"); 10 | else if(a==0&&b==0&&c!=0)printf("0\n"); 11 | else if(a==0&&b!=0)printf("1\n"); 12 | else if(a!=0&&b*b-4*a*c>0)printf("2\n"); 13 | else if(a!=0&&b*b-4*a*c==0)printf("1\n"); 14 | else if(a!=0&&b*b-4*a*c<0)printf("0\n"); 15 | 16 | } 17 | return 0; 18 | } -------------------------------------------------------------------------------- /HDUOJ/1859.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | typedef long long LL; 12 | using namespace std; 13 | int main() 14 | { 15 | int x,y,minX,minY,maxX,maxY; 16 | while(scanf("%d %d",&x,&y),x||y) 17 | { 18 | minX=x,minY=y; 19 | maxX=x,maxY=y; 20 | while(scanf("%d %d",&x,&y),x||y) 21 | { 22 | minX=min(minX,x); 23 | minY=min(minY,y); 24 | maxX=max(maxX,x); 25 | maxY=max(maxY,y); 26 | } 27 | printf("%d %d %d %d\n",minX,minY,maxX,maxY); 28 | } 29 | return 0; 30 | } -------------------------------------------------------------------------------- /HDUOJ/1868.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | int main() 4 | { 5 | int n; 6 | while(cin>>n) 7 | { 8 | long long m=2*n,x; 9 | long long sq=(long long)sqrt(m); 10 | int ans=0; 11 | for(long long i=2;i<=sq;i++) 12 | { 13 | x=(long long)( n/1.0/i - (i-1)/2 ); 14 | if((x+x+i-1)*i==m) 15 | ans++; 16 | } 17 | cout< 2 | int main() 3 | { 4 | 5 | char a[1000]; 6 | while(~scanf("%s",&a)) 7 | { 8 | int n=0; 9 | for(int i=0; ;i++) 10 | { 11 | if(a[i]==')') n--; 12 | if(a[i]=='(') n++; 13 | if(a[i]=='B') break; 14 | } 15 | printf("%d\n",n); 16 | } 17 | return 0; 18 | } -------------------------------------------------------------------------------- /HDUOJ/1877.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | typedef long long LL; 12 | using namespace std; 13 | int main() 14 | { 15 | int m,a,b; 16 | int arr[10000]={0}; 17 | while(cin>>m>>a>>b) 18 | { 19 | int c=a+b; 20 | int i=0; 21 | if(c==0)printf("0\n"); 22 | else{ 23 | while(c>0) 24 | { 25 | arr[i++]=c%m; 26 | c=c/m; 27 | } 28 | for(int j=i-1;j>=0;--j) 29 | { 30 | cout< 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | typedef long long LL; 12 | using namespace std; 13 | int main() 14 | { 15 | int n;cin>>n; 16 | while(n--){ 17 | int a,b,t; cin>>a>>b>>t; 18 | if(t%a==t%b)cout<<"Both!"<t%b)cout<<"Xiangsanzi!"< 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | typedef long long LL; 12 | using namespace std; 13 | int main() 14 | { 15 | int t; 16 | cin>>t; 17 | while(t--) 18 | { 19 | LL n,s,d; 20 | cin>>n; 21 | s=n*n*n; 22 | d=(n+1)*(n+1)*(n+1); 23 | printf("%lld %lld\n",s,d); 24 | } 25 | return 0; 26 | } -------------------------------------------------------------------------------- /HDUOJ/1984.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | int main() 4 | { 5 | int n,m,i,j,c,k=0; 6 | char a[1001]={0}; 7 | scanf("%d",&n); 8 | while(n--) 9 | { 10 | k++; 11 | scanf("%d",&m); 12 | gets(a); 13 | j=strlen(a); 14 | for(i=m;i 2 | using namespace std; 3 | 4 | int main() 5 | { 6 | int t; 7 | int cas=1; 8 | char str[500]; 9 | int ans,dep; 10 | scanf("%d",&t); 11 | getchar(); 12 | while(t--) 13 | { 14 | gets(str); 15 | ans=0; 16 | dep=0; 17 | for(int i=0;str[i];i++) 18 | { 19 | if(str[i]=='[') 20 | dep++; 21 | else 22 | dep--; 23 | if(dep>ans) 24 | ans=dep; 25 | } 26 | int res=1; 27 | for(int i=0;i 2 | int dp[25] = {1,1,5,11} ; 3 | int main () 4 | { 5 | int T, i, cas = 1, n; 6 | for(i = 4 ; i <= 22 ; i++) 7 | dp[i] = dp[i-1]+dp[i-2]*5+dp[i-3]-dp[i-4] ; 8 | scanf ("%d", &T) ; 9 | while (T--) 10 | { 11 | scanf ("%d", &n) ; 12 | printf ("%d %d\n", cas++, dp[n]) ; 13 | } 14 | return 0 ; 15 | } -------------------------------------------------------------------------------- /HDUOJ/1994.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lzyrapx/Competitive-Programming/6b0eea727f9a6444700a6966209397ac7011226f/HDUOJ/1994.cpp -------------------------------------------------------------------------------- /HDUOJ/1998(Merzirac奇数幻方生成法构造).cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | //Merzirac奇数幻方生成法 4 | int main() 5 | { 6 | int n; 7 | int d[20][20]; 8 | int t; 9 | int i,j,k,stx,sty,x,y; 10 | scanf("%d",&t); 11 | while(t--) 12 | { 13 | scanf("%d",&n); 14 | stx=0;//行 15 | sty=(n+1)/2-1;//列 16 | for(k=1;k<=n*n;k++) 17 | { 18 | x=stx--; 19 | y=sty++; 20 | d[x][y]=k; 21 | 22 | if(k%n==0) 23 | { 24 | stx=stx+2; 25 | sty=sty-1; 26 | } 27 | if (stx<0) 28 | stx=n-1; 29 | if(sty>=n) 30 | sty=0; 31 | 32 | } 33 | 34 | for(i=0;i 2 | #include 3 | using namespace std; 4 | #define N 500010 5 | __int64 a[N]; 6 | int ans[1010]; 7 | //一个数 n与任何数的因子和都不相等,那么n就叫做不可摸数 8 | void init () 9 | { 10 | for (int i=1; i 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | typedef long long LL; 10 | using namespace std; 11 | int main() 12 | { 13 | double a,b,c,d; 14 | double m,n,ans; 15 | while(cin>>a>>b>>c>>d){ 16 | m=a-c; 17 | n=b-d; 18 | ans=sqrt((a-c)*(a-c)+(b-d)*(b-d)); 19 | printf("%.2lf\n",ans); 20 | } 21 | return 0; 22 | 23 | } 24 | 25 | -------------------------------------------------------------------------------- /HDUOJ/2002.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | typedef long long LL; 10 | using namespace std; 11 | #define PI 3.1415927 12 | int main() 13 | { 14 | double r; 15 | double ans; 16 | while(cin>>r){ 17 | ans=(4*PI*r*r*r)/3; 18 | printf("%.3lf\n",ans); 19 | } 20 | return 0; 21 | 22 | } 23 | 24 | -------------------------------------------------------------------------------- /HDUOJ/2003.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | typedef long long LL; 10 | using namespace std; 11 | 12 | int main() 13 | { 14 | double a,ans; 15 | while(cin>>a){ 16 | ans=fabs(a); 17 | printf("%.2lf\n",ans); 18 | } 19 | return 0; 20 | 21 | } 22 | 23 | -------------------------------------------------------------------------------- /HDUOJ/2004.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | typedef long long LL; 10 | using namespace std; 11 | 12 | int main() 13 | { 14 | int t; 15 | while(scanf("%d",&t)!=EOF) 16 | { 17 | if(t<0||t>100) 18 | { 19 | printf("Score is error!\n"); 20 | } 21 | else 22 | { 23 | t=t/10; 24 | switch(t) 25 | { 26 | case 10: 27 | case 9:printf("A\n");break; 28 | case 8:printf("B\n");break; 29 | case 7:printf("C\n");break; 30 | case 6:printf("D\n");break; 31 | default:printf("E\n");break; 32 | } 33 | } 34 | } 35 | 36 | return 0; 37 | 38 | } 39 | 40 | -------------------------------------------------------------------------------- /HDUOJ/2005.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | typedef long long LL; 10 | using namespace std; 11 | 12 | int main() 13 | { 14 | int y,m,d; 15 | while(~scanf("%d/%d/%d",&y,&m,&d)) 16 | { 17 | int k,leap; 18 | int day[2][13]={ 19 | {0,31,28,31,30,31,30,31,31,30,31,30,31}, 20 | {0,31,29,31,30,31,30,31,31,30,31,30,31} 21 | }; 22 | leap=(y%4==0&&y%100!=0||y%400==0); 23 | for(k=1;k 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | typedef long long LL; 10 | using namespace std; 11 | 12 | int main() 13 | { 14 | int n; 15 | int a[10001]={0}; 16 | while(cin>>n){ 17 | int sum=1; 18 | for(int i=0;i>a[i]; 20 | if(a[i]%2==1) 21 | sum=sum*a[i]; 22 | } 23 | printf("%d\n",sum); 24 | } 25 | 26 | return 0; 27 | 28 | } 29 | 30 | -------------------------------------------------------------------------------- /HDUOJ/2007.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | typedef long long LL; 10 | using namespace std; 11 | 12 | int main() 13 | { 14 | int m,n; 15 | while(cin>>m>>n) 16 | { 17 | if(m>=n) 18 | swap(m,n); 19 | long x=0,y=0; 20 | for(int i=m;i<=n;i++) 21 | { 22 | if(i%2==0) 23 | x+=i*i; 24 | else 25 | y+=i*i*i; 26 | } 27 | cout< 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | typedef long long LL; 10 | using namespace std; 11 | 12 | int main() 13 | { 14 | int n,i,a,b,c; 15 | double x; 16 | while(cin>>n){ 17 | if(n==0)break; 18 | a=b=c=0; 19 | for(i=0;i>x; 21 | if(x>0)c++; 22 | else if(x<0)a++; 23 | else b++; 24 | } 25 | printf("%d %d %d\n",a,b,c); 26 | } 27 | return 0; 28 | } -------------------------------------------------------------------------------- /HDUOJ/2009.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | typedef long long LL; 10 | using namespace std; 11 | 12 | int main() 13 | { 14 | int i; 15 | float s,n,m; 16 | while(scanf("%f %f",&n,&m)!=EOF) 17 | { 18 | s=0; 19 | for(i=0;i 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | typedef long long LL; 10 | using namespace std; 11 | 12 | int main() 13 | { 14 | int a,b,c,m,n,i=1,p=-1; 15 | double sum=0; 16 | cin>>m; 17 | while(m--) 18 | { 19 | i=1;p=-1; 20 | sum=0; 21 | cin>>n; 22 | while(n--) 23 | { 24 | p*=-1; 25 | sum+=(1.0/i)*p; 26 | i++; 27 | 28 | } 29 | //cout< 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | typedef long long LL; 10 | using namespace std; 11 | int f(int n){ 12 | if(n==1)return 1; 13 | else if(n==2)return 4; 14 | else return (f(n-1)+1)*2; 15 | } 16 | int main() 17 | { 18 | int n; 19 | int ans; 20 | while(cin>>n){ 21 | ans=f(n); 22 | printf("%d\n",ans); 23 | } 24 | return 0; 25 | } -------------------------------------------------------------------------------- /HDUOJ/2014.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lzyrapx/Competitive-Programming/6b0eea727f9a6444700a6966209397ac7011226f/HDUOJ/2014.cpp -------------------------------------------------------------------------------- /HDUOJ/2015.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | typedef long long LL; 11 | using namespace std; 12 | 13 | int main() 14 | { 15 | int i,a[102]={0},m,n,count=0,sum=0,flag=0; 16 | while(~scanf("%d%d",&n,&m)) 17 | { 18 | for(i=0;i 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | typedef long long LL; 11 | using namespace std; 12 | 13 | int main() 14 | { 15 | int T,len; 16 | cin>>T; 17 | while(T--){ 18 | string s; 19 | int sum=0; 20 | cin>>s; 21 | len=s.size(); 22 | for(int i=0;i='0'&&s[i]<='9') 24 | sum++; 25 | } 26 | printf("%d\n",sum); 27 | } 28 | return 0; 29 | } -------------------------------------------------------------------------------- /HDUOJ/2018.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | typedef long long LL; 11 | using namespace std; 12 | 13 | int main() 14 | { 15 | int n,i; 16 | int s[60]={0,1,2,3,4}; 17 | while(~scanf("%d",&n)&&n) 18 | { 19 | if(n>4) 20 | for(i=5;i<=n;i++) 21 | { 22 | s[i]=s[i-1]+s[i-3]; 23 | } 24 | printf("%d\n",s[n]); 25 | } 26 | return 0; 27 | } -------------------------------------------------------------------------------- /HDUOJ/2019.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | typedef long long LL; 11 | using namespace std; 12 | 13 | int main() 14 | { 15 | int n,m; 16 | while (cin>>n>>m){ 17 | if(m==0&&n==0)break; 18 | int a[101]; 19 | for (int i=0; i>a[i]; 21 | } 22 | a[n]=m; 23 | sort(a,a+n+1); 24 | for (int i=0; i0){ 26 | cout<<" "; 27 | } 28 | cout< 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | typedef long long LL; 11 | using namespace std; 12 | //int cmp(int x,int y){ 13 | // return x>y; 14 | //} 15 | int main() 16 | { 17 | int n,i,j,a[100],t; 18 | while((scanf("%d",&n)!=EOF),n) 19 | { 20 | for(i=0;i>a[i]; 22 | for(i=0;i 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | typedef long long LL; 11 | using namespace std; 12 | 13 | int main() 14 | { 15 | int n,m,i,j,x,y,a[100][100],max; 16 | while(cin>>n>>m) 17 | { 18 | max=0; 19 | for(i=1;i<=n;i++) 20 | { 21 | for(j=1;j<=m;j++) 22 | { 23 | cin>>a[i][j]; 24 | if(abs(a[i][j])>max) 25 | { 26 | max=abs(a[i][j]); 27 | x=i,y=j; 28 | } 29 | } 30 | } 31 | cout< 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | typedef long long LL; 11 | using namespace std; 12 | 13 | int main() 14 | { 15 | int n; 16 | cin>>n; 17 | getchar(); 18 | while(n--){ 19 | int a,b,c,x,y,z; 20 | cin>>a>>b>>c>>x>>y>>z; 21 | if(c+z>=60){ 22 | c=c+z-60; 23 | b=b+1; 24 | } 25 | else 26 | c=c+z; 27 | if(b+y>=60){ 28 | b=b+y-60; 29 | a=a+1; 30 | } 31 | else 32 | b=b+y; 33 | a=a+x; 34 | cout< 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | typedef long long LL; 11 | using namespace std; 12 | 13 | int main() 14 | { 15 | int n; 16 | double a,b,c; 17 | cin>>n; 18 | while(n--) 19 | { 20 | cin>>a>>b>>c; 21 | if(((a+b)>c)&&((a+c)>b)&&((b+c)>a)) 22 | cout<<"YES"< 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | typedef long long LL; 11 | using namespace std; 12 | int f(int n){ 13 | int ans=0; 14 | for(int i=1;i<=n/2;i++){ 15 | if(n%i==0){ 16 | ans+=i; 17 | } 18 | } 19 | //cout<>T; 27 | while(T--){ 28 | cin>>n>>m; 29 | if(n==f(m)){ 30 | if(m==f(n)) 31 | printf("YES\n"); 32 | } 33 | else printf("NO\n"); 34 | } 35 | return 0; 36 | } -------------------------------------------------------------------------------- /HDUOJ/2041.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | typedef long long LL; 12 | using namespace std; 13 | int main() 14 | { 15 | int N=0,M=0,i=0,sum=0; 16 | int a[41]={0}; 17 | scanf("%d",&N); 18 | a[1]=1; 19 | a[2]=1; 20 | for(i=3;i<=40;i++) 21 | { 22 | a[i]=a[i-1]+a[i-2]; 23 | } 24 | while(N--) 25 | { 26 | scanf("%d",&M); 27 | printf("%d\n",a[M]); 28 | } 29 | return 0; 30 | } -------------------------------------------------------------------------------- /HDUOJ/2042.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | typedef long long LL; 12 | using namespace std; 13 | int f(int n) 14 | { 15 | if(n==1)return 4; 16 | else return (f(n-1)-1)*2; 17 | } 18 | int main() 19 | { 20 | int t,n; 21 | cin>>t; 22 | while(t--) 23 | { 24 | cin>>n; 25 | int ans; 26 | ans=f(n); 27 | cout< 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | typedef long long LL; 12 | using namespace std; 13 | int main() 14 | { 15 | long long int f[55]; 16 | f[1]=1; 17 | f[2]=2; 18 | for(int i=3;i<55;i++) 19 | { 20 | f[i]=f[i-1]+f[i-2]; 21 | } 22 | int t; 23 | scanf("%d",&t); 24 | while(t--) 25 | { 26 | int n,m; 27 | scanf("%d%d",&n,&m); 28 | printf("%lld\n",f[m-n]); 29 | } 30 | return 0; 31 | } -------------------------------------------------------------------------------- /HDUOJ/2045.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | long long a[55]; 4 | int main() 5 | { 6 | long long n; 7 | a[0]=0; 8 | a[1]=3,a[2]=6,a[3]=6; 9 | for(int i=4;i<=55;i++){ 10 | a[i]=a[i-1]+2*a[i-2]; 11 | } 12 | while(cin>>n) 13 | { 14 | cout< 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | typedef long long LL; 12 | using namespace std; 13 | int main() 14 | { 15 | long long int i,a[52],n; 16 | a[1]=1;a[2]=2; 17 | for(i=3;i<51;i++) 18 | a[i]=a[i-1]+a[i-2]; 19 | while(~scanf("%d",&n)) 20 | { 21 | printf("%lld\n",a[n]); 22 | } 23 | return 0; 24 | } 25 | 26 | -------------------------------------------------------------------------------- /HDUOJ/2047.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | typedef long long LL; 11 | using namespace std; 12 | #define MAX 40 13 | 14 | int main() 15 | { 16 | LL ans[MAX+1]; 17 | int i;ans[1]=3;ans[2]=8; 18 | for(i=3;i<=MAX;i++) 19 | { 20 | ans[i]=2*(ans[i-1]+ans[i-2]); 21 | while(cin>>i) 22 | { 23 | printf("%lld\n",ans[i]); 24 | } 25 | } 26 | return 0; 27 | } -------------------------------------------------------------------------------- /HDUOJ/2048.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lzyrapx/Competitive-Programming/6b0eea727f9a6444700a6966209397ac7011226f/HDUOJ/2048.cpp -------------------------------------------------------------------------------- /HDUOJ/2049.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | typedef long long LL; 12 | using namespace std; 13 | 14 | int main() 15 | { 16 | LL n,m,c,i; 17 | scanf("%d",&c); 18 | while(c--) 19 | { 20 | LL a[31]; 21 | a[0]=a[1]=0;a[2]=1,a[3]=2; 22 | for(i=4;i<30;i++) 23 | a[i]=(i-1)*(a[i-1]+a[i-2]); 24 | LL sum1,sum2; 25 | sum1=sum2=1; 26 | scanf("%lld%lld",&n,&m); 27 | for(i=n;i>n-m;i--) 28 | sum1*=i; 29 | for(i=2;i<=m;i++) 30 | sum2*=i; 31 | printf("%lld\n",sum1/sum2*a[m]); 32 | 33 | } 34 | return 0; 35 | } -------------------------------------------------------------------------------- /HDUOJ/2051.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | typedef long long LL; 11 | using namespace std; 12 | int main() 13 | { 14 | 15 | int i,n,m,j,a[100]={0}; 16 | while(scanf("%d",&n)!=EOF) 17 | { 18 | i=0; 19 | while(n) 20 | { 21 | a[i]=n%2; 22 | i++; 23 | n/=2; 24 | } 25 | 26 | for(int j=i-1;j>=0;j--) 27 | printf("%d",a[j]); 28 | printf("\n"); 29 | } 30 | return 0; 31 | } -------------------------------------------------------------------------------- /HDUOJ/2052.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | int main() 4 | { 5 | int n,m; 6 | while(cin>>n>>m) 7 | { 8 | int i,j; 9 | cout<<"+"; 10 | for(i=1;i<=n;i++) 11 | cout<<"-"; 12 | cout<<"+"< 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | typedef long long LL; 11 | using namespace std; 12 | int main() 13 | { 14 | 15 | int n,k,i; 16 | while(scanf("%d",&n)!=EOF) 17 | { 18 | k=0; 19 | for(i=1;i<=n;i++) 20 | { 21 | if(n%i==0) 22 | k++; 23 | } 24 | if(k%2==0) 25 | printf("0\n"); 26 | else 27 | printf("1\n"); 28 | } 29 | return 0; 30 | } -------------------------------------------------------------------------------- /HDUOJ/2054.java: -------------------------------------------------------------------------------- 1 | import java.math.BigDecimal; 2 | import java.util.Scanner; 3 | public class Main { 4 | public static void main(String[] args) { 5 | Scanner cin = new Scanner(System.in); 6 | while(cin.hasNext()) 7 | { 8 | BigDecimal num1=cin.nextBigDecimal(); 9 | BigDecimal num2=cin.nextBigDecimal(); 10 | String str1=num1.stripTrailingZeros().toPlainString(); 11 | String str2=num2.stripTrailingZeros().toPlainString(); 12 | if(str1.equals(str2)) 13 | System.out.println("YES"); 14 | else System.out.println("NO"); 15 | } 16 | } 17 | } -------------------------------------------------------------------------------- /HDUOJ/2055.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | typedef long long LL; 11 | using namespace std; 12 | int main() 13 | { 14 | 15 | int n,y,res; 16 | char x; 17 | cin>>n; 18 | while(n--){ 19 | cin>>x>>y; 20 | y=(x>96)?96-x+y:x-64+y; //A:65 a:97 21 | cout< 2 | using namespace std; 3 | int main() 4 | { 5 | long long m ,n; 6 | while(cin>>n>>m,n||m) 7 | { 8 | long long a,k; 9 | for(k=(int)sqrt(2*m);k>0;k--) //因为1+2+。。。+(2*m)^1/2>m;所一和为m的元素个数应该小于等于(2*m)^1/2; 10 | { 11 | a=m/k-(k-1)/2; //假设从a开始一直加到a+k-1,一共k个元素和为m,可以计算出a; 12 | if((2*a-1+k)*k==2*m) //(2*m)^1/2可能不是整数,判断是有必要的; 13 | cout<<"["< 2 | using namespace std; 3 | 4 | int main() 5 | { 6 | int n; 7 | long long step[36] = { 0,1 }; 8 | for (int i = 2; i < 36; i++) 9 | step[i] = 3 * step[i - 1] + 1; 10 | while ((cin >> n) && n) 11 | { 12 | cout << 2 * step[n] << endl; 13 | } 14 | return 0; 15 | } -------------------------------------------------------------------------------- /HDUOJ/2065.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #define LL long long 3 | #define mod 100 4 | using namespace std; 5 | int q_mod(int a,LL b) 6 | { 7 | int ans=1; 8 | while(b){ 9 | if(b&1) 10 | ans=(ans*a)%mod; 11 | a=(a*a)%mod; 12 | b>>=1; 13 | } 14 | return ans; 15 | } 16 | int main() 17 | { 18 | int t; 19 | while(~scanf("%d",&t)&&t){ 20 | int cas=0; 21 | LL n; 22 | while(t--){ 23 | scanf("%I64d",&n); 24 | printf("Case %d: %d\n",++cas,( q_mod(4,n-1)+q_mod(2,n-1) ) % mod); 25 | } 26 | printf("\n"); 27 | } 28 | return 0; 29 | } 30 | -------------------------------------------------------------------------------- /HDUOJ/2067.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | typedef long long ll; 3 | int main() 4 | { 5 | ll n,dp[36][36],cas=1;; 6 | dp[0][0]=0; 7 | dp[1][1]=1; 8 | for(int i=1;i<=35;i++) 9 | { 10 | dp[0][i]=1; 11 | } 12 | for(int i=1;i<=35;i++) 13 | { 14 | dp[i][i]=dp[i-1][i]; 15 | for(int j=i+1;j<=35;j++) 16 | { 17 | dp[i][j]=dp[i][j-1]+dp[i-1][j]; 18 | } 19 | } 20 | while(~scanf("%I64d",&n)&&n!=-1) 21 | { 22 | printf("%I64d %I64d %I64d\n",cas++, n, 2*dp[n][n]); 23 | } 24 | return 0; 25 | } -------------------------------------------------------------------------------- /HDUOJ/2068.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | int C(int n,int m) 3 | { 4 | long long a=1,b=1,i; 5 | for(i=1;i<=m;i++,n--) 6 | { 7 | b*=i; 8 | a*=n; 9 | } 10 | return a/b; 11 | } 12 | int main() 13 | { 14 | int i,n; 15 | long long ans,a[13]; 16 | a[0]=1;a[1]=0;a[2]=1;a[3]=2; 17 | for(i=4;i<=12;i++) 18 | a[i]=(i-1)*(a[i-1]+a[i-2]); 19 | // for(int n=1;n<=25;n++) 20 | // { 21 | while(scanf("%d",&n)!=EOF&&n!=0) 22 | { 23 | ans=0; 24 | for(i=0;i<=n/2;i++) 25 | ans+=a[i]*C(n,i); 26 | printf("%I64d\n",ans); 27 | } 28 | // } 29 | return 0; 30 | } -------------------------------------------------------------------------------- /HDUOJ/2070.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | int main() 3 | { 4 | long long s[51]={0,1}; 5 | int i; 6 | for(i=2;i<=50;i++) 7 | s[i]=s[i-2]+s[i-1]; 8 | int n; 9 | while(scanf("%d",&n)&&(n!=-1)) 10 | printf("%I64d\n",s[n]); 11 | return 0; 12 | 13 | } -------------------------------------------------------------------------------- /HDUOJ/2071.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | typedef long long LL; 11 | using namespace std; 12 | int main() 13 | { 14 | 15 | int n; 16 | cin>>n; 17 | while(n--){ 18 | int m,i; 19 | double h,s; 20 | double maxn=0.00; 21 | cin>>m; 22 | for(i=0;i>h; 25 | maxn=max(maxn,h); 26 | } 27 | printf("%.2lf\n",maxn); 28 | } 29 | return 0; 30 | } -------------------------------------------------------------------------------- /HDUOJ/2073.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lzyrapx/Competitive-Programming/6b0eea727f9a6444700a6966209397ac7011226f/HDUOJ/2073.cpp -------------------------------------------------------------------------------- /HDUOJ/2075.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | int main() 4 | { 5 | int n; 6 | cin>>n; 7 | while(n--){ 8 | long a,b; 9 | cin>>a>>b; 10 | if(a%b==0) 11 | cout<<"YES"< 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | typedef long long LL; 11 | using namespace std; 12 | 13 | int main() { 14 | int h,m,s; 15 | int t; 16 | double n1,n2,n3; 17 | int ans; 18 | cin>>t; 19 | while(t--) 20 | { 21 | cin>>h>>m>>s; 22 | n1=h/12.0+m/60.0/12.0+s/60.0/60.0/12.0; 23 | n2=m/60.0+s/60.0/60.0; 24 | n3=fabs(n1-n2)*360; 25 | while(n3>=360.0){ 26 | n3=n3-360.0; 27 | } 28 | while(n3>=180.0) 29 | { 30 | n3=360.0-n3; 31 | } 32 | ans=n3; 33 | cout< 2 | #include 3 | #include 4 | #include 5 | using namespace std; 6 | int main() 7 | { 8 | int i,j,k; 9 | int t,n; 10 | __int64 m; 11 | cin>>t; 12 | while(t--) 13 | { 14 | cin>>n; 15 | m=pow(3,n-1)+1; 16 | printf("%I64d\n",m); 17 | } 18 | return 0; 19 | } -------------------------------------------------------------------------------- /HDUOJ/2078.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | typedef long long LL; 11 | using namespace std; 12 | 13 | int main() { 14 | int t,m,n,i; 15 | int a[50]; 16 | scanf("%d",&t); 17 | while(t--) 18 | { 19 | scanf("%d%d",&n,&m); 20 | for(i=0;i 3 | #include 4 | #include 5 | using namespace std; 6 | struct zhi 7 | { 8 | double x,y; 9 | }; 10 | double dist(zhi a,zhi b) 11 | { 12 | return sqrt((a.x-b.x)*(a.x-b.x)+(a.y-b.y)*(a.y-b.y)); 13 | } 14 | double dist1(zhi a) 15 | { 16 | return sqrt((a.x)*(a.x)+(a.y)*(a.y)); 17 | } 18 | int main() 19 | { 20 | int t; 21 | zhi a,b; 22 | scanf("%d",&t); 23 | while(t--) 24 | { 25 | cin>>a.x>>a.y>>b.x>>b.y; 26 | double d1=dist1(a); 27 | double d2=dist1(b); 28 | double d3=dist(a,b); 29 | //cout< 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | typedef long long LL; 11 | using namespace std; 12 | 13 | int main() { 14 | 15 | int n; 16 | int i; 17 | char m[12]; 18 | scanf("%d",&n); 19 | while(n--) 20 | { 21 | scanf("%s",m); 22 | printf("6%s\n",m+6); 23 | 24 | } 25 | return 0; 26 | } -------------------------------------------------------------------------------- /HDUOJ/2083.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | using namespace std; 5 | int main() 6 | { 7 | int k,m,n,i,a[10005]; 8 | int s; 9 | scanf("%d",&m); 10 | while(m--) 11 | { 12 | s=0; 13 | scanf("%d",&n); 14 | for(i=0;i 2 | using namespace std; 3 | int dp[100][100]; 4 | int main() 5 | { 6 | int n,m; 7 | while(scanf("%d",&n)!=EOF) 8 | { 9 | while(n--) 10 | { 11 | scanf("%d",&m); 12 | for(int i=0;i=0;i--) 17 | { 18 | for(int j=0;j<=i;j++) 19 | dp[i][j]=max(dp[i][j]+dp[i+1][j],dp[i][j]+dp[i+1][j+1]); 20 | } 21 | printf("%d\n",dp[0][0]); 22 | } 23 | } 24 | return 0; 25 | 26 | } -------------------------------------------------------------------------------- /HDUOJ/2085.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | int dp[100][100]; 4 | int main() 5 | { 6 | 7 | int n,i; 8 | long long int a,b,c; 9 | while(scanf("%d",&n)!=EOF&&n!=-1) 10 | { 11 | a=1;b=0; 12 | for(i=0;i 2 | #include 3 | int main() 4 | { 5 | double c[3005]={0},a0,an1; 6 | int n; 7 | int i,j; 8 | while(~scanf("%d",&n)) 9 | { 10 | scanf("%lf%lf",&a0,&an1); 11 | for(i=1;i<=n;i++) 12 | scanf("%lf",&c[i]); 13 | double sum=0; 14 | sum+=n*a0+an1; 15 | for(i=1;i<=n;i++) 16 | { 17 | sum-=2*(n-i+1)*c[i]; 18 | } 19 | sum/=n+1; 20 | printf("%.2lf\n",sum); 21 | } 22 | return 0; 23 | } -------------------------------------------------------------------------------- /HDUOJ/2087.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | int dp[100][100]; 4 | int main() 5 | { 6 | 7 | char a[1001],b[1001]; 8 | while(scanf("%s",a)&&a[0]!='#') 9 | { 10 | scanf("%s",b); 11 | int len1,len2; 12 | len1=strlen(a); 13 | len2=strlen(b); 14 | int flag=0,num=0; 15 | for(int i=0;i 2 | using namespace std; 3 | 4 | int main() 5 | { 6 | int n; 7 | int a[51]; 8 | int mid; 9 | long long sum; 10 | bool first = true; 11 | while(cin >> n && n) 12 | { 13 | sum = 0; 14 | if(!first) 15 | cout << endl; 16 | for(int i = 0; i < n; i++) 17 | { 18 | cin >> a[i]; 19 | sum += a[i]; 20 | } 21 | int move = 0; 22 | mid = sum / n; 23 | for(int i = 0; i < n; i++) 24 | { 25 | if(a[i] > mid) 26 | move += a[i] - mid; 27 | } 28 | cout << move << endl; 29 | first = false; 30 | } 31 | return 0; 32 | } -------------------------------------------------------------------------------- /HDUOJ/2089(数位dp).cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lzyrapx/Competitive-Programming/6b0eea727f9a6444700a6966209397ac7011226f/HDUOJ/2089(数位dp).cpp -------------------------------------------------------------------------------- /HDUOJ/2090.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | typedef long long LL; 12 | using namespace std; 13 | int main() 14 | { 15 | char str[20]; 16 | double m,n,s=0; 17 | while(scanf("%s%lf%lf",str,&m,&n)!=EOF) 18 | { 19 | s+=m*n; 20 | } 21 | printf("%.1lf\n",s); 22 | return 0; 23 | } -------------------------------------------------------------------------------- /HDUOJ/2091.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | int main() 3 | { 4 | char c; 5 | int n,t=1; 6 | while(scanf("%c%d",&c,&n)&&c!='@') 7 | { 8 | if(t==0)printf("\n"); 9 | t=0; 10 | for(int i=1;i<=n;i++) 11 | { 12 | for(int j=1;j<=(n+i-1);j++) 13 | { 14 | if(j==n-i+1&&i!=n) 15 | printf("%c",c); 16 | else if(j==(n+i-1)&&i!=n) 17 | printf("%c",c); 18 | else if(i==n) 19 | printf("%c",c); 20 | else 21 | printf(" "); 22 | } 23 | printf("\n"); 24 | } 25 | getchar(); 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /HDUOJ/2092.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lzyrapx/Competitive-Programming/6b0eea727f9a6444700a6966209397ac7011226f/HDUOJ/2092.cpp -------------------------------------------------------------------------------- /HDUOJ/2094.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | int main() 5 | { 6 | int n; 7 | int in[1200],ans; 8 | string a,b; 9 | map mp; 10 | while(~scanf("%d",&n)&&n) 11 | { 12 | int y=1; 13 | memset(in,0,sizeof(in)); 14 | mp.clear(); 15 | for(int i=1;i<=n;i++) 16 | { 17 | cin>>a; 18 | if(mp[a]==0)mp[a]=y++; 19 | cin>>b; 20 | if(mp[b]==0)mp[b]=y++; 21 | in[mp[b]]++; 22 | } 23 | ans=0; 24 | for(int i=1;i 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | typedef long long LL; 12 | using namespace std; 13 | 14 | int main() 15 | { 16 | LL t; LL a,b; LL ans; 17 | cin>>t; 18 | while(t--) 19 | { 20 | scanf("%lld %lld",&a,&b); 21 | ans=(LL)(a+b)%100; 22 | printf("%lld\n",ans); 23 | } 24 | return 0; 25 | } -------------------------------------------------------------------------------- /HDUOJ/2097.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lzyrapx/Competitive-Programming/6b0eea727f9a6444700a6966209397ac7011226f/HDUOJ/2097.cpp -------------------------------------------------------------------------------- /HDUOJ/2099.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | #include 12 | #include 13 | #include 14 | typedef long long LL; 15 | using namespace std; 16 | int main() 17 | { 18 | int a,b; 19 | while(cin>>a>>b&&a!=0&&b!=0) 20 | { 21 | int v=0,k=0; 22 | for(v=0;v<=99;v++) 23 | if((a*100+v)%b==0) 24 | { 25 | if(k==1) 26 | printf(" "); 27 | k=1; 28 | if(v<10) 29 | printf("0%d",v); 30 | else 31 | printf("%d",v); 32 | } 33 | printf("\n"); 34 | } 35 | return 0; 36 | } -------------------------------------------------------------------------------- /HDUOJ/2101.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | int main() 4 | { 5 | int a, b; 6 | while(cin >> a >> b) 7 | cout << (((a+b) % 86) ? "no" : "yes" ) << endl; 8 | 9 | return 0; 10 | } -------------------------------------------------------------------------------- /HDUOJ/2102.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lzyrapx/Competitive-Programming/6b0eea727f9a6444700a6966209397ac7011226f/HDUOJ/2102.cpp -------------------------------------------------------------------------------- /HDUOJ/2103.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lzyrapx/Competitive-Programming/6b0eea727f9a6444700a6966209397ac7011226f/HDUOJ/2103.cpp -------------------------------------------------------------------------------- /HDUOJ/2104.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | int gcd(int a,int b) 3 | { 4 | return b==0?a:gcd(b,a%b); 5 | } 6 | int main() 7 | 8 | { 9 | int n,m; 10 | while(scanf("%d%d",&n,&m),n!=-1&&m!=-1) 11 | { 12 | if(gcd(n,m)==1) puts("YES"); 13 | else puts("POOR Haha"); 14 | } 15 | return 0; 16 | }//求n m是否互质 -------------------------------------------------------------------------------- /HDUOJ/2105.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | using namespace std; 4 | int main() 5 | { 6 | int n; 7 | while(cin>>n&&n) 8 | { 9 | while(n--) 10 | { 11 | double x1,x2,x3,y1,y2,y3; 12 | cin>>x1>>y1>>x2>>y2>>x3>>y3; 13 | printf("%.1lf %.1lf\n",1.0*(x1+x2+x3)/3,1.0*(y1+y2+y3)/3); 14 | } 15 | } 16 | return 0; 17 | } 18 | -------------------------------------------------------------------------------- /HDUOJ/2107.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | int main() 3 | { 4 | int t,a,max; 5 | while(scanf("%d",&t)!=EOF &&t!=0) 6 | { 7 | max=0; 8 | while(t--) 9 | { 10 | scanf("%d",&a); 11 | if(a>max) 12 | { 13 | max=a; 14 | } 15 | } 16 | printf("%d\n",max); 17 | } 18 | return 0; 19 | } -------------------------------------------------------------------------------- /HDUOJ/2108.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lzyrapx/Competitive-Programming/6b0eea727f9a6444700a6966209397ac7011226f/HDUOJ/2108.cpp -------------------------------------------------------------------------------- /HDUOJ/2113.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lzyrapx/Competitive-Programming/6b0eea727f9a6444700a6966209397ac7011226f/HDUOJ/2113.cpp -------------------------------------------------------------------------------- /HDUOJ/2114.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lzyrapx/Competitive-Programming/6b0eea727f9a6444700a6966209397ac7011226f/HDUOJ/2114.cpp -------------------------------------------------------------------------------- /HDUOJ/2115.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lzyrapx/Competitive-Programming/6b0eea727f9a6444700a6966209397ac7011226f/HDUOJ/2115.cpp -------------------------------------------------------------------------------- /HDUOJ/2116.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | using namespace std; 4 | long long a,b,m,n,Max,Min=0; 5 | void solve(int n) 6 | { 7 | long long ans=1; 8 | for(int i=1;i=0&&b<=0)||(a<=0&&b>=0)) printf("WaHaHa\n"); 18 | if(a>0&&b>0) 19 | { 20 | if(a>Max-b) printf("Yes\n"); 21 | else printf("WaHaHa\n"); 22 | } 23 | if(a<0&&b<0) 24 | { 25 | if(a 2 | int main() 3 | { 4 | int n,m,i,t,x; 5 | int s; 6 | while(scanf("%d%d",&n,&m)!=EOF) 7 | { 8 | s=1; 9 | while(m--) 10 | { 11 | s=s*10; 12 | t=s/n; 13 | s=s%n; 14 | } 15 | printf("%d\n",t%10); 16 | } 17 | return 0; 18 | } -------------------------------------------------------------------------------- /HDUOJ/2123.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | int main() 3 | { 4 | int n,i,j,a; 5 | scanf("%d",&n); 6 | while(n--) 7 | { 8 | scanf("%d",&a); 9 | for(i=1;i<=a;i++) 10 | { 11 | for(j=1;j 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | #include 12 | #include 13 | #include 14 | #include 15 | typedef long long LL; 16 | using namespace std; 17 | 18 | LL a[100005],i,n,m,j,k,l; 19 | int main() 20 | { 21 | a[1]=1;a[2]=3; 22 | for(i=3;i<100002;i++) 23 | { 24 | if(i%3==0) 25 | a[i]=a[i-1]+i*i*i; 26 | else 27 | a[i]=a[i-1]+i; 28 | } 29 | while(scanf("%lld",&n)&&n>=0) 30 | { 31 | printf("%lld\n",a[n]); 32 | } 33 | return 0; 34 | } -------------------------------------------------------------------------------- /HDUOJ/2134.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | using namespace std; 5 | const double PI=3.14; 6 | int main() 7 | { 8 | int R; 9 | double S; 10 | double A,B; 11 | while(cin>>R) 12 | { 13 | if(R==0) 14 | break; 15 | S=PI*R*R; 16 | S=S/3; 17 | A=sqrt(S/PI); 18 | B=sqrt((2*S)/PI); 19 | printf("%.3lf %.3lf\n",A,B); 20 | } 21 | return 0; 22 | } -------------------------------------------------------------------------------- /HDUOJ/2135.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lzyrapx/Competitive-Programming/6b0eea727f9a6444700a6966209397ac7011226f/HDUOJ/2135.cpp -------------------------------------------------------------------------------- /HDUOJ/2136.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lzyrapx/Competitive-Programming/6b0eea727f9a6444700a6966209397ac7011226f/HDUOJ/2136.cpp -------------------------------------------------------------------------------- /HDUOJ/2137.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lzyrapx/Competitive-Programming/6b0eea727f9a6444700a6966209397ac7011226f/HDUOJ/2137.cpp -------------------------------------------------------------------------------- /HDUOJ/2139.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | #include 12 | #include 13 | #include 14 | typedef long long LL; 15 | using namespace std; 16 | const int maxn=3000; 17 | LL s[maxn]; 18 | int main() 19 | { 20 | LL n,m,i; 21 | s[1]=1; 22 | for(i=3;i<=maxn;i+=2) 23 | { 24 | s[i]=s[i-2]+i*i; 25 | } 26 | while(scanf("%lld",&n)!=EOF) 27 | { 28 | printf("%lld\n",s[n]); 29 | } 30 | return 0; 31 | } 32 | -------------------------------------------------------------------------------- /HDUOJ/2143.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lzyrapx/Competitive-Programming/6b0eea727f9a6444700a6966209397ac7011226f/HDUOJ/2143.cpp -------------------------------------------------------------------------------- /HDUOJ/2156.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lzyrapx/Competitive-Programming/6b0eea727f9a6444700a6966209397ac7011226f/HDUOJ/2156.cpp -------------------------------------------------------------------------------- /HDUOJ/2161.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | using namespace std; 4 | int main() 5 | { 6 | int n,m=1,i,j; 7 | int prime(int x); 8 | while(cin>>n,n>0) 9 | { 10 | if(n==1||n==2) 11 | { 12 | cout< 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | #include 12 | #include 13 | typedef long long LL; 14 | using namespace std; 15 | const int maxn=100; 16 | 17 | int main() 18 | { 19 | int n,k=1; 20 | while((cin>>n)&&n>0) 21 | { 22 | int sum=0,x; 23 | for(int i=0;i>x; 26 | sum+=x; 27 | } 28 | cout<<"Sum of #"< 2 | using namespace std; 3 | long long dfs(long long n,long long m) 4 | { 5 | if(n==1&&m==1) return 1; 6 | long long mid=pow(2,n-1); 7 | if(m==mid) return n; 8 | else if(m>mid) return dfs(n-1,m-mid); 9 | else return dfs(n-1,m); 10 | } 11 | int main() 12 | { 13 | long long n,m; 14 | while(cin>>n>>m) 15 | { 16 | if(n==0&&m==0) break; 17 | cout< 2 | #include 3 | using namespace std; 4 | int main() 5 | { 6 | int n,m,p; 7 | cin>>n; 8 | while(n--) 9 | { 10 | cin>>m; 11 | p=pow(2,m)-1; 12 | 13 | cout< 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | typedef long long LL; 12 | using namespace std; 13 | int main() 14 | { 15 | double n, m; 16 | while (scanf("%lf%lf", &n, &m)!=EOF) { 17 | printf("%.2lf\n", 1/n); 18 | } 19 | return 0; 20 | } -------------------------------------------------------------------------------- /HDUOJ/2212.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | int f(int n){ 4 | int i,k=1; 5 | for(i=1;i<=n;i++) 6 | k*=i; 7 | return k; 8 | } 9 | int main() 10 | { 11 | int i,a,b,s; 12 | for(i=1;i<50000;i++){ 13 | a=i; 14 | s=0; 15 | while(a!=0){ 16 | b=a%10; 17 | s+=f(b); 18 | a/=10; 19 | } 20 | if(s==i) 21 | cout< 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | #include 12 | #include 13 | #include 14 | #include 15 | using namespace std; 16 | 17 | int main() 18 | { 19 | int n,m,i,a[11],sum; 20 | scanf("%d",&n); 21 | while(n--) 22 | { 23 | sum=0; 24 | scanf("%d",&m); 25 | for(i=1;i<=m;i++) 26 | { 27 | scanf("%d",&a[i]); 28 | sum+=a[i]; 29 | } 30 | printf("%d\n",sum-m+1); 31 | } 32 | return 0; 33 | } -------------------------------------------------------------------------------- /HDUOJ/2309.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | using namespace std; 4 | 5 | int main() 6 | { 7 | int n,s,a[101]; 8 | while((cin>>n)&&n) 9 | { 10 | s=0; 11 | for(int i=0;i>a[i]; 13 | sort(a,a+n); 14 | for(int i=1;i 2 | #include 3 | int main() 4 | { 5 | int n,c,r,m; 6 | scanf("%d",&n); 7 | while(n--) 8 | { 9 | scanf("%d%d%d",&c,&r,&m); 10 | if(r-m>c) 11 | printf("advertise\n"); 12 | else if(r-m==c) 13 | printf("does not matter\n"); 14 | else 15 | printf("do not advertise\n"); 16 | } 17 | return 0; 18 | } -------------------------------------------------------------------------------- /HDUOJ/2368(水题).cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | int main() 5 | { 6 | double r,w,h; 7 | int cas=0; 8 | while(cin>>r>>w>>h) 9 | { 10 | if(r==0)break; 11 | cas++; 12 | if(sqrt(w*w+h*h)<=2*r) 13 | { 14 | printf("Pizza %d fits on the table.\n",cas); 15 | } 16 | else 17 | { 18 | printf("Pizza %d does not fit on the table.\n",cas); 19 | } 20 | } 21 | return 0; 22 | } -------------------------------------------------------------------------------- /HDUOJ/2370(模拟).cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | int f[34],vis[34]; 4 | void init() 5 | { 6 | f[1] = 1;f[2] = 2; 7 | for(int i=3;i<=30;i++){ 8 | f[i] = f[i-1] + f[i-2]; 9 | } 10 | } 11 | int main() 12 | { 13 | int n,m; 14 | cin>>n; 15 | init(); 16 | while(n--) 17 | { 18 | cin>>m; 19 | memset(vis,0,sizeof(vis)); 20 | for(int i=29;i>=1;--i) 21 | { 22 | if(m<=0)break; 23 | if(f[i]<=m) 24 | { 25 | m-=f[i]; 26 | vis[i] = 1; 27 | } 28 | } 29 | int ans = 0; 30 | for(int i=2;i<=29;i++){ 31 | ans += vis[i]*f[i-1]; 32 | } 33 | cout< 2 | using namespace std; 3 | long long ans = 0; 4 | long long a[1234]; 5 | int main() 6 | { 7 | int n; 8 | while(cin>>n) 9 | { 10 | ans = 0; 11 | if(n==0)break; 12 | for(int i=1;i<=n;i++){ 13 | cin>>a[i]; 14 | } 15 | for(int i=n;i>0;--i){ 16 | 17 | ans+=a[i]; 18 | for(int j=i-1;j>0;--j) 19 | { 20 | a[j]+=a[i]; 21 | } 22 | } 23 | cout< 2 | int main() 3 | { 4 | int i,n,a,b,c; 5 | scanf("%d",&n); 6 | for(i=1;i<=n;i++) 7 | { 8 | scanf("%d%d%d",&a,&b,&c); 9 | if(a*a==b*b+c*c||b*b==a*a+c*c||c*c==a*a+b*b) 10 | printf("Scenario #%d:\nyes\n\n",i); 11 | else 12 | printf("Scenario #%d:\nno\n\n",i); 13 | } 14 | return 0; 15 | } -------------------------------------------------------------------------------- /HDUOJ/2401.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lzyrapx/Competitive-Programming/6b0eea727f9a6444700a6966209397ac7011226f/HDUOJ/2401.cpp -------------------------------------------------------------------------------- /HDUOJ/2438.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lzyrapx/Competitive-Programming/6b0eea727f9a6444700a6966209397ac7011226f/HDUOJ/2438.cpp -------------------------------------------------------------------------------- /HDUOJ/2500.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | typedef long long LL; 12 | using namespace std; 13 | int main() 14 | { 15 | int n; 16 | cin>>n; 17 | while(n--){ 18 | int m,i,j; 19 | cin>>m; 20 | char s[4]="HDU"; 21 | for(i=1;i<=3*m;i++){ 22 | for(j=1;j<=m;j++) 23 | cout< 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | #include 12 | #include 13 | typedef long long LL; 14 | using namespace std; 15 | const int maxn=100; 16 | 17 | int main() 18 | { 19 | 20 | int a,b,c,d,e,f,m,flag; 21 | cin>>m; 22 | while(m--) 23 | { 24 | flag=0; 25 | cin>>a>>b>>c>>d; 26 | f=b*d; 27 | e=a*d+b*c; 28 | while(flag!=1) 29 | { 30 | flag=__gcd(e,f); 31 | e/=flag; 32 | f/=flag; 33 | } 34 | printf("%d %d\n",e,f); 35 | } 36 | return 0; 37 | } -------------------------------------------------------------------------------- /HDUOJ/2504.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lzyrapx/Competitive-Programming/6b0eea727f9a6444700a6966209397ac7011226f/HDUOJ/2504.cpp -------------------------------------------------------------------------------- /HDUOJ/2511(汉诺塔).cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | //从from借助 mid 移到 to 4 | void solve(int l,int r,long long m,int from,int to,int mid) 5 | { 6 | long long num = (1LL<<(r-l))-1; 7 | if(m<=num)//从from柱子以mid为中介放到to 8 | { 9 | solve(l,r-1,m,from,mid,to); 10 | } 11 | else if(m==num+1){ 12 | printf("%d %d %d\n",r,from,to); 13 | } 14 | else //把最下面的碟子放到to上 15 | { 16 | solve(l,r-1,m-1-num,mid,to,from); 17 | } 18 | } 19 | int main() 20 | { 21 | int t,n; 22 | long long m; 23 | cin>>t; 24 | while(t--) 25 | { 26 | cin>>n>>m;// n 个盘子,第 m 次移动 27 | solve(1,n,m,1,3,2); 28 | } 29 | return 0; 30 | } -------------------------------------------------------------------------------- /HDUOJ/2519.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | #include 12 | #include 13 | typedef long long LL; 14 | using namespace std; 15 | const int maxn=100; 16 | 17 | int main() 18 | { 19 | int t,m,n,i,j; 20 | double a,b; 21 | cin>>t; 22 | while(t--) 23 | { 24 | a=1; b=1; 25 | cin>>n>>m; 26 | for(i=1;i<=m;i++) 27 | a=a*i; //A(3,3) 28 | for(j=n,i=m;i>0;--j,--i) 29 | b=b*j; //A(5,3) 30 | printf("%.0lf\n",b/a); 31 | } 32 | return 0; 33 | } -------------------------------------------------------------------------------- /HDUOJ/2520.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | #include 12 | #include 13 | typedef long long LL; 14 | using namespace std; 15 | const int maxn=100; 16 | 17 | int main() 18 | { 19 | LL t,a,b; 20 | LL n; 21 | cin>>t; 22 | while(t--) 23 | { 24 | 25 | cin>>n; 26 | LL sum=0; 27 | for(LL i=1;i<=n;i++) 28 | { 29 | a=1+2*(i-1); 30 | sum=(sum+a)%10000; 31 | } 32 | printf("%lld\n",sum); 33 | } 34 | return 0; 35 | } -------------------------------------------------------------------------------- /HDUOJ/2521.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lzyrapx/Competitive-Programming/6b0eea727f9a6444700a6966209397ac7011226f/HDUOJ/2521.cpp -------------------------------------------------------------------------------- /HDUOJ/2522(分数循环节).cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | bool vis[123456]; 4 | int main() 5 | { 6 | int t; 7 | cin>>t; 8 | int n; 9 | while(t--) 10 | { 11 | cin>>n; 12 | if(n<0){ //注意:可以是负数 13 | printf("-"); 14 | n=-n; 15 | } 16 | if(n==1){ 17 | puts("1"); 18 | continue; 19 | } 20 | memset(vis,false,sizeof vis); 21 | printf("0."); 22 | vis[0] = true; 23 | int m = 1; 24 | while(vis[m]==false) 25 | { 26 | vis[m] = true; 27 | m *= 10; 28 | printf("%d",m/n); 29 | m%=n; 30 | } 31 | cout< 2 | #include 3 | using namespace std; 4 | 5 | int main() 6 | { 7 | ios::sync_with_stdio(false); 8 | double h, l ,v; 9 | while(cin>>h>>l>>v && (h || l || v)) 10 | { 11 | double s = -9.8*l*l/(2*v*v) - l*l/(2.0*(-9.8*l*l)/(v*v)) + h; 12 | printf("%.2lf\n",s); 13 | } 14 | } 15 | 16 | -------------------------------------------------------------------------------- /HDUOJ/2535.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | #include 12 | #include 13 | #include 14 | typedef long long LL; 15 | using namespace std; 16 | 17 | int main() 18 | { 19 | int n; int a; 20 | while(cin>>n,n) 21 | { 22 | int s[1002]; 23 | for(int i=0;i>a; 26 | s[i]=a/2+1; 27 | } 28 | sort(s,s+n); 29 | int ans=0; 30 | for(int i=0;i 2 | # include 3 | int main() 4 | { 5 | int t; 6 | double a,b,c,d,s; 7 | scanf("%d",&t); 8 | while(t--) 9 | { 10 | scanf("%lf%lf%lf%lf",&a,&b,&c,&d); 11 | s=sqrt((a-c)*(a-c)+(b-d)*(b-d)); 12 | printf("%.1f\n",s); 13 | } 14 | return 0; 15 | } -------------------------------------------------------------------------------- /HDUOJ/2548.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | main() 3 | { 4 | double u,v,l,w; 5 | int n; 6 | scanf("%d",&n); 7 | while(n--) 8 | { 9 | scanf("%lf %lf %lf %lf",&u,&v,&w,&l); 10 | printf("%.3f\n",l/(u+v)*w); 11 | } 12 | return 0; 13 | } -------------------------------------------------------------------------------- /HDUOJ/2551.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | #include 12 | #include 13 | #include 14 | typedef long long LL; 15 | using namespace std; 16 | 17 | int main() 18 | { 19 | int t,x; 20 | cin>>t; 21 | while(t--) 22 | { 23 | cin>>x; 24 | LL s=0,i=1; 25 | while(s 2 | #include 3 | using namespace std; 4 | 5 | int main() 6 | { 7 | ios::sync_with_stdio(false); 8 | int n; 9 | while(cin>>n,n) 10 | { 11 | int res=n*(n+1)/2; 12 | if(res%2==0)puts("Y"); 13 | else puts("N"); 14 | } 15 | return 0; 16 | } 17 | 18 | -------------------------------------------------------------------------------- /HDUOJ/2555.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lzyrapx/Competitive-Programming/6b0eea727f9a6444700a6966209397ac7011226f/HDUOJ/2555.cpp -------------------------------------------------------------------------------- /HDUOJ/2560.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | int a[100][100]; 3 | int main() 4 | { 5 | int t,n,m,sum,i,j; 6 | scanf("%d",&t); 7 | while(t--) 8 | { 9 | sum=0; 10 | scanf("%d%d",&n,&m); 11 | { 12 | for(i=0;i 2 | #include 3 | using namespace std; 4 | int main() 5 | { 6 | int n,i,a[101],l; 7 | scanf("%d",&n); 8 | while(n--) 9 | { 10 | scanf("%d",&l); 11 | for(int i=0;i 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | #include 12 | #include 13 | #include 14 | typedef long long LL; 15 | using namespace std; 16 | 17 | int main() 18 | { 19 | int n; 20 | cin>>n; 21 | while(n--) 22 | { 23 | int i; 24 | char a[53],t; 25 | cin>>a; 26 | for(i=0;i 2 | #include 3 | int main() 4 | { 5 | int n,a,b,m,i; 6 | char x[100],y[100]; 7 | while(scanf("%d",&n)!=EOF) 8 | { 9 | while(n--) 10 | { 11 | scanf("%s%s",x,y); 12 | a=strlen(x); 13 | m=a/2; 14 | b=strlen(y); 15 | for(i=0;i 2 | using namespace std; 3 | 4 | int main() 5 | { 6 | string s; 7 | while(cin>>s) 8 | { 9 | int num = 0; 10 | int sum = 0; 11 | for(int i=0;i 2 | using namespace std; 3 | 4 | int main() 5 | { 6 | long long n,i,j,sum,num; 7 | while(~scanf("%d",&n)) 8 | { 9 | num=0; 10 | for(i=1;i=n) break; 17 | } 18 | if(sum==n) num++; 19 | } 20 | printf("%d\n",num+1); //加上本身 21 | } 22 | return 0; 23 | } -------------------------------------------------------------------------------- /HDUOJ/2717.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lzyrapx/Competitive-Programming/6b0eea727f9a6444700a6966209397ac7011226f/HDUOJ/2717.cpp -------------------------------------------------------------------------------- /HDUOJ/3652.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lzyrapx/Competitive-Programming/6b0eea727f9a6444700a6966209397ac7011226f/HDUOJ/3652.cpp -------------------------------------------------------------------------------- /HDUOJ/3652(数位DP).cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lzyrapx/Competitive-Programming/6b0eea727f9a6444700a6966209397ac7011226f/HDUOJ/3652(数位DP).cpp -------------------------------------------------------------------------------- /HDUOJ/4152.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lzyrapx/Competitive-Programming/6b0eea727f9a6444700a6966209397ac7011226f/HDUOJ/4152.cpp -------------------------------------------------------------------------------- /HDUOJ/5718.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lzyrapx/Competitive-Programming/6b0eea727f9a6444700a6966209397ac7011226f/HDUOJ/5718.cpp -------------------------------------------------------------------------------- /HDUOJ/5719.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lzyrapx/Competitive-Programming/6b0eea727f9a6444700a6966209397ac7011226f/HDUOJ/5719.cpp -------------------------------------------------------------------------------- /HDUOJ/5721.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lzyrapx/Competitive-Programming/6b0eea727f9a6444700a6966209397ac7011226f/HDUOJ/5721.cpp -------------------------------------------------------------------------------- /HDUOJ/5722.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lzyrapx/Competitive-Programming/6b0eea727f9a6444700a6966209397ac7011226f/HDUOJ/5722.cpp -------------------------------------------------------------------------------- /HDUOJ/5726.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lzyrapx/Competitive-Programming/6b0eea727f9a6444700a6966209397ac7011226f/HDUOJ/5726.cpp -------------------------------------------------------------------------------- /HDUOJ/5727.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lzyrapx/Competitive-Programming/6b0eea727f9a6444700a6966209397ac7011226f/HDUOJ/5727.cpp -------------------------------------------------------------------------------- /HDUOJ/5728.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lzyrapx/Competitive-Programming/6b0eea727f9a6444700a6966209397ac7011226f/HDUOJ/5728.cpp -------------------------------------------------------------------------------- /HDUOJ/5733.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lzyrapx/Competitive-Programming/6b0eea727f9a6444700a6966209397ac7011226f/HDUOJ/5733.cpp -------------------------------------------------------------------------------- /HDUOJ/5747.cpp: -------------------------------------------------------------------------------- 1 | //#include 2 | #include 3 | #include 4 | #include 5 | #include 6 | using namespace std; 7 | int main() 8 | { 9 | int t; 10 | scanf("%d",&t); 11 | while(t--) 12 | { 13 | int n,m; 14 | scanf("%d%d",&n,&m); 15 | int ans=0; 16 | int d =1 <<(min(m,30)); 17 | while(n) 18 | { 19 | ans+=n/d; 20 | n-=n/d*d; 21 | d/=2; 22 | } 23 | printf("%d\n",ans); 24 | } 25 | return 0; 26 | } -------------------------------------------------------------------------------- /HDUOJ/5776.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lzyrapx/Competitive-Programming/6b0eea727f9a6444700a6966209397ac7011226f/HDUOJ/5776.cpp -------------------------------------------------------------------------------- /HDUOJ/5777.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lzyrapx/Competitive-Programming/6b0eea727f9a6444700a6966209397ac7011226f/HDUOJ/5777.cpp -------------------------------------------------------------------------------- /HDUOJ/5778.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lzyrapx/Competitive-Programming/6b0eea727f9a6444700a6966209397ac7011226f/HDUOJ/5778.cpp -------------------------------------------------------------------------------- /HDUOJ/5780.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lzyrapx/Competitive-Programming/6b0eea727f9a6444700a6966209397ac7011226f/HDUOJ/5780.cpp -------------------------------------------------------------------------------- /HDUOJ/5781.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | const double INF = 1e12; 4 | const double eps = 1e-8; 5 | double dp[2010][20]; 6 | double solve(int k, int w) 7 | { 8 | if(k == 0) 9 | return dp[k][w] = 0; 10 | if(w == 0) 11 | return INF; 12 | if(dp[k][w] > 0) 13 | return dp[k][w]; 14 | dp[k][w] = INF; 15 | for(int i=1; i<=k; i++) 16 | dp[k][w] = min(dp[k][w],(double)(k-i+1)/(k+1)*solve(k-i,w)+(double)i/(k+1)*solve(i-1,w-1)+1); 17 | return dp[k][w]; 18 | } 19 | int main() 20 | { 21 | int k, w; 22 | while(~scanf("%d%d",&k,&w)) 23 | { 24 | w = min(w,15); 25 | printf("%.6lf\n",solve(k,w)); 26 | } 27 | return 0; 28 | } -------------------------------------------------------------------------------- /HDUOJ/5782(....).cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lzyrapx/Competitive-Programming/6b0eea727f9a6444700a6966209397ac7011226f/HDUOJ/5782(....).cpp -------------------------------------------------------------------------------- /HDUOJ/5783.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lzyrapx/Competitive-Programming/6b0eea727f9a6444700a6966209397ac7011226f/HDUOJ/5783.cpp -------------------------------------------------------------------------------- /HDUOJ/5784.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lzyrapx/Competitive-Programming/6b0eea727f9a6444700a6966209397ac7011226f/HDUOJ/5784.cpp -------------------------------------------------------------------------------- /HDUOJ/5785.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lzyrapx/Competitive-Programming/6b0eea727f9a6444700a6966209397ac7011226f/HDUOJ/5785.cpp -------------------------------------------------------------------------------- /HDUOJ/5791.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lzyrapx/Competitive-Programming/6b0eea727f9a6444700a6966209397ac7011226f/HDUOJ/5791.cpp -------------------------------------------------------------------------------- /HDUOJ/5793.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | typedef long long ll; 4 | const int mod=1e9+7; 5 | 6 | ll q_mod(ll a,ll n) 7 | { 8 | ll ans=1; 9 | while(n){ 10 | if(n&1)ans=ans*a%mod; 11 | n>>=1; 12 | a=a*a%mod; 13 | } 14 | return ans; 15 | } 16 | int main() 17 | { 18 | int t; 19 | scanf("%d",&t); 20 | while(t--){ 21 | ll n,m; 22 | scanf("%lld%lld",&n,&m); 23 | printf("%lld\n",(q_mod(m,n+1)-1)*q_mod(m-1,mod-2)%mod); 24 | } 25 | return 0; 26 | } -------------------------------------------------------------------------------- /HDUOJ/5795.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | int SG(int x) 4 | { 5 | if(x%8==0)return x-1; 6 | if(x%8==7)return x+1; 7 | return x; 8 | } 9 | int main() 10 | { 11 | int t; 12 | scanf("%d",&t); 13 | while(t--) 14 | { 15 | int n; 16 | scanf("%d",&n); 17 | int ans=0; 18 | int a=0; 19 | for(int i=0;i 2 | #include 3 | const int N = 100000+20; 4 | char S[N]; 5 | int main(){ 6 | int t; 7 | scanf("%d",&t); 8 | while(t--) 9 | { 10 | scanf("%s",S); 11 | long long cnt=0,ans=0; 12 | int L=strlen(S); 13 | for(int i=0;i<=L;i++) 14 | { 15 | if(S[i]=='q') 16 | { 17 | cnt++; 18 | } 19 | else if(S[i]!='q'&&S[i-1]=='q') 20 | { 21 | ans+=cnt*(cnt+1)/2; 22 | cnt=0; 23 | } 24 | } 25 | printf("%lld\n",ans); 26 | } 27 | return 0; 28 | } -------------------------------------------------------------------------------- /HDUOJ/README.md: -------------------------------------------------------------------------------- 1 | # TODO 2 | -------------------------------------------------------------------------------- /LibreOJ/1.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lzyrapx/Competitive-Programming/6b0eea727f9a6444700a6966209397ac7011226f/LibreOJ/1.zip -------------------------------------------------------------------------------- /LibreOJ/105(rope)(区间翻转).cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | using namespace std; 4 | using namespace __gnu_cxx; 5 | roperop,rp; 6 | int main() 7 | { 8 | int n,m; 9 | scanf("%d%d",&n,&m); 10 | for(int i=1;i<=n;i++){ 11 | rop.push_back(n-i+1); 12 | rp.push_back(i); 13 | } 14 | for(int i=1;i<=m;i++){ 15 | int l,r; 16 | scanf("%d%d",&l,&r); 17 | rope tmp = rp.substr(l-1,r-l+1); 18 | rope temp = rop.substr(n-r,r-l+1); 19 | rp=rp.substr(0,l-1) + temp + rp.substr(r,n-r); 20 | rop = rop.substr(0,n-r) + tmp + rop.substr(n-l+1,l-1); 21 | } 22 | char c; 23 | for(int i=0;i 2 | using namespace std; 3 | int exgcd(int a,int b,int &x,int &y) 4 | { 5 | if(b==0) 6 | { 7 | x=1; 8 | y=0; 9 | return a; 10 | } 11 | int res=exgcd(b,a%b,x,y); 12 | int t=x;x=y;y=t-(a/b)*y; 13 | return res; 14 | } 15 | int main() 16 | { 17 | int n,p; 18 | int x,y; 19 | cin>>n>>p; 20 | for(int i=1;i<=n;i++){ 21 | 22 | exgcd(i,p,x,y); 23 | printf("%d\n",(x+p)%p); 24 | } 25 | return 0; 26 | } -------------------------------------------------------------------------------- /LibreOJ/110(乘法逆元)(奇葩快速幂).cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | inline int mul_mod(int a,int b,int mod) 4 | { 5 | int ret; 6 | __asm__ __volatile__ ("\tmull %%ebx\n\tdivl %%ecx\n" :"=d"(ret):"a"(a),"b"(b),"c"(mod)); 7 | return ret; 8 | } 9 | inline int ksm(int x,int y,int mod) 10 | { 11 | int bit=1<<25; 12 | int ans=1; 13 | while(bit) 14 | { 15 | ans=mul_mod(ans,ans,mod); 16 | if(y&bit)ans=mul_mod(ans,x,mod); 17 | bit>>=1; 18 | } 19 | return (int)ans; 20 | } 21 | int n,p; 22 | int main() 23 | { 24 | scanf("%d%d",&n,&p); 25 | for(int i=1;i<=n;i++) 26 | printf("%d\n",ksm(i,p-2,p)); 27 | return 0; 28 | } 29 | -------------------------------------------------------------------------------- /LibreOJ/118(正则表达式).cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | char regx[233], str[233]; 7 | int main(){ 8 | while(~scanf("%s %s", regx, str)){ 9 | regex_t reg; 10 | regcomp(®, regx, REG_EXTENDED); 11 | regmatch_t mm[1]; 12 | if(regexec(®, str, 1, mm, 0) != REG_NOMATCH){ 13 | if(mm[0].rm_eo-mm[0].rm_so == strlen(str)) 14 | puts("Yes"); 15 | else puts("No"); 16 | } 17 | else puts("No"); 18 | regfree(®); 19 | } 20 | return 0; 21 | } -------------------------------------------------------------------------------- /LibreOJ/4(脑洞题).py: -------------------------------------------------------------------------------- 1 | s = 's = %r\nprint(s%%s)' 2 | print(s%s) -------------------------------------------------------------------------------- /LibreOJ/5.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lzyrapx/Competitive-Programming/6b0eea727f9a6444700a6966209397ac7011226f/LibreOJ/5.zip -------------------------------------------------------------------------------- /LibreOJ/6.cpp: -------------------------------------------------------------------------------- 1 | #include "interaction.h" 2 | using namespace std; 3 | 4 | vectorans; 5 | int binary(int idx) 6 | { 7 | int l = 0,r = 1000000; 8 | int mid,res; 9 | while(l<=r) 10 | { 11 | mid = (l+r)>>1; 12 | res = guess(idx,mid); 13 | if(res>0){ 14 | r = mid -1; 15 | } 16 | else if(!res) return mid; 17 | else l = mid + 1; 18 | } 19 | return l; 20 | } 21 | int main() 22 | { 23 | int n = get_num(); 24 | for(int i=0;i 2 | using namespace std; 3 | typedef long long ll; 4 | ll ans[10]; 5 | ll calc(ll limit,ll l,ll r) 6 | { 7 | ll res = 0; 8 | ll last = 0; 9 | for(ll i = l;i<=min(limit,r);i=last+1) 10 | { 11 | last = min(limit/(limit/i),r); 12 | res += limit/i*(last-i+1); 13 | } 14 | return res; 15 | } 16 | int main() 17 | { 18 | int l,r; 19 | scanf("%d%d",&l,&r); 20 | for(int i=1;i<=9;i++) 21 | { 22 | ll x = i; 23 | for(;x<=r;x*=10) 24 | { 25 | ll L = x; 26 | ll R = x/i*(i+1)-1; 27 | ans[i] += calc(r,L,R)-calc(l-1,L,R); 28 | } 29 | printf("%lld\n",ans[i]); 30 | } 31 | return 0; 32 | } -------------------------------------------------------------------------------- /LibreOJ/6086(数学题).cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | typedef long long ll; 4 | const int maxn =5000010; 5 | const int mod = 1000000007; 6 | int n,m,num; 7 | ll l[maxn],j[maxn],k[maxn]; 8 | ll x[maxn],y[maxn],z[maxn]; 9 | int main() 10 | { 11 | 12 | scanf("%d",&n); 13 | for(int i=1;i<=n;i++) 14 | { 15 | scanf("%d%d%d",&l[i],&j[i],&k[i]); 16 | x[i] = l[i] - j[i]; 17 | y[i] = j[i] - k[i]; 18 | z[i] = k[i] - l[i]; 19 | } 20 | ll ans = 0; 21 | sort(x+1,x+n+1); 22 | sort(y+1,y+n+1); 23 | sort(z+1,z+n+1); 24 | for(int i=1;i<=n;i++) 25 | { 26 | ans = (ans + 1LL*(2*i-n-1)*(x[i]+y[i]+z[i])) % mod; 27 | } 28 | printf("%lld\n",(ans*500000004)%mod); 29 | return 0; 30 | } -------------------------------------------------------------------------------- /LibreOJ/6090(构造).cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | int a[234],b[234]; 5 | bool flag; 6 | int main() 7 | { 8 | int n,k; 9 | flag = true; 10 | int pos; 11 | cin>>n>>k; 12 | for(int i=0;i>a[i]; 14 | if(a[i]==0&&flag) 15 | { 16 | pos = i; 17 | flag =false; 18 | } 19 | } 20 | for(int i=0;i>b[i]; 21 | 22 | if(k==1) 23 | { 24 | a[pos]=b[0]; 25 | int ans = 1; 26 | for(int i=0;ia[i+1]) 29 | { 30 | cout<<"Yes"< 2 | using namespace std; 3 | typedef long long ll; 4 | const int maxn = 10000010; 5 | const int mod = 1e9+7; 6 | int n,m,x,y; 7 | int pos,ans; 8 | char c,s[2010]; 9 | int main() 10 | { 11 | cin>>n; 12 | scanf("%s",s+1); 13 | cin>>m; 14 | while(m--) 15 | { 16 | cin>>x>>c; 17 | y = 1; 18 | pos = x; 19 | ans = 0; 20 | for(int i=1;i<=n;i++) 21 | { 22 | //for(;y<=n;y++) 23 | while(y<=n) 24 | { 25 | if(s[y]!=c) 26 | { 27 | if(pos==0)break; 28 | --pos; 29 | } 30 | y++; 31 | } 32 | if(s[i]!=c)pos++; 33 | if(y-i>ans)ans = y-i; 34 | } 35 | cout< 2 | using namespace std; 3 | double c[1100],d[1100]; 4 | /* 5 | 因为我们要算期望,所以我们需要枚举第i个人在第j个位置需要的时间, 6 | 累加起来,又因为第i个人在第j个位置的概率一定为1/n,所以我们可以得到公式: 7 | 1/n* \sum{i=1~n}\sum{j=1~n} {u * n / ( c[i] - (j-1) * d[i] - v)} 8 | */ 9 | int main() 10 | { 11 | int n; 12 | double u,v; 13 | scanf("%d%lf%lf",&n,&v,&u); 14 | for(int i=1;i<=n;i++) 15 | { 16 | scanf("%lf",&c[i]); 17 | } 18 | for(int i=1;i<=n;i++){ 19 | scanf("%lf",&d[i]); 20 | } 21 | double ans = 0; 22 | for(int i=1;i<=n;i++){ 23 | for(int j=1;j<=n;j++) 24 | { 25 | ans += u / ( c[i] - (j-1) * d[i] - v); 26 | } 27 | } 28 | printf("%.3lf\n",ans); 29 | return 0; 30 | } -------------------------------------------------------------------------------- /LibreOJ/6176(数学题)(难).cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | typedef long long ll; 4 | int main() 5 | { 6 | int t ; 7 | cin>>t; 8 | while(t--) 9 | { 10 | ll a,b,c,k; 11 | cin>>a>>b>>c>>k; 12 | if(c % __gcd(b, __gcd(a,k-1))){ 13 | puts("No"); 14 | } 15 | else{ 16 | puts("Yes"); 17 | } 18 | } 19 | return 0; 20 | } -------------------------------------------------------------------------------- /LibreOJ/6217(背包dp).cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | int a[1234],b[1234]; 4 | int dp[1234]; 5 | int main() 6 | { 7 | int n; 8 | cin>>n; 9 | for(int i=1;i<=n;i++) cin>>a[i]>>b[i]; 10 | for(int i=0;i<=n;i++)dp[i] = 0; 11 | for(int i=1;i<=n;i++){ 12 | for(int j=n;j>=a[i];--j) 13 | { 14 | dp[j] = max(dp[j],dp[j-a[i]]+b[i]); 15 | } 16 | } 17 | cout< 2 | using namespace std; 3 | const int maxn =1000020; 4 | long long x[maxn]; 5 | long long y[maxn]; 6 | int n; 7 | int main() 8 | { 9 | cin>>n; 10 | for(int i=1;i<=n;i++) 11 | { 12 | cin>>x[i]; 13 | long long p=(p+x[i])%n; 14 | if(p==0) 15 | { 16 | for(int j=1;j<=i;j++) 17 | { 18 | printf("%lld %lld\n",j,x[j]); 19 | } 20 | } 21 | else if(y[p]) 22 | { 23 | for(int j=y[p]+1;j<=i;j++) 24 | { 25 | printf("%lld %lld\n",j,x[j]); 26 | } 27 | return 0; 28 | } 29 | else 30 | { 31 | y[p]=i; 32 | } 33 | 34 | } 35 | 36 | return 0; 37 | } -------------------------------------------------------------------------------- /LibreOJ/README.md: -------------------------------------------------------------------------------- 1 | ## LibreOJ 2 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Competitive-Programming 2 | ### Source Codes For Competitive Programming 3 | - Codeforces 4 | - AtCoder 5 | - TopCoder 6 | - HDUOJ 7 | - POJ 8 | - BZOJ 9 | - ACdream 10 | - ZOJ 11 | - 51nod 12 | - LibreOJ 13 | - FZU 14 | - GCJ 15 | - hihocoder 16 | - Leetcode 17 | - Coding Interviews 18 | - etc 19 | 20 | ## TODO 21 | -------------------------------------------------------------------------------- /Retired_code/README.md: -------------------------------------------------------------------------------- 1 | ## I don't know what I am doing. 2 | -------------------------------------------------------------------------------- /Retired_code/Simplex/README.md: -------------------------------------------------------------------------------- 1 | ### 单纯形 2 | -------------------------------------------------------------------------------- /Retired_code/Simplex/Simplex Algorithm.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lzyrapx/Competitive-Programming/6b0eea727f9a6444700a6966209397ac7011226f/Retired_code/Simplex/Simplex Algorithm.pdf -------------------------------------------------------------------------------- /Xiangtan Invitation Contest 2017/1263(D)(签到题).cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | char s[22][22]; 4 | int main() 5 | { 6 | int n,m,a,b; 7 | while(~scanf("%d %d %d %d",&n,&m,&a,&b)) 8 | { 9 | for(int i=0; i 2 | using namespace std; 3 | typedef long long ll; 4 | const int maxn=1e5+10; 5 | int n,m; 6 | int c; 7 | int a[maxn]; 8 | 9 | int main() 10 | { 11 | while(~scanf("%d",&n)) 12 | { 13 | a[0]=0; 14 | int b; 15 | cin>>m>>c; 16 | for(int i=1;i<=n;i++) 17 | { 18 | scanf("%d",&b); 19 | a[i]=a[i-1]+b; 20 | } 21 | sort(a,a+n+1); 22 | ll ans = 0 ; 23 | for (int i=0;i 2 | using namespace std; 3 | typedef long long ll; 4 | ll gcd(ll a, ll b) 5 | { 6 | return b == 0 ? a : gcd(b, a%b); 7 | } 8 | int main() 9 | { 10 | ios::sync_with_stdio(false); 11 | cin.tie(0); 12 | ll n,m; 13 | while(cin >> n >> m) 14 | { 15 | ll t1 = gcd(n, m); 16 | ll t2 = 2 * n * m; 17 | ll num = gcd(t1, t2); 18 | ll p = t1 / num; 19 | ll q = t2 / num; 20 | cout << p <<"/" << q < 3 | #include 4 | using namespace std; 5 | int main() 6 | { 7 | int a,b; 8 | 9 | while(cin>>a>>b){ 10 | printf("%d",a+b); 11 | } 12 | return 0; 13 | } -------------------------------------------------------------------------------- /hihocoder/1032(manacher).cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lzyrapx/Competitive-Programming/6b0eea727f9a6444700a6966209397ac7011226f/hihocoder/1032(manacher).cpp -------------------------------------------------------------------------------- /hihocoder/1033(数位dp).cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lzyrapx/Competitive-Programming/6b0eea727f9a6444700a6966209397ac7011226f/hihocoder/1033(数位dp).cpp -------------------------------------------------------------------------------- /hihocoder/1037(dp).cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | int dp[1010][1010]; 4 | int main() 5 | { 6 | int t,maxx=0; 7 | scanf("%d",&t); 8 | for(int i=1; i<=t; i++) 9 | { 10 | for(int j=1; j<=i; j++) 11 | { 12 | scanf("%d",&dp[i][j]); 13 | dp[i][j]+=max(dp[i-1][j],dp[i-1][j-1]); 14 | maxx=max(maxx,dp[i][j]); 15 | } 16 | } 17 | printf("%d\n",maxx); 18 | } -------------------------------------------------------------------------------- /hihocoder/1038(dp).cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #define max(a,b) a>b?a:b; 3 | int n,m,w[505],p[505],f[100005],i,j; 4 | int main(){ 5 | scanf("%d%d",&n,&m); 6 | for(i=0;i=w[i];j--) 9 | f[j]=max(f[j],f[j-w[i]]+p[i]); 10 | printf("%d\n",f[m]); 11 | return 0; 12 | } -------------------------------------------------------------------------------- /hihocoder/1039(字符串).cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lzyrapx/Competitive-Programming/6b0eea727f9a6444700a6966209397ac7011226f/hihocoder/1039(字符串).cpp -------------------------------------------------------------------------------- /hihocoder/1040(计算几何).cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lzyrapx/Competitive-Programming/6b0eea727f9a6444700a6966209397ac7011226f/hihocoder/1040(计算几何).cpp -------------------------------------------------------------------------------- /hihocoder/1041(树上dfs).cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lzyrapx/Competitive-Programming/6b0eea727f9a6444700a6966209397ac7011226f/hihocoder/1041(树上dfs).cpp -------------------------------------------------------------------------------- /hihocoder/1042(枚举).cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lzyrapx/Competitive-Programming/6b0eea727f9a6444700a6966209397ac7011226f/hihocoder/1042(枚举).cpp -------------------------------------------------------------------------------- /hihocoder/1043(dp).cpp: -------------------------------------------------------------------------------- 1 | #include 2 | int d[100005]; 3 | int n,m; 4 | int main(){ 5 | int need,value; 6 | scanf("%d%d", &n, &m); 7 | while(n--){ 8 | scanf("%d%d", &need, &value); 9 | for(int i = need; i <= m; i++) 10 | if(d[i-need] + value > d[i]) 11 | d[i] = d[i-need] + value; 12 | } 13 | printf("%d\n",d[m]); 14 | return 0; 15 | } -------------------------------------------------------------------------------- /hihocoder/1044(状压dp).cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lzyrapx/Competitive-Programming/6b0eea727f9a6444700a6966209397ac7011226f/hihocoder/1044(状压dp).cpp -------------------------------------------------------------------------------- /hihocoder/README.md: -------------------------------------------------------------------------------- 1 | # TODO 2 | -------------------------------------------------------------------------------- /jisuanke/2018Game5/B.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | typedef long long ll; 4 | const int maxn = 505000; 5 | const int mod = 998244353; 6 | ll n,k; 7 | 8 | ll calc(ll x) 9 | { 10 | ll ans = 1; 11 | while (x > 0) { 12 | ans *= (x % 10); 13 | x/=10; 14 | } 15 | return ans; 16 | } 17 | int main() 18 | { 19 | ll ans = 0; 20 | std::cin >> n >> k; 21 | for(ll i = 1; i <= n;i++) { 22 | for(ll j = 1; j <= n;j++) { 23 | if(__gcd(calc(i),calc(j)) > 0 && __gcd(calc(i),calc(j)) <= k && (calc(i) * calc(j)) > 0){ 24 | ans ++; 25 | ans %= mod; 26 | } 27 | } 28 | } 29 | std::cout << ans % mod<< '\n'; 30 | return 0; 31 | } 32 | -------------------------------------------------------------------------------- /百度之星/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lzyrapx/Competitive-Programming/6b0eea727f9a6444700a6966209397ac7011226f/百度之星/.DS_Store -------------------------------------------------------------------------------- /百度之星/2018/2018-A-Round/A.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | const int maxn = 1e5; 4 | 5 | int a[maxn]; 6 | int main() 7 | { 8 | int n; 9 | while(std::cin >> n) 10 | { 11 | for(int i=0;ia[i+2]) { 18 | ans=a[i]+a[i+1]+a[i+2]; 19 | } 20 | } 21 | std::cout << ans << '\n'; 22 | } 23 | return 0; 24 | } 25 | -------------------------------------------------------------------------------- /百度之星/2019/in.txt: -------------------------------------------------------------------------------- 1 | 1 2 | 1 3 | 5 5 6 6 4 | 7 7 8 8 5 | -------------------------------------------------------------------------------- /百度之星/2020/第三场/A.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * @Author: zhaoyang.liang 3 | * @Github: https://github.com/LzyRapx 4 | * @Date: 2020-07-26 23:35:09 5 | */ 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | 12 | using namespace std; 13 | 14 | int main(int argc, char const *argv[]) 15 | { 16 | int t; 17 | cin >> t; 18 | while(t--){ 19 | int n; 20 | cin >> n; 21 | double res = 0.0; 22 | int a; 23 | double b; 24 | for(int i = 0; i < n; i++) { 25 | cin >> a >> b; 26 | res = max(res, (1 - b) / (a - b + 1)); 27 | } 28 | printf("%.5f\n",res); 29 | } 30 | return 0; 31 | } -------------------------------------------------------------------------------- /百度之星/2020/第三场/B.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * @Author: zhaoyang.liang 3 | * @Github: https://github.com/LzyRapx 4 | * @Date: 2020-07-26 23:35:25 5 | */ 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | 12 | using namespace std; 13 | 14 | int main(int argc, char const *argv[]) 15 | { 16 | int t; 17 | cin >> t; 18 | while(t--){ 19 | double n; 20 | cin >> n; 21 | if(n > 1) { 22 | cout << "No"<< endl; 23 | } 24 | else { 25 | cout << "Yes" << endl; 26 | } 27 | 28 | } 29 | return 0; 30 | } -------------------------------------------------------------------------------- /百度之星/2020/第三场/C.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * @Author: zhaoyang.liang 3 | * @Github: https://github.com/LzyRapx 4 | * @Date: 2020-07-26 23:35:38 5 | */ 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | 12 | using namespace std; 13 | typedef long long ll; 14 | int main(int argc, char const *argv[]) 15 | { 16 | int t; 17 | cin >> t; 18 | while(t--){ 19 | ll n, m; 20 | cin >> n >> m; 21 | ll res = 0; 22 | m = min(m, n / 2); 23 | res = m * (2 * n + 1); 24 | res = res - 2 * m * (m + 1); 25 | cout << res << endl; 26 | } 27 | return 0; 28 | } -------------------------------------------------------------------------------- /百度之星/百度之星2016-资格赛/A.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lzyrapx/Competitive-Programming/6b0eea727f9a6444700a6966209397ac7011226f/百度之星/百度之星2016-资格赛/A.cpp -------------------------------------------------------------------------------- /百度之星/百度之星2016-资格赛/B.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lzyrapx/Competitive-Programming/6b0eea727f9a6444700a6966209397ac7011226f/百度之星/百度之星2016-资格赛/B.cpp -------------------------------------------------------------------------------- /百度之星/百度之星2016-资格赛/D.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lzyrapx/Competitive-Programming/6b0eea727f9a6444700a6966209397ac7011226f/百度之星/百度之星2016-资格赛/D.cpp --------------------------------------------------------------------------------