├── .gitignore ├── README.md └── code ├── 01_dataStructure ├── cf 375D BST插入+查找.cpp ├── hdu 5573 二叉树+构造.cpp ├── huffman.cpp ├── kd-tree │ ├── hdu 4347 k维空间面的最近m个点.cpp │ ├── hdu 5992 平面最近点对+价格限制(16qingdao).cpp │ └── template.cpp ├── segmentTree │ ├── hdu 1166 线段树单点(加减)+区间(求和).cpp │ ├── hdu 1540 区间合并(最大连续区间).cpp │ ├── hdu 1542 线段树(没做完).cpp │ ├── hdu 1556 线段树查询每个点.cpp │ ├── hdu 1698 线段树区间(替换)+区间(求和).cpp │ ├── hdu 1754 线段树单点(替换)+区间(最值).cpp │ ├── hdu 3974 多叉树映射到区间用线段树解决.cpp │ ├── hdu 5238 中国剩余定理+线段树.cpp │ ├── hdu2795.cpp │ ├── hdu4027未完成.cpp │ ├── hdu4578.cpp │ ├── hdu4614.cpp │ ├── joj1008.cpp │ ├── poj 2528 线段树+离散化+染色个数.cpp │ ├── poj 3264 线段树建树+区间(最值).cpp │ ├── poj 3468 线段树区间(加)+区间(求和).cpp │ ├── template.cpp │ ├── ubdo hdu 1394 线段树 最小逆序数.cpp │ ├── zoj 1610 染色区间数.cpp │ ├── 矩形面积并交周长并.cpp │ ├── 线段树--区间更新+区间求和+lazy(poj3468).cpp │ └── 线段树--单点更新+区间最值(hdu1754).cpp ├── template.cpp ├── trie │ ├── Trie_动态模板(hdu1251).cpp │ ├── Trie_静态模板(hdu1251).cpp │ ├── hdu 1075 Trie_动态,翻译字典.cpp │ ├── hdu 1075 map翻译字典.cpp │ ├── hdu 1247 Trie_静态,两个串组成一个串.cpp │ ├── hdu 1251 Trie_动态,前缀个数.cpp │ ├── hdu 1251 Trie_静态,前缀个数.cpp │ ├── hdu 1671 Trie_动态模板.cpp │ ├── hdu 2846 Trie_静态模板.cpp │ ├── hdu1671.cpp │ └── template.cpp ├── union-find │ ├── hdu 1198 求连通块---并查集.cpp │ ├── hdu 1325 poj 1208 并查集.cpp │ ├── hdu 1856 基础并查集.cpp │ ├── hdu 3038 带权并查集.cpp │ ├── hdu 3047 带权并查集.cpp │ ├── hdu 3635 并查集.cpp │ ├── poj 1182 带权并查集.cpp │ └── union-find-ConnectedBlock.py ├── 主席树 │ ├── poj 2104 主席树,区间第k大.cpp │ └── 主席树(区间最值).cpp └── 前缀和 │ ├── cf 816B 前缀和扫一遍(好题).cpp │ └── hdu 6012 维护区间前缀和.cpp ├── 02_string ├── AC自动机 │ ├── 1.cpp │ ├── hdu 2222 acam裸题(文章中出现几个单词).cpp │ ├── hdu 6208 最长串是否为所有串的母串.cpp │ ├── hdu2896.cpp │ ├── note.cpp │ ├── template.cpp │ └── 输入挂.cpp ├── KMP │ ├── 17计蒜之道1场B题 KMP+模拟.cpp │ ├── hdu 1358 next应用(循环节个数).cpp │ ├── hdu 1686 KMP(模式串在主串出现次数).cpp │ ├── hdu 1711 KMP裸题.cpp │ ├── hdu 2087 KMP(模式串在主串出现次数(不可重叠)).cpp │ ├── hdu 2203 KMP模板题.cpp │ ├── hdu 2594 最长公共s1前缀与s2后缀(next应用).cpp │ ├── hdu 3746 next应用(补齐字符串成为两个循环节).cpp │ ├── hdu 6208 最长串是否为所有串的母串(KMP_TLE).cpp │ ├── hust 1010 next应用(找最小循环节).cpp │ ├── poj 2406 next应用(最小循环节).cpp │ ├── poj 2752 next应用(求所有公共前后缀长度).cpp │ ├── poj 3461 KMP模版.cpp │ ├── poj3080.cpp │ └── template.cpp ├── hdu 1039 简单判断字符串.cpp ├── hdu 1073 字符串处理,模拟OJ系统.cpp ├── hdu 2206 字符串处理(IP).cpp ├── hdu 2207 字符串处理 (IP).cpp ├── manacher │ ├── hdu3068.cpp │ └── manacher.cpp ├── template.cpp ├── 后缀数组 │ ├── hdu 4552 求所有前缀出现次数之和.cpp │ ├── hdu6194.cpp │ ├── poj 2774 后缀数组模板题,最长公共子串.cpp │ ├── poj 3261 最长可重复k次的可重叠子串.cpp │ ├── poj1226.cpp │ ├── poj1743.cpp │ ├── poj2406KMP_循环节.cpp │ ├── poj3261_template2.cpp │ ├── poj3581da_三个子串逆序字典序最小.cpp │ ├── template_da.cpp │ └── template_da1.cpp └── 字符串哈希 │ └── hdu1880.cpp ├── 03_graph ├── LCA │ └── RMQ │ │ ├── hdu 2586 lca+rmq板题.cpp │ │ ├── hdu 2874 lca+rmq+并查集.cpp │ │ ├── hdu 6065 lca+rmq+dp(过不了).cpp │ │ ├── lca+rmq.cpp │ │ └── lca+tarjan_undo.cpp ├── cf862b 二分图染色.cpp ├── hdu 1116 判断存在欧拉通路.cpp ├── hdu 1285 拓扑排序.cpp ├── hdu 1878 是否存在欧拉回路.cpp ├── hdu 2094 拓扑排序判断回路.cpp ├── hdu 2894 转换为欧拉回路.cpp ├── hdu 3018 欧拉回路能否一笔画问题.cpp ├── hdu 3478 二分图判定(染色).cpp ├── hdu 5961 暴力搜索(图论)--判断图是否传递.cpp ├── hdu2224.cpp ├── leetcode787_步数限制的权值最段路.py ├── poj 2386 dfs 类似找连通块.cpp ├── template.cpp ├── 强连通分量 │ ├── hdu 6165 半连通分量_kosaraju.cpp │ ├── kosaraju.cpp │ ├── poj 1236 scc_kosaraju(出入度).cpp │ ├── poj 2186 scc_kosaraju(2次dfs)_挑战.cpp │ ├── poj 2762 半连通分量_kosaraju.cpp │ ├── poj 3180 大于1的scc个数_kosaraju.cpp │ ├── tarjan.cpp │ └── template.cpp ├── 搜索 │ ├── fzu 2150 两点dfs+暴力.cpp │ ├── hdu 1015 dfs回溯.cpp │ ├── hdu 1241 简单dfs求连通块.cpp │ ├── hdu 1495 简单bfs.cpp │ ├── hdu 1518 排列树转子集树(加上贪心思想).cpp │ ├── hdu 2181 20面体哈密顿路径(dfs).cpp │ ├── hdu 2612 两点bfs.cpp │ ├── hdu 5952 无向图中爆搜大小为S的团个数.cpp │ ├── hdu 6113 dfs边界+连通块.cpp │ ├── hdu1043.cpp │ ├── hdu2553裸N后(按行dfs).cpp │ ├── hdu3533.cpp │ ├── hdu3567.cpp │ ├── poj 1321 状压dp.cpp │ ├── poj 1426 dfs.cpp │ ├── poj 1426_print.cpp │ ├── poj 2251 三维bfs.cpp │ ├── poj 3087 比起bfs更像模拟.cpp │ ├── poj 3126 bfs+素数筛选.cpp │ ├── poj 3278 一维bfs.cpp │ ├── poj 3279 状压dp.cpp │ ├── poj 3414 数组dfs+模拟+输出路径.cpp │ ├── poj 3984 bfs+记录路径.cpp │ ├── poj1321类似N后(按行dfs).cpp │ ├── poj1376.cpp │ ├── template.cpp │ └── uva 11624 两点bfs+记录深度.cpp ├── 最小生成树 │ ├── hdu 1102 kruskal求最小生成树.cpp │ ├── hdu 1102 prim求最小生成树.cpp │ ├── hdu 1162 kruskal基础题.cpp │ ├── hdu 1233 kruskal模板题.cpp │ ├── hdu 1301 kruskal基础题.cpp │ ├── hdu 1598 kruskal+贪心(枚举).cpp │ ├── hdu 1863 kruskal模版题.cpp │ ├── hdu 1875 kruskal模版题+求距离.cpp │ ├── hdu 1879 kruskal基础题.cpp │ ├── hdu 3371 kruskal基础题+并查集.cpp │ ├── poj 1287 kruskal模板.cpp │ └── template.cpp ├── 最短路 │ ├── dijkstra.cpp │ ├── dijkstra │ │ ├── hdu 1874 dijkstra 简单.cpp │ │ ├── hdu 2066 dijkstra.cpp │ │ ├── hdu2544(eloge最短路).cpp │ │ └── hdu2544(n*n最短路).cpp │ ├── dijkstra_new.cpp │ ├── dijkstra_print_path.cpp │ ├── hdu 1704 folyd传递闭包(优化) │ ├── hdu 1874 dijkstra 简单.cpp │ ├── hdu 2066 dijkstra.cpp │ ├── hdu 6181 次短路裸题.cpp │ ├── hdu2544(eloge最短路).cpp │ ├── hdu2544(n*n最短路).cpp │ ├── jisuanke 18018 两属性的队列优化dijkstra.cpp │ ├── poj 1502 dijkstra板题.cpp │ ├── poj 1511 两次spfa.cpp │ ├── poj 1797 dijkstra变形.cpp │ ├── poj 1860 spfa.cpp │ ├── poj 2240 floyd判正环.cpp │ ├── poj 2240 spfa判正环.cpp │ ├── poj 2253 dijkstra小改.cpp │ ├── poj 2387 dijkstra裸题+堆优化.cpp │ ├── poj 3255 次短路裸题.cpp │ ├── poj 3259 spfa板题 │ ├── poj 3268 dijkstra两次.cpp │ ├── poj 3660 floyd求闭包.cpp │ ├── poj1125floyd.cpp │ ├── template.cpp │ └── 次短路模板.cpp └── 网络流 │ ├── dinic最大流.cpp │ ├── hdu5988.cpp │ ├── note.cpp │ ├── poj1698.cpp │ └── 最小费用最大流模板.cpp ├── 04_search └── template.cpp ├── 05_DP ├── HDU 1011 树形DP.cpp ├── LCS │ ├── LCS模版.cpp │ ├── hdu 1159 LCS bare problem.cpp │ ├── hdu 1503 LCS+输出路径.cpp │ └── hdu 1513 LCS+滚动数组(Palindrome).cpp ├── cfDP │ ├── cf868d.cpp │ └── cf873b.cpp ├── hdu 1024 最大子串和增强(dp).cpp ├── hdu 1058 DP前面所有推下一个.cpp ├── hdu 1171 多重背包.cpp ├── hdu 1176 DP(数塔变形题).cpp ├── hdu 1243 LCS+DP.cpp ├── hdu 1421 经典dp.cpp ├── hdu 2059 动态规划(龟兔赛跑).cpp ├── hdu 2064 汉诺塔III DP.cpp ├── hdu 2077 汉诺塔IV DP.cpp ├── hdu 2084 DP入门题(数塔).cpp ├── hdu 2085 裸递推.cpp ├── hdu 2089 数位DP入门题.cpp ├── hdu 5890 dp+bitset输入挂.cpp ├── hdu 5900 区间DP+最小费用最大流.cpp ├── poj 1664 m果放入n盘,递归+DP写法.cpp ├── poj1018_undo.cpp ├── poj1088记忆化搜索.cpp ├── poj1795_undo.cpp ├── template.cpp ├── 三维DP │ └── 3d_dp.py ├── 区间DP │ ├── ccf201612_4.cpp │ ├── hdu2476_undo.cpp │ ├── hdu6212.cpp │ ├── lightoj 1422 穿衣服.cpp │ ├── poj 3186 从里向外推区间(区间DP).cpp │ ├── poj1651.cpp │ ├── poj2955括号匹配.cpp │ └── template.md ├── 基础dp │ ├── hdu 1024 m段字段和最大值.cpp │ ├── hdu 1029 ms.cpp │ ├── hdu 1029_online.cpp │ ├── hdu 1029_sort.cpp │ ├── hdu 1069 LIS.cpp │ ├── hdu 1078 DP做法和搜索做法(好题).cpp │ ├── hdu 1078 DP做法和搜索做法.cpp │ ├── hdu 1078 dp+记忆化搜索.cpp │ ├── hdu 1087 最大递增子段和.cpp │ ├── hdu 1114 完全背包.cpp │ ├── hdu 1160 LIS+输出路径.cpp │ ├── hdu 1176 数塔问题(DP).cpp │ ├── hdu 1257 LIS.cpp │ ├── hdu 1260 3*nDP.cpp │ ├── hdu 2859 简单二维DP.cpp │ ├── hdu 6197 LIS变形.cpp │ ├── hdu 6201 图上DP(点权+边权+找点到点价值最大).cpp │ ├── poj 1015 dp.cpp │ ├── poj 1458 LCS.cpp │ ├── poj 2533 LIS+路径模板(nlogn).cpp │ ├── poj 2533 LIS板题.cpp │ ├── poj 3186 区间DP.cpp │ ├── poj 3616 简单DP.cpp │ ├── poj 3666 DP.cpp │ ├── poj1050最大子矩阵和.cpp │ └── poj1661.cpp ├── 数位DP │ ├── ccf2013_12_4.cpp │ ├── hdu2089.cpp │ ├── hdu4734.cpp │ ├── note.cpp │ ├── poj3252.cpp │ └── tem.cpp ├── 树形DP │ ├── hdu 1520 简单树形DP.cpp │ └── poj2342树形DP入门题.cpp ├── 概率DP │ ├── hdu 3853 概率DP(左上走到右下).cpp │ ├── hdu 4405 简单概率DP求期望(有向无环图).cpp │ ├── hdu 5236 概率DP+贪心.cpp │ └── poj 2096 概率DP入门题(期望).cpp ├── 状压DP │ ├── hdu 1074 状压DP.cpp │ └── hdu 4284 状压DP(枚举所有状态进行DP即可).cpp └── 背包 │ ├── 01knapsack.py │ ├── hdu 2546 01背包.cpp │ ├── hdu 2602 01背包裸题.cpp │ ├── hdu1171.cpp │ ├── hdu2639.cpp │ └── hdu6092.cpp ├── 06_greedy ├── hdu 1051 贪心(排序+多次扫描).cpp ├── hdu 1902 简单贪心.cpp ├── hdu 5237 简单贪心.cpp ├── hdu 6000 贪心.cpp ├── hdu 6011 贪心+模拟.cpp ├── hdu 6180 强势贪心(multiset存相反数).cpp ├── poj 1852 蚂蚁走路.cpp ├── poj 2431 贪心+优先队列.cpp ├── poj 3069 贪心 线段取点.cpp ├── poj 3253 贪心+优先队列.cpp └── poj 3617 贪心---字典序最小问题.cpp ├── 07_numberTheory ├── 4.cpp ├── hdu 1019 多个数最小公倍数.cpp ├── hdu 1286 欧拉值裸.cpp ├── hdu 2098 裸素数表.cpp ├── hdu 2421 数论--积性函数.cpp ├── hdu 3037 大组合数取模Lucas.cpp ├── hdu 5238 中国剩余定理+线段树.cpp ├── lightoj 1341 求一个数(1e12)因子个数.cpp ├── lightoj 1370 向上找素数.cpp ├── poj 2407 欧拉值裸.cpp ├── poj3070矩阵快速幂.cpp ├── template.cpp ├── template.md └── 矩阵+高斯 │ ├── hdu 5755 高斯消元裸题.cpp │ ├── 高斯消元模版.cpp │ └── 高斯消元模版.md ├── 08_gameTheory ├── hdu 1525 找必胜态,简单博弈.cpp ├── hdu 1536 SG函数(dfs模版).cpp ├── hdu 1564 组合博弈 找规律 奇偶数.cpp ├── hdu 1846 巴什博弈(裸题) .cpp ├── hdu 1848 SG函数入门.cpp ├── hdu 1851 n个bash + SG定理.cpp ├── hdu 2147 组合博弈 PN表+规律+奇偶数.cpp ├── hdu 2149 bash 小改.cpp ├── hdu 2176 裸Nim+给出第一次取法.cpp ├── hdu 2188 巴什博弈(裸题).cpp ├── hdu 3032 SG打表找规律(可分为两堆).cpp ├── hdu1907 nim.cpp ├── 博弈论知识.cpp └── (未完成)hdu 5795 SG打表找规律(可分为三堆).cpp ├── 09_networkFlow ├── hdu 2063 二部图匹配(匈牙利算法dfs).cpp └── 二分图匹配(匈牙利算法dfs模版).cpp ├── 10_组合数学 ├── 14.cpp ├── Catalan │ ├── hdu 1023 出栈情况数(Catalan).java │ ├── hdu 1023卡特兰裸题.cpp │ └── hdu 1130 Catalan+大数(BST种类数).java ├── hdu 1018 斯特林公式求n!位数.cpp ├── hdu 1028 母函数(整数划分).cpp ├── hdu 1085 母函数(用1.2.5三种硬币最小不能表示的数).cpp ├── hdu 1799 组合数学求C(n,m)+预处理.cpp ├── hdu 2082 母函数入门.cpp ├── hdu 2512 第二类斯特林数.cpp ├── hdu 2643 第二类斯特林数.cpp ├── hdu 3625 第一类斯特林数.cpp ├── 容斥 │ ├── hdu 4135 容斥原理--(a,b)间与n互斥个数.cpp │ ├── hdu 4451 容斥原理+枚举.cpp │ └── hdu4135未.cpp ├── 斯特林数模版.cpp ├── 母函数模版.cpp └── 生成排列与组合.md ├── 11_计算几何 └── hdu 1392 凸包(Graham扫描法).cpp ├── 12_二分答案+判断 ├── cf round 402 D 二分+暴力判断(好题).cpp ├── hdu 1969 二分查找(难在精度).cpp ├── hdu 2199 二分暴力查找.cpp └── poj 2456 最大化最小值 largest minimum distance.cpp ├── 13_概率期望 ├── hdu 1099 期望入门+分数通分.cpp ├── hdu 1204 Markov过程求期望.cpp ├── hdu 4438 简单求期望值.cpp └── hdu 5245 矩阵概率题求期望.cpp ├── 14_递归 ├── hdu 2049 递推.cpp ├── hdu 2050 递推.cpp ├── hdu 2067 简单递推.cpp ├── hdu 2431 递推 .cpp ├── hdu 2502 简单递推(好题,可以复习下).cpp ├── hdu 2563 很好的递推题(列公式算).cpp └── hdu 5965 递推.cpp ├── 15_分治 └── hdu5127.cpp ├── 16_分块 ├── template └── template.cpp ├── 17_矩阵 ├── (未完成)5950 矩阵快速幂,构造矩阵.cpp └── cf450b.cpp ├── 18_常用技巧 ├── template.cpp ├── xor │ └── hdu 2095 异或找出现奇数次的数.cpp ├── 尺取法 │ ├── hdu 6103 尺取法.cpp │ ├── hdu 6205 尺取(往后走直到和为负数找最大和).cpp │ ├── poj 3061 尺取法(和有下限的最短子序列).cpp │ └── poj 3320 尺取法(最短的覆盖所有点的子序列).cpp ├── 离散化 │ └── STL离散化.cpp ├── 输入挂.cpp └── 随机数.cpp ├── 19_STL ├── STL.cpp ├── cf840A pair.cpp ├── cf843a 置换群(PII使用).cpp ├── cf865d mulSet和priQue区别.cpp ├── hdu 1027 permutation.cpp ├── hdu 1031 pri_que重载.cpp ├── hdu 1113 map(string).cpp ├── hdu 1196 lowbit.cpp ├── hdu 2095 set|map.cpp ├── hdu 3785 利用优先队列的排序.cpp ├── hdu 3823 vector+暴力枚举.cpp ├── hdu 4287 法1--简单字典树+hash映射4.cpp ├── hdu 4287 法2--STL做法,好题.cpp ├── hdu 4858 vector.cpp ├── hdu 5127 VectorList区别.cpp ├── hdu 6015 STL map,pque.cpp ├── hdu 6168 multiset.cpp └── map-set练习.cpp ├── 20_数学题 ├── hdu 1006 钟表角度问题(模拟+区间交集+数学).cpp ├── hdu 1029 鸽巢原理(出现次数大于一半的数).cpp ├── hdu 1071 定积分.cpp ├── hdu 1076 从y开始的第n个闰年.cpp ├── hdu 1086 求m个线段交点数.cpp ├── hdu 1271 (数学题)把一个数拆成整数对.cpp ├── hdu 1999 因子和,类似筛选素数.cpp ├── hdu 2056 矩形面积.cpp ├── hdu 2073 计算距离.cpp ├── hdu 2086 数学题---可怕....cpp ├── hdu 2393 水题,判断是否直角三角形.cpp ├── hdu 2503 分数化简.cpp ├── hdu 2504 gcd最大公因数.cpp ├── hdu 3299 枚举+扫描(难).cpp ├── hdu 4432 求n因子和+进制转化.cpp ├── hdu 4452 模拟,太多方向,略复杂.cpp ├── hdu 5495 置换群+LCS.cpp └── 未完成 poj 3716 beyes.cpp ├── GDCPC2013 ├── A Temple Run 简单公式.cpp ├── B Young Tableau (STL multiset).cpp ├── F Pokemon.cpp ├── README.md └── prepareFor2017GDCPC.doc ├── README.md ├── basic ├── 17计蒜之道1场A题 存地图扫描.cpp ├── acm_class │ ├── 1001.cpp │ ├── 1002.cpp │ ├── 1003.cpp │ └── 1012.cpp ├── cf 814A 简单排序.cpp ├── cf 814B 简单构造.cpp ├── cf 816A 简单规律.cpp ├── cf 817A.cpp ├── cf844a.cpp ├── cf844b.cpp ├── cf862a.cpp ├── cf862c 玄学.cpp ├── cf864a.cpp ├── cf864b.cpp ├── cf864c greedy.cpp ├── cf865a.cpp ├── cf867a.cpp ├── guanggong │ ├── a.cpp │ ├── i.cpp │ ├── l.cpp │ └── l.py ├── hdu 1017.cpp ├── hdu 1021.cpp ├── hdu 1033 模拟水题.cpp ├── hdu 1037.cpp ├── hdu 1048.cpp ├── hdu 1064.cpp ├── hdu 1084 水题 排序+模拟.cpp ├── hdu 1106 排序 水题 .cpp ├── hdu 1170 水题-switch.cpp ├── hdu 1228 简单map.cpp ├── hdu 1229 简单a+b.cpp ├── hdu 1622 简单模拟.cpp ├── hdu 1994.cpp ├── hdu 2053 模拟.cpp ├── hdu 2060水题.cpp ├── hdu 2061水题.cpp ├── hdu 2070 水.cpp ├── hdu 2074 .cpp ├── hdu 2083 超简单暴力过.cpp ├── hdu 2093.cpp ├── hdu 2100.cpp ├── hdu 2103.cpp ├── hdu 2187 简单贪心--直接排序.cpp ├── hdu 2500 水题.cpp ├── hdu 2501 简单方块递推.cpp ├── hdu 2510 暴力打表.cpp ├── hdu 2561 水题排序.cpp ├── hdu 2562.cpp ├── hdu 4278 简单 转换为八进制.cpp ├── hdu 4450 水.cpp ├── hdu 5038 简单模拟求解.cpp ├── hdu 5567 简单暴力 .cpp ├── hdu 5600 easy dfs.cpp ├── hdu 5601 简单模拟.cpp ├── hdu 6106 二分图思维题.cpp ├── hdu2212.cpp ├── hdu4920.cpp ├── hdu6213.cpp ├── jisuanke │ ├── dao1 │ │ ├── 1.cpp │ │ └── 2.cpp │ ├── dao2 │ │ ├── 1.cpp │ │ ├── te.cpp │ │ └── test.cpp │ ├── lq │ │ ├── 17 │ │ │ ├── 1.cpp │ │ │ ├── 2.cpp │ │ │ ├── 3.cpp │ │ │ └── 4.cpp │ │ ├── 1.cpp │ │ ├── 2.cpp │ │ ├── 2014-03-25 │ │ │ ├── 21.cpp │ │ │ ├── 22.cpp │ │ │ ├── 34.cpp │ │ │ └── test.cpp │ │ ├── 3.cpp │ │ └── practice5 │ │ │ ├── 1.cpp │ │ │ ├── 2.cpp │ │ │ ├── 3.cpp │ │ │ ├── 4.cpp │ │ │ ├── e.cpp │ │ │ ├── f.cpp │ │ │ ├── g.cpp │ │ │ ├── i.cpp │ │ │ └── test.cpp │ └── ningxia │ │ ├── 1.cpp │ │ ├── b.cpp │ │ ├── data.cpp │ │ ├── e.cpp │ │ ├── i.class │ │ ├── i.java │ │ ├── l.cpp │ │ └── test.cpp ├── jnu │ ├── 3 │ │ ├── 1.cpp │ │ ├── 2.cpp │ │ ├── 22.cpp │ │ ├── 3.cpp │ │ ├── 4.cpp │ │ └── 44.cpp │ ├── 4 │ │ ├── 1.cpp │ │ ├── 2.cpp │ │ ├── 3.cpp │ │ ├── 4.cpp │ │ └── 5.cpp │ ├── 5 │ │ ├── 1.cpp │ │ ├── 2.cpp │ │ ├── 3.cpp │ │ ├── 4.cpp │ │ └── 5.cpp │ ├── 5_pre │ │ ├── 1.cpp │ │ ├── 2.cpp │ │ └── 3.cpp │ ├── 8_pre │ │ ├── 2 │ │ ├── 3 │ │ ├── 2.cpp │ │ └── 3.cpp │ ├── acm_class │ │ ├── DP03-30 │ │ │ ├── 1001.cpp │ │ │ ├── 1018.cpp │ │ │ └── test.cpp │ │ ├── 搜索4-20 │ │ │ ├── 1001.cpp │ │ │ ├── 1003.cpp │ │ │ ├── 1004.cpp │ │ │ ├── 1023.cpp │ │ │ ├── 1024.cpp │ │ │ ├── 1025.cpp │ │ │ └── 1026.cpp │ │ ├── 数组03-12 │ │ │ ├── 1001数塔.cpp │ │ │ ├── 1002movingTable.cpp │ │ │ ├── 1003jumping.cpp │ │ │ ├── 1004maxSum.cpp │ │ │ └── 1005noAC.cpp │ │ └── 母函数4-19 │ │ │ └── 1001.cpp │ └── gao2 │ │ ├── 1.cpp │ │ └── e.cpp ├── nowcoder │ ├── pku_kaoyan │ │ ├── 1.cpp │ │ ├── 10.cpp │ │ ├── 11.cpp │ │ ├── 12.cpp │ │ ├── 13.cpp │ │ ├── 14.cpp │ │ ├── 16.cpp │ │ ├── 17.cpp │ │ ├── 2.cpp │ │ ├── 3.java │ │ ├── 4.cpp │ │ ├── 5.cpp │ │ ├── 6.cpp │ │ ├── 7.cpp │ │ ├── 8.cpp │ │ ├── 9.cpp │ │ ├── h12.class │ │ ├── h12.java │ │ └── test.cpp │ ├── practice17 │ │ ├── 1.cpp │ │ ├── 2.cpp │ │ ├── 3.cpp │ │ └── 4.cpp │ └── 华中科技大学_4-29 │ │ ├── b.cpp │ │ ├── c.cpp │ │ ├── f.cpp │ │ ├── h.cpp │ │ ├── j.cpp │ │ └── k.cpp ├── poj 2552 模拟水题.cpp ├── 百练 │ ├── 1.cpp │ ├── 2.cpp │ ├── 2018研究生上机测试 │ │ ├── a.cpp │ │ ├── b.cpp │ │ ├── c.cpp │ │ ├── d.cpp │ │ ├── e.cpp │ │ ├── f.cpp │ │ ├── g.cpp │ │ ├── h.cpp │ │ ├── i.cpp │ │ └── readme.md │ ├── 3.cpp │ ├── 4.cpp │ ├── 5.cpp │ └── readme.md └── 金马五校赛 │ ├── 1.cpp │ ├── e.cpp │ ├── f.class │ ├── f.cpp │ ├── f_WA.java │ └── k.cpp ├── big num ├── hdu 1002 大数相加.java ├── hdu 1042 大数阶乘.java ├── hdu 1047 大数相加.java ├── hdu 1047 大数相加string.cpp ├── hdu 1061 大数取模 模版.cpp ├── hdu 1063 R的n次幂.java ├── hdu 1715 fibonaqi.java ├── hdu 1753 大浮点数相加.java ├── hdu 5237 大数模拟.java ├── hdu 5241 大数乘法.cpp ├── hdu5920高精度.cpp └── note.java ├── ccf ├── 2013_12_1.cpp ├── 2013_12_2.cpp ├── 2013_12_3.cpp ├── 2013_12_4.cpp ├── 2013_12_4_组合做法.cpp ├── 2013_12_5.cpp ├── 2014_03_1.cpp ├── 2014_03_2.cpp ├── 2014_09_1.cpp ├── 2014_09_2.cpp ├── 2014_09_3.cpp ├── 2014_09_4.cpp ├── 2014_09_5.cpp ├── 2016_04_1.cpp ├── 2016_04_2.cpp ├── 2016_09_1.cpp ├── 2016_09_2.cpp ├── 2016_09_4.cpp ├── 2016_12_1.cpp ├── 2016_12_2.cpp ├── 2016_12_4.cpp ├── 2017_03_01.cpp ├── 2017_03_02.cpp ├── 2017_03_03.cpp ├── 2017_03_04.cpp ├── 2017_03_05.cpp ├── 2017_09_1.cpp ├── 2017_09_2.cpp ├── 2017_09_3.cpp ├── 2017_09_4.cpp ├── 2017_09_5_bit_AC.cpp ├── 2017_09_5_seg_TLE.cpp ├── 2017_12_1.cpp ├── 2017_12_2.cpp ├── 2017_12_3.cpp ├── 2017_12_4.cpp ├── readme.md ├── seg.cpp └── test.cpp ├── cf ├── 340 │ └── 5.cpp ├── 375 │ ├── 1.cpp │ └── 2.cpp ├── 382 │ ├── 1.cpp │ ├── 3.cpp │ └── 4.cpp ├── 428 │ ├── 1.cpp │ ├── 2.cpp │ ├── 3.cpp │ ├── 4.cpp │ ├── 44.cpp │ ├── in3 │ ├── in4 │ └── q.cpp ├── 429 │ ├── a.cpp │ ├── b.cpp │ ├── c.cpp │ └── d.cpp ├── 430 │ ├── a.cpp │ ├── b.cpp │ ├── c.cpp │ └── q.cpp ├── 431 │ ├── 1.cpp │ ├── 2.cpp │ ├── 22.cpp │ ├── 3.cpp │ ├── in3 │ ├── q.cpp │ ├── qq.cpp │ ├── tt.cpp │ └── ttt.cpp ├── 437 │ └── 3undo.cpp ├── 438 │ ├── 1.cpp │ ├── 2.cpp │ ├── 3.cpp │ ├── 4.cpp │ ├── 44.cpp │ ├── 4444.cpp │ └── in3 ├── 439 │ ├── 1.cpp │ ├── 2.cpp │ ├── 3.cpp │ └── 33.cpp ├── 440 │ ├── 1.cpp │ ├── b.cpp │ ├── c.cpp │ ├── cc.cpp │ └── q.cpp ├── 447 │ ├── b.cpp │ ├── c.cpp │ └── cc.cpp ├── 459 │ ├── 1.cpp │ ├── 2.cpp │ └── 3_undo.cpp ├── 460 │ ├── 1.cpp │ ├── 2.cpp │ ├── 3.cpp │ └── 4.cpp ├── 461 │ ├── 1.cpp │ ├── 2.cpp │ ├── 22.cpp │ ├── oo │ └── poss.py ├── 463 │ ├── 1.cpp │ ├── 2.cpp │ └── 3.cpp ├── 465 │ ├── 1.cpp │ ├── 2.cpp │ └── 3.cpp ├── 466 │ ├── 1 │ ├── 2 │ ├── 3 │ ├── 4 │ ├── 1.cpp │ ├── 2.cpp │ ├── 3.cpp │ └── 4.cpp ├── 467 │ ├── 1 │ ├── 2 │ ├── 3 │ ├── 1.cpp │ ├── 2.cpp │ └── 3.cpp ├── 468 │ ├── 1 │ ├── 2 │ ├── 4 │ ├── 1.cpp │ ├── 2.cpp │ └── 4.cpp ├── 470 │ ├── 1 │ ├── 2 │ ├── 3 │ ├── 1.cpp │ ├── 2.cpp │ └── 3.cpp ├── 471 │ ├── 1.cpp │ ├── 2.cpp │ └── 3.cpp ├── 472 │ ├── 1.cpp │ ├── 2.cpp │ └── 3.cpp ├── 473 │ ├── 1.cpp │ ├── 2.cpp │ ├── 3.cpp │ ├── 4.cpp │ ├── 5.cpp │ └── test.cpp ├── 477 │ ├── 1.cpp │ ├── 2.cpp │ ├── 3.cpp │ └── test.cpp ├── 478 │ ├── 1.cpp │ ├── 2.cpp │ └── 3.cpp ├── 446a.cpp ├── 446b.cpp ├── 446c.cpp ├── 446d.cpp ├── 823A.cpp ├── 823B.cpp ├── 832D.cpp ├── 833A.cpp ├── 833B.cpp ├── 834A.cpp ├── 834B.cpp ├── 834B1.cpp ├── 835A.cpp ├── 835B.cpp ├── 835C.cpp ├── 835D.cpp ├── cf 814C.cpp ├── edu35 │ ├── 1.cpp │ ├── 2.cpp │ ├── 3.cpp │ └── 4.cpp ├── edu38 │ ├── 1.cpp │ └── 2.cpp ├── edu39 │ ├── 1.cpp │ ├── 2.cpp │ └── 3.cpp ├── edu41 │ ├── 1.cpp │ ├── 2.cpp │ ├── 3.cpp │ ├── 4.cpp │ └── 5.cpp ├── edu43 │ ├── 1.cpp │ ├── 2.cpp │ ├── 3.cpp │ ├── 3.out │ ├── 5.cpp │ ├── data.cpp │ ├── data_maker │ └── sh.bash ├── hdu6033.cpp ├── hdu6034-undo.cpp ├── hdu6043.cpp └── test.cpp ├── hiho └── 186.cpp ├── leetcode ├── 1.cpp └── 2.cpp ├── notice.md └── poj ├── 1003.cpp ├── 1004.cpp ├── 1005.cpp ├── 1006.cpp ├── 1007.cpp ├── 1008.cpp ├── poj2001字典树.cpp ├── poj2002哈希.cpp └── readme.md /.gitignore: -------------------------------------------------------------------------------- 1 | in 2 | out 3 | note.md 4 | ICPC.md 5 | a.out 6 | .idea 7 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # ACM-ICPC Template 2 | 3 | ## Dwnload 4 | download the lastest commit use 5 | 6 | `git clone --depth=1 git@github.com:mazicwong/ACM_code.git` 7 | 8 | ## TOC 9 | > - 01_dataStructure(数据结构) 10 | > - 02_string(字符串) 11 | > - 03_graph(图论) 12 | > - 04_search(搜索) 13 | > - 05_DP(动态规划) 14 | > - 06_greedy(贪心) 15 | > - 07_numberTheory(数论) 16 | > - 08_gameTheory(博弈论) 17 | > - 09_networkFlow(网络流) 18 | > - 10_组合数学 19 | > - 11_计算几何 20 | > - 12_二分答案+判断 21 | > - 13_概率期望 22 | > - 14_递归 23 | > - 15_分治 24 | > - 16_分块 25 | > - 17_矩阵 26 | > - 18_常用技巧 27 | > - 19_STL 28 | > - 20_数学题 29 | 30 | ## Related Tutorial 31 | [https://www.programiz.com/dsa/graph-dfs](https://www.programiz.com/dsa/graph-dfs) 32 | 33 | ## JNU_ACM 34 | [https://github.com/jnutxdy/JNU_ACMTemplate](https://github.com/jnutxdy/JNU_ACMTemplate) 35 | -------------------------------------------------------------------------------- /code/01_dataStructure/cf 375D BST插入+查找.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mazicwong/ACM_code/b4e774e8fb2087c89c607688600318a7ee6d4571/code/01_dataStructure/cf 375D BST插入+查找.cpp -------------------------------------------------------------------------------- /code/01_dataStructure/hdu 5573 二叉树+构造.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mazicwong/ACM_code/b4e774e8fb2087c89c607688600318a7ee6d4571/code/01_dataStructure/hdu 5573 二叉树+构造.cpp -------------------------------------------------------------------------------- /code/01_dataStructure/segmentTree/hdu 1166 线段树单点(加减)+区间(求和).cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mazicwong/ACM_code/b4e774e8fb2087c89c607688600318a7ee6d4571/code/01_dataStructure/segmentTree/hdu 1166 线段树单点(加减)+区间(求和).cpp -------------------------------------------------------------------------------- /code/01_dataStructure/segmentTree/hdu 1542 线段树(没做完).cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | using namespace std; 5 | int main() 6 | { 7 | 8 | 9 | return 0; 10 | } -------------------------------------------------------------------------------- /code/01_dataStructure/segmentTree/hdu 1698 线段树区间(替换)+区间(求和).cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mazicwong/ACM_code/b4e774e8fb2087c89c607688600318a7ee6d4571/code/01_dataStructure/segmentTree/hdu 1698 线段树区间(替换)+区间(求和).cpp -------------------------------------------------------------------------------- /code/01_dataStructure/segmentTree/hdu 1754 线段树单点(替换)+区间(最值).cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mazicwong/ACM_code/b4e774e8fb2087c89c607688600318a7ee6d4571/code/01_dataStructure/segmentTree/hdu 1754 线段树单点(替换)+区间(最值).cpp -------------------------------------------------------------------------------- /code/01_dataStructure/segmentTree/hdu 5238 中国剩余定理+线段树.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mazicwong/ACM_code/b4e774e8fb2087c89c607688600318a7ee6d4571/code/01_dataStructure/segmentTree/hdu 5238 中国剩余定理+线段树.cpp -------------------------------------------------------------------------------- /code/01_dataStructure/segmentTree/hdu4027未完成.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mazicwong/ACM_code/b4e774e8fb2087c89c607688600318a7ee6d4571/code/01_dataStructure/segmentTree/hdu4027未完成.cpp -------------------------------------------------------------------------------- /code/01_dataStructure/segmentTree/poj 2528 线段树+离散化+染色个数.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mazicwong/ACM_code/b4e774e8fb2087c89c607688600318a7ee6d4571/code/01_dataStructure/segmentTree/poj 2528 线段树+离散化+染色个数.cpp -------------------------------------------------------------------------------- /code/01_dataStructure/segmentTree/poj 3264 线段树建树+区间(最值).cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mazicwong/ACM_code/b4e774e8fb2087c89c607688600318a7ee6d4571/code/01_dataStructure/segmentTree/poj 3264 线段树建树+区间(最值).cpp -------------------------------------------------------------------------------- /code/01_dataStructure/segmentTree/poj 3468 线段树区间(加)+区间(求和).cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mazicwong/ACM_code/b4e774e8fb2087c89c607688600318a7ee6d4571/code/01_dataStructure/segmentTree/poj 3468 线段树区间(加)+区间(求和).cpp -------------------------------------------------------------------------------- /code/01_dataStructure/segmentTree/template.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mazicwong/ACM_code/b4e774e8fb2087c89c607688600318a7ee6d4571/code/01_dataStructure/segmentTree/template.cpp -------------------------------------------------------------------------------- /code/01_dataStructure/segmentTree/ubdo hdu 1394 线段树 最小逆序数.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mazicwong/ACM_code/b4e774e8fb2087c89c607688600318a7ee6d4571/code/01_dataStructure/segmentTree/ubdo hdu 1394 线段树 最小逆序数.cpp -------------------------------------------------------------------------------- /code/01_dataStructure/segmentTree/zoj 1610 染色区间数.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mazicwong/ACM_code/b4e774e8fb2087c89c607688600318a7ee6d4571/code/01_dataStructure/segmentTree/zoj 1610 染色区间数.cpp -------------------------------------------------------------------------------- /code/01_dataStructure/segmentTree/线段树--区间更新+区间求和+lazy(poj3468).cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mazicwong/ACM_code/b4e774e8fb2087c89c607688600318a7ee6d4571/code/01_dataStructure/segmentTree/线段树--区间更新+区间求和+lazy(poj3468).cpp -------------------------------------------------------------------------------- /code/01_dataStructure/segmentTree/线段树--单点更新+区间最值(hdu1754).cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mazicwong/ACM_code/b4e774e8fb2087c89c607688600318a7ee6d4571/code/01_dataStructure/segmentTree/线段树--单点更新+区间最值(hdu1754).cpp -------------------------------------------------------------------------------- /code/01_dataStructure/union-find/hdu 1198 求连通块---并查集.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mazicwong/ACM_code/b4e774e8fb2087c89c607688600318a7ee6d4571/code/01_dataStructure/union-find/hdu 1198 求连通块---并查集.cpp -------------------------------------------------------------------------------- /code/01_dataStructure/union-find/hdu 1325 poj 1208 并查集.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mazicwong/ACM_code/b4e774e8fb2087c89c607688600318a7ee6d4571/code/01_dataStructure/union-find/hdu 1325 poj 1208 并查集.cpp -------------------------------------------------------------------------------- /code/01_dataStructure/union-find/hdu 1856 基础并查集.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mazicwong/ACM_code/b4e774e8fb2087c89c607688600318a7ee6d4571/code/01_dataStructure/union-find/hdu 1856 基础并查集.cpp -------------------------------------------------------------------------------- /code/01_dataStructure/union-find/hdu 3038 带权并查集.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mazicwong/ACM_code/b4e774e8fb2087c89c607688600318a7ee6d4571/code/01_dataStructure/union-find/hdu 3038 带权并查集.cpp -------------------------------------------------------------------------------- /code/01_dataStructure/union-find/hdu 3047 带权并查集.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mazicwong/ACM_code/b4e774e8fb2087c89c607688600318a7ee6d4571/code/01_dataStructure/union-find/hdu 3047 带权并查集.cpp -------------------------------------------------------------------------------- /code/01_dataStructure/union-find/hdu 3635 并查集.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mazicwong/ACM_code/b4e774e8fb2087c89c607688600318a7ee6d4571/code/01_dataStructure/union-find/hdu 3635 并查集.cpp -------------------------------------------------------------------------------- /code/01_dataStructure/union-find/poj 1182 带权并查集.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mazicwong/ACM_code/b4e774e8fb2087c89c607688600318a7ee6d4571/code/01_dataStructure/union-find/poj 1182 带权并查集.cpp -------------------------------------------------------------------------------- /code/01_dataStructure/主席树/主席树(区间最值).cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mazicwong/ACM_code/b4e774e8fb2087c89c607688600318a7ee6d4571/code/01_dataStructure/主席树/主席树(区间最值).cpp -------------------------------------------------------------------------------- /code/01_dataStructure/前缀和/cf 816B 前缀和扫一遍(好题).cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mazicwong/ACM_code/b4e774e8fb2087c89c607688600318a7ee6d4571/code/01_dataStructure/前缀和/cf 816B 前缀和扫一遍(好题).cpp -------------------------------------------------------------------------------- /code/01_dataStructure/前缀和/hdu 6012 维护区间前缀和.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mazicwong/ACM_code/b4e774e8fb2087c89c607688600318a7ee6d4571/code/01_dataStructure/前缀和/hdu 6012 维护区间前缀和.cpp -------------------------------------------------------------------------------- /code/02_string/AC自动机/1.cpp: -------------------------------------------------------------------------------- 1 | /************************************************************************* 2 | > File Name: 1.cpp 3 | > Author: mazicwong 4 | > Mail: mazicwong@gmail.com 5 | > Created Time: 2017年09月22日 星期五 16时04分19秒 6 | ************************************************************************/ 7 | 8 | #include 9 | #include 10 | #include 11 | #include 12 | #include 13 | #include 14 | #include 15 | #include 16 | #include 17 | #include 18 | #include 19 | #include 20 | using namespace std; 21 | 22 | map mp; 23 | int main() 24 | { 25 | //freopen("in","r",stdin); 26 | char str[100]; 27 | scanf("%s",str); 28 | mp[str]=4; 29 | for (map::iterator it=mp.begin();it!=mp.end();it++) 30 | //printf("%d %d\n",it->first,it->second); 31 | cout << (it->first) << endl << (it->second) << endl; 32 | return 0; 33 | } 34 | -------------------------------------------------------------------------------- /code/02_string/KMP/17计蒜之道1场B题 KMP+模拟.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mazicwong/ACM_code/b4e774e8fb2087c89c607688600318a7ee6d4571/code/02_string/KMP/17计蒜之道1场B题 KMP+模拟.cpp -------------------------------------------------------------------------------- /code/02_string/KMP/hdu 2203 KMP模板题.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mazicwong/ACM_code/b4e774e8fb2087c89c607688600318a7ee6d4571/code/02_string/KMP/hdu 2203 KMP模板题.cpp -------------------------------------------------------------------------------- /code/02_string/KMP/template.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mazicwong/ACM_code/b4e774e8fb2087c89c607688600318a7ee6d4571/code/02_string/KMP/template.cpp -------------------------------------------------------------------------------- /code/02_string/hdu 1039 简单判断字符串.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mazicwong/ACM_code/b4e774e8fb2087c89c607688600318a7ee6d4571/code/02_string/hdu 1039 简单判断字符串.cpp -------------------------------------------------------------------------------- /code/02_string/hdu 1073 字符串处理,模拟OJ系统.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mazicwong/ACM_code/b4e774e8fb2087c89c607688600318a7ee6d4571/code/02_string/hdu 1073 字符串处理,模拟OJ系统.cpp -------------------------------------------------------------------------------- /code/02_string/hdu 2206 字符串处理(IP).cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mazicwong/ACM_code/b4e774e8fb2087c89c607688600318a7ee6d4571/code/02_string/hdu 2206 字符串处理(IP).cpp -------------------------------------------------------------------------------- /code/02_string/hdu 2207 字符串处理 (IP).cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mazicwong/ACM_code/b4e774e8fb2087c89c607688600318a7ee6d4571/code/02_string/hdu 2207 字符串处理 (IP).cpp -------------------------------------------------------------------------------- /code/03_graph/hdu 1116 判断存在欧拉通路.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mazicwong/ACM_code/b4e774e8fb2087c89c607688600318a7ee6d4571/code/03_graph/hdu 1116 判断存在欧拉通路.cpp -------------------------------------------------------------------------------- /code/03_graph/hdu 1285 拓扑排序.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mazicwong/ACM_code/b4e774e8fb2087c89c607688600318a7ee6d4571/code/03_graph/hdu 1285 拓扑排序.cpp -------------------------------------------------------------------------------- /code/03_graph/hdu 1878 是否存在欧拉回路.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mazicwong/ACM_code/b4e774e8fb2087c89c607688600318a7ee6d4571/code/03_graph/hdu 1878 是否存在欧拉回路.cpp -------------------------------------------------------------------------------- /code/03_graph/hdu 2094 拓扑排序判断回路.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mazicwong/ACM_code/b4e774e8fb2087c89c607688600318a7ee6d4571/code/03_graph/hdu 2094 拓扑排序判断回路.cpp -------------------------------------------------------------------------------- /code/03_graph/hdu 2894 转换为欧拉回路.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mazicwong/ACM_code/b4e774e8fb2087c89c607688600318a7ee6d4571/code/03_graph/hdu 2894 转换为欧拉回路.cpp -------------------------------------------------------------------------------- /code/03_graph/hdu 3018 欧拉回路能否一笔画问题.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mazicwong/ACM_code/b4e774e8fb2087c89c607688600318a7ee6d4571/code/03_graph/hdu 3018 欧拉回路能否一笔画问题.cpp -------------------------------------------------------------------------------- /code/03_graph/hdu 3478 二分图判定(染色).cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mazicwong/ACM_code/b4e774e8fb2087c89c607688600318a7ee6d4571/code/03_graph/hdu 3478 二分图判定(染色).cpp -------------------------------------------------------------------------------- /code/03_graph/hdu 5961 暴力搜索(图论)--判断图是否传递.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mazicwong/ACM_code/b4e774e8fb2087c89c607688600318a7ee6d4571/code/03_graph/hdu 5961 暴力搜索(图论)--判断图是否传递.cpp -------------------------------------------------------------------------------- /code/03_graph/leetcode787_步数限制的权值最段路.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # coding=utf-8 3 | 4 | # https://leetcode.com/problems/cheapest-flights-within-k-stops/discuss/115541/JavaPython-Priority-Queue-Solution 5 | # Idea 6 | # It happen to be the same idea of Dijkstra's algorithm, but we need to keep the path 7 | 8 | class Solution: 9 | def findCheapestPrice(self, n: int, flights: List[List[int]], src: int, dst: int, K: int) -> int: 10 | # 步数限制的权值最短路 11 | # delete vis[] in dijkstra 12 | f = collections.defaultdict(dict) 13 | for u,v,w in flights: 14 | f[u][v] = w 15 | heap = [(0, src, K+1)] 16 | while(heap): 17 | w,to,step = heapq.heappop(heap) 18 | if to == dst: 19 | return w 20 | if step>0: 21 | for v in f[to]: 22 | heapq.heappush(heap, (w + f[to][v], v, step-1)) 23 | return -1 24 | -------------------------------------------------------------------------------- /code/03_graph/poj 2386 dfs 类似找连通块.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mazicwong/ACM_code/b4e774e8fb2087c89c607688600318a7ee6d4571/code/03_graph/poj 2386 dfs 类似找连通块.cpp -------------------------------------------------------------------------------- /code/03_graph/最小生成树/hdu 1102 kruskal求最小生成树.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mazicwong/ACM_code/b4e774e8fb2087c89c607688600318a7ee6d4571/code/03_graph/最小生成树/hdu 1102 kruskal求最小生成树.cpp -------------------------------------------------------------------------------- /code/03_graph/最小生成树/hdu 1102 prim求最小生成树.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mazicwong/ACM_code/b4e774e8fb2087c89c607688600318a7ee6d4571/code/03_graph/最小生成树/hdu 1102 prim求最小生成树.cpp -------------------------------------------------------------------------------- /code/03_graph/最小生成树/hdu 1162 kruskal基础题.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mazicwong/ACM_code/b4e774e8fb2087c89c607688600318a7ee6d4571/code/03_graph/最小生成树/hdu 1162 kruskal基础题.cpp -------------------------------------------------------------------------------- /code/03_graph/最小生成树/hdu 1301 kruskal基础题.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mazicwong/ACM_code/b4e774e8fb2087c89c607688600318a7ee6d4571/code/03_graph/最小生成树/hdu 1301 kruskal基础题.cpp -------------------------------------------------------------------------------- /code/03_graph/最小生成树/hdu 1598 kruskal+贪心(枚举).cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mazicwong/ACM_code/b4e774e8fb2087c89c607688600318a7ee6d4571/code/03_graph/最小生成树/hdu 1598 kruskal+贪心(枚举).cpp -------------------------------------------------------------------------------- /code/03_graph/最小生成树/hdu 1863 kruskal模版题.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mazicwong/ACM_code/b4e774e8fb2087c89c607688600318a7ee6d4571/code/03_graph/最小生成树/hdu 1863 kruskal模版题.cpp -------------------------------------------------------------------------------- /code/03_graph/最小生成树/hdu 1875 kruskal模版题+求距离.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mazicwong/ACM_code/b4e774e8fb2087c89c607688600318a7ee6d4571/code/03_graph/最小生成树/hdu 1875 kruskal模版题+求距离.cpp -------------------------------------------------------------------------------- /code/03_graph/最小生成树/hdu 1879 kruskal基础题.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mazicwong/ACM_code/b4e774e8fb2087c89c607688600318a7ee6d4571/code/03_graph/最小生成树/hdu 1879 kruskal基础题.cpp -------------------------------------------------------------------------------- /code/03_graph/最小生成树/hdu 3371 kruskal基础题+并查集.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mazicwong/ACM_code/b4e774e8fb2087c89c607688600318a7ee6d4571/code/03_graph/最小生成树/hdu 3371 kruskal基础题+并查集.cpp -------------------------------------------------------------------------------- /code/03_graph/最短路/dijkstra/hdu 1874 dijkstra 简单.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mazicwong/ACM_code/b4e774e8fb2087c89c607688600318a7ee6d4571/code/03_graph/最短路/dijkstra/hdu 1874 dijkstra 简单.cpp -------------------------------------------------------------------------------- /code/03_graph/最短路/dijkstra/hdu 2066 dijkstra.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mazicwong/ACM_code/b4e774e8fb2087c89c607688600318a7ee6d4571/code/03_graph/最短路/dijkstra/hdu 2066 dijkstra.cpp -------------------------------------------------------------------------------- /code/03_graph/最短路/dijkstra/hdu2544(n*n最短路).cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mazicwong/ACM_code/b4e774e8fb2087c89c607688600318a7ee6d4571/code/03_graph/最短路/dijkstra/hdu2544(n*n最短路).cpp -------------------------------------------------------------------------------- /code/03_graph/最短路/hdu 1874 dijkstra 简单.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mazicwong/ACM_code/b4e774e8fb2087c89c607688600318a7ee6d4571/code/03_graph/最短路/hdu 1874 dijkstra 简单.cpp -------------------------------------------------------------------------------- /code/03_graph/最短路/hdu 2066 dijkstra.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mazicwong/ACM_code/b4e774e8fb2087c89c607688600318a7ee6d4571/code/03_graph/最短路/hdu 2066 dijkstra.cpp -------------------------------------------------------------------------------- /code/03_graph/最短路/hdu2544(n*n最短路).cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mazicwong/ACM_code/b4e774e8fb2087c89c607688600318a7ee6d4571/code/03_graph/最短路/hdu2544(n*n最短路).cpp -------------------------------------------------------------------------------- /code/03_graph/网络流/hdu5988.cpp: -------------------------------------------------------------------------------- 1 | /************************************************************************* 2 | > File Name: hdu5988.cpp 3 | > Author: mazicwong 4 | > Mail: mazicwong@gmail.com 5 | > Created Time: 2017年10月14日 星期六 16时04分25秒 6 | ************************************************************************/ 7 | 8 | #include 9 | #include 10 | #include 11 | #include 12 | #include 13 | #include 14 | #include 15 | #include 16 | #include 17 | #include 18 | #include 19 | #include 20 | using namespace std; 21 | /* 22 | * hdu5988 最小费用最大流 23 | * 24 | * / 25 | 26 | int main() 27 | { 28 | freopen("in","r",stdin); 29 | int T;cin>>T; 30 | while(T--) 31 | { 32 | int n,m; 33 | cin>>n>>m; 34 | for (int i=1;i<=m;i++) 35 | { 36 | scanf("%d%d",&a,&b); 37 | 38 | 39 | } 40 | } 41 | 42 | 43 | return 0; 44 | } 45 | -------------------------------------------------------------------------------- /code/03_graph/网络流/poj1698.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 | using namespace std; 15 | 16 | int T,n; 17 | int f[22][8]; 18 | int Day[55]; 19 | int Week[55]; 20 | 21 | /* 22 | * 电影为点 23 | */ 24 | 25 | bool solve() 26 | { 27 | 28 | 29 | } 30 | 31 | int main() 32 | { 33 | //freopen("in","r",stdin); 34 | cin>>T; 35 | while(T--) 36 | { 37 | cin>>n; 38 | for (int i=0;i File Name: cf868d.cpp 3 | > Author: mazicwong 4 | > Mail: mazicwong@gmail.com 5 | > Created Time: 2017年10月19日 星期四 23时26分20秒 6 | ************************************************************************/ 7 | 8 | #include 9 | #include 10 | #include 11 | #include 12 | #include 13 | #include 14 | #include 15 | #include 16 | #include 17 | #include 18 | #include 19 | #include 20 | using namespace std; 21 | 22 | int main() 23 | { 24 | freopen("in","r",stdin); 25 | int n;cin>>n; 26 | for (int i=0;i>m; 31 | int a,b; 32 | for (int i=0;i 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | using namespace std; 9 | typedef long long ll; 10 | 11 | const int maxn = 100+5; 12 | int dp[maxn][maxn]; 13 | int main() 14 | { 15 | int t; 16 | cin >> t; 17 | while (t--) 18 | { 19 | int n; 20 | cin >> n; 21 | for (int i = 1; i <= n; i++) 22 | for (int j = 1; j <= i; j++) 23 | cin >> dp[i][j]; 24 | for (int i = n-1; i >= 1; i--) 25 | for (int j = 1; j <= n-1; j++) 26 | dp[i][j] += max(dp[i + 1][j], dp[i + 1][j + 1]); 27 | printf("%d\n", dp[1][1]); 28 | } 29 | return 0; 30 | } -------------------------------------------------------------------------------- /code/05_DP/hdu 2085 裸递推.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | using namespace std; 9 | typedef long long ll; 10 | 11 | const int maxn = 35; 12 | ll dp[maxn][2] = {1,0}; 13 | void init() 14 | { 15 | for (int i = 1; i <= 33; i++) 16 | { 17 | dp[i][0] = dp[i - 1][0] * 3 + dp[i - 1][1] * 2; 18 | dp[i][1] = dp[i - 1][0] + dp[i - 1][1]; 19 | } 20 | } 21 | int main() 22 | { 23 | init(); 24 | ll n; 25 | while (cin >> n&&n != -1) 26 | printf("%I64d, %I64d\n", dp[n][0], dp[n][1]); 27 | return 0; 28 | } -------------------------------------------------------------------------------- /code/05_DP/hdu 2089 数位DP入门题.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mazicwong/ACM_code/b4e774e8fb2087c89c607688600318a7ee6d4571/code/05_DP/hdu 2089 数位DP入门题.cpp -------------------------------------------------------------------------------- /code/05_DP/hdu 5890 dp+bitset输入挂.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mazicwong/ACM_code/b4e774e8fb2087c89c607688600318a7ee6d4571/code/05_DP/hdu 5890 dp+bitset输入挂.cpp -------------------------------------------------------------------------------- /code/05_DP/hdu 5900 区间DP+最小费用最大流.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mazicwong/ACM_code/b4e774e8fb2087c89c607688600318a7ee6d4571/code/05_DP/hdu 5900 区间DP+最小费用最大流.cpp -------------------------------------------------------------------------------- /code/05_DP/poj 1664 m果放入n盘,递归+DP写法.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mazicwong/ACM_code/b4e774e8fb2087c89c607688600318a7ee6d4571/code/05_DP/poj 1664 m果放入n盘,递归+DP写法.cpp -------------------------------------------------------------------------------- /code/05_DP/poj1018_undo.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | //max(B/P) min/sum 5 | int n; 6 | int dp[105]; 7 | int main() 8 | { 9 | int t;cin>>t; 10 | memset(dp,0,sizeof(dp)); 11 | double num=-1; 12 | while(t--) 13 | { 14 | cin>>n; 15 | for(int i=1;i<=n;i++) 16 | { 17 | int tmp;cin>>tmp; 18 | for(int j=1;j<=tmp;j++) 19 | { 20 | double m,p;cin>>m>>p; 21 | if(m/p > dp[i]) 22 | { 23 | dp[i]=m/p; 24 | num=min(m,num); 25 | } 26 | } 27 | } 28 | cout< 2 | using namespace std; 3 | //找一个最短的串,使得给定n个串都是他的子串 4 | 5 | //只有15个串,尝试状压,2^15种状态 6 | 7 | const int maxn = 17; 8 | int dp[1<>t; 17 | for(int cas=1;cas<=t;cas++) 18 | { 19 | int n;cin>>n; 20 | cout << "Scenario #" << cas++ << ":\n"; 21 | for(int i=0;i>str[i]; 22 | if(n==1) {cout< 2 | using namespace std; 3 | 4 | const int maxn = 1e3+5; 5 | int dp[maxn][maxn]; 6 | int sum[maxn]; 7 | int a[maxn]; 8 | int main() 9 | { 10 | int n;cin>>n; 11 | for(int i=1;i<=n;i++) cin>>a[i],sum[i]=sum[i-1]+a[i]; 12 | //按照区间长度从小到大DP 13 | for(int len=1;len 2 | #include 3 | #include 4 | #include 5 | using namespace std; 6 | const int maxn=105; 7 | int a[maxn]; 8 | int dp[maxn][maxn]; 9 | //每次取中间的一个数,ans加上连续三个数的乘积,直到剩下两个数,要min{ans} 10 | 11 | int main() 12 | { 13 | //freopen("in","r",stdin); 14 | int n;cin>>n; 15 | for(int i=0;i>a[i]; 16 | memset(dp,0x3f3f3f3f,sizeof(dp)); 17 | for(int i=0;i 2 | #include 3 | #include 4 | #include 5 | 6 | using namespace std; 7 | 8 | const int maxn = 105; 9 | int dp[maxn][maxn]; 10 | string str; 11 | 12 | int main() 13 | { 14 | while(cin>>str && str!="end") 15 | { 16 | int len = str.size(); 17 | memset(dp,0,sizeof(dp)); 18 | for(int l=1;l File Name: hdu1029_sort.cpp 3 | > Author: mazicwong 4 | > Mail: mazicwong@gmail.com 5 | > Created Time: 2017年07月24日 星期一 09时42分48秒 6 | ************************************************************************/ 7 | 8 | #include 9 | #include 10 | #include 11 | #include 12 | #include 13 | #include 14 | using namespace std; 15 | const int maxn = 1e6+5; 16 | int a[maxn]; 17 | int main() 18 | { 19 | int n; 20 | freopen("in","r",stdin); 21 | while(scanf("%d",&n)!=EOF) 22 | { 23 | for (int i=0;i File Name: hdu1171.cpp 3 | > Author: mazicwong 4 | > Mail: mazicwong@gmail.com 5 | > Created Time: 2017年08月05日 星期六 20时51分24秒 6 | ************************************************************************/ 7 | 8 | #include 9 | #include 10 | #include 11 | #include 12 | #include 13 | #include 14 | using namespace std; 15 | 16 | int dp 17 | int main() 18 | { 19 | freopen("in","r",stdin); 20 | int n; 21 | while(scanf("%d",&n) && n>=0) 22 | { 23 | for (int i=1;i<=n;i++) 24 | { 25 | scanf("%d%d",&v[i],&w[i]); 26 | } 27 | } 28 | 29 | return 0; 30 | } 31 | -------------------------------------------------------------------------------- /code/05_DP/背包/hdu6092.cpp: -------------------------------------------------------------------------------- 1 | /************************************************************************* 2 | > File Name: hdu6092.cpp 3 | > Author: mazicwong 4 | > Mail: mazicwong@gmail.com 5 | > Created Time: 2017年11月16日 星期四 09时03分59秒 6 | ************************************************************************/ 7 | 8 | #include 9 | #include 10 | #include 11 | #include 12 | #include 13 | #include 14 | #include 15 | #include 16 | #include 17 | #include 18 | #include 19 | #include 20 | using namespace std; 21 | 22 | int main() 23 | { 24 | //freopen("in","r",stdin); 25 | int T;cin>>T; 26 | while(T--) { 27 | int n,m; 28 | cin>>n>>m; 29 | for (int i=0;i<=m;i++) { 30 | scanf("%d",&b[i]); 31 | } 32 | 33 | } 34 | 35 | return 0; 36 | } 37 | -------------------------------------------------------------------------------- /code/06_greedy/hdu 1051 贪心(排序+多次扫描).cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mazicwong/ACM_code/b4e774e8fb2087c89c607688600318a7ee6d4571/code/06_greedy/hdu 1051 贪心(排序+多次扫描).cpp -------------------------------------------------------------------------------- /code/06_greedy/hdu 5237 简单贪心.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mazicwong/ACM_code/b4e774e8fb2087c89c607688600318a7ee6d4571/code/06_greedy/hdu 5237 简单贪心.cpp -------------------------------------------------------------------------------- /code/06_greedy/hdu 6000 贪心.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mazicwong/ACM_code/b4e774e8fb2087c89c607688600318a7ee6d4571/code/06_greedy/hdu 6000 贪心.cpp -------------------------------------------------------------------------------- /code/06_greedy/hdu 6011 贪心+模拟.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mazicwong/ACM_code/b4e774e8fb2087c89c607688600318a7ee6d4571/code/06_greedy/hdu 6011 贪心+模拟.cpp -------------------------------------------------------------------------------- /code/06_greedy/poj 1852 蚂蚁走路.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mazicwong/ACM_code/b4e774e8fb2087c89c607688600318a7ee6d4571/code/06_greedy/poj 1852 蚂蚁走路.cpp -------------------------------------------------------------------------------- /code/06_greedy/poj 2431 贪心+优先队列.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mazicwong/ACM_code/b4e774e8fb2087c89c607688600318a7ee6d4571/code/06_greedy/poj 2431 贪心+优先队列.cpp -------------------------------------------------------------------------------- /code/06_greedy/poj 3069 贪心 线段取点.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mazicwong/ACM_code/b4e774e8fb2087c89c607688600318a7ee6d4571/code/06_greedy/poj 3069 贪心 线段取点.cpp -------------------------------------------------------------------------------- /code/06_greedy/poj 3253 贪心+优先队列.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mazicwong/ACM_code/b4e774e8fb2087c89c607688600318a7ee6d4571/code/06_greedy/poj 3253 贪心+优先队列.cpp -------------------------------------------------------------------------------- /code/06_greedy/poj 3617 贪心---字典序最小问题.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mazicwong/ACM_code/b4e774e8fb2087c89c607688600318a7ee6d4571/code/06_greedy/poj 3617 贪心---字典序最小问题.cpp -------------------------------------------------------------------------------- /code/07_numberTheory/hdu 1019 多个数最小公倍数.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | using namespace std; 7 | int t; 8 | int n; 9 | typedef long long ll; 10 | int gcd(ll n, ll m) 11 | { 12 | return m ? gcd(m, n%m) : n; 13 | } 14 | int lcm(ll n, ll m) 15 | { 16 | return n *m / gcd(n, m); 17 | } 18 | int main() 19 | { 20 | scanf("%d", &t); 21 | ll tmp; 22 | ll ans = 1; 23 | while (t--) 24 | { 25 | ans = 1; 26 | scanf("%d", &n); 27 | for (int i = 0; i < n; i++) 28 | { 29 | scanf("%lld", &tmp); 30 | ans = lcm(ans, tmp); 31 | } 32 | printf("%lld\n", ans); 33 | } 34 | return 0; 35 | } -------------------------------------------------------------------------------- /code/07_numberTheory/hdu 1286 欧拉值裸.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mazicwong/ACM_code/b4e774e8fb2087c89c607688600318a7ee6d4571/code/07_numberTheory/hdu 1286 欧拉值裸.cpp -------------------------------------------------------------------------------- /code/07_numberTheory/hdu 2098 裸素数表.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | using namespace std; 7 | typedef long long ll; 8 | const int maxn = 1e4 + 5; 9 | 10 | //ll prime[maxn]; 11 | ll isprime[maxn]; 12 | //ll tot=0; 13 | void getprime() 14 | { 15 | memset(isprime,1,sizeof(isprime)); 16 | for (int i=2;i 2 | using namespace std; 3 | 4 | //dp[n][m] = dp[m][m] (n>n>>m; 20 | cout << dfs(n,m); 21 | return 0; 22 | } 23 | -------------------------------------------------------------------------------- /code/10_组合数学/hdu 1018 斯特林公式求n!位数.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mazicwong/ACM_code/b4e774e8fb2087c89c607688600318a7ee6d4571/code/10_组合数学/hdu 1018 斯特林公式求n!位数.cpp -------------------------------------------------------------------------------- /code/10_组合数学/hdu 1028 母函数(整数划分).cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mazicwong/ACM_code/b4e774e8fb2087c89c607688600318a7ee6d4571/code/10_组合数学/hdu 1028 母函数(整数划分).cpp -------------------------------------------------------------------------------- /code/10_组合数学/hdu 1085 母函数(用1.2.5三种硬币最小不能表示的数).cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mazicwong/ACM_code/b4e774e8fb2087c89c607688600318a7ee6d4571/code/10_组合数学/hdu 1085 母函数(用1.2.5三种硬币最小不能表示的数).cpp -------------------------------------------------------------------------------- /code/10_组合数学/hdu 1799 组合数学求C(n,m)+预处理.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mazicwong/ACM_code/b4e774e8fb2087c89c607688600318a7ee6d4571/code/10_组合数学/hdu 1799 组合数学求C(n,m)+预处理.cpp -------------------------------------------------------------------------------- /code/10_组合数学/hdu 2082 母函数入门.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mazicwong/ACM_code/b4e774e8fb2087c89c607688600318a7ee6d4571/code/10_组合数学/hdu 2082 母函数入门.cpp -------------------------------------------------------------------------------- /code/10_组合数学/hdu 2512 第二类斯特林数.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mazicwong/ACM_code/b4e774e8fb2087c89c607688600318a7ee6d4571/code/10_组合数学/hdu 2512 第二类斯特林数.cpp -------------------------------------------------------------------------------- /code/10_组合数学/hdu 2643 第二类斯特林数.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mazicwong/ACM_code/b4e774e8fb2087c89c607688600318a7ee6d4571/code/10_组合数学/hdu 2643 第二类斯特林数.cpp -------------------------------------------------------------------------------- /code/10_组合数学/hdu 3625 第一类斯特林数.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mazicwong/ACM_code/b4e774e8fb2087c89c607688600318a7ee6d4571/code/10_组合数学/hdu 3625 第一类斯特林数.cpp -------------------------------------------------------------------------------- /code/10_组合数学/容斥/hdu 4135 容斥原理--(a,b)间与n互斥个数.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mazicwong/ACM_code/b4e774e8fb2087c89c607688600318a7ee6d4571/code/10_组合数学/容斥/hdu 4135 容斥原理--(a,b)间与n互斥个数.cpp -------------------------------------------------------------------------------- /code/10_组合数学/容斥/hdu 4451 容斥原理+枚举.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mazicwong/ACM_code/b4e774e8fb2087c89c607688600318a7ee6d4571/code/10_组合数学/容斥/hdu 4451 容斥原理+枚举.cpp -------------------------------------------------------------------------------- /code/10_组合数学/容斥/hdu4135未.cpp: -------------------------------------------------------------------------------- 1 | /************************************************************************* 2 | > File Name: hdu4135.cpp 3 | > Author: mazicwong 4 | > Mail: mazicwong@gmail.com 5 | > Created Time: 2017年08月10日 星期四 15时51分32秒 6 | ************************************************************************/ 7 | 8 | #include 9 | #include 10 | #include 11 | #include 12 | #include 13 | #include 14 | using namespace std; 15 | /* 16 | * 求[a,b]中与n互质的个数 17 | * 18 | * 考虑所有n的素因子,记为pi(只考虑素数因子是因为,合数因子也可以分解为素数因子) 19 | * 求[a,b]内有多少个能被pi整除 20 | */ 21 | int main() 22 | { 23 | freopen("in","r",stdin); 24 | 25 | return 0; 26 | } 27 | -------------------------------------------------------------------------------- /code/10_组合数学/斯特林数模版.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mazicwong/ACM_code/b4e774e8fb2087c89c607688600318a7ee6d4571/code/10_组合数学/斯特林数模版.cpp -------------------------------------------------------------------------------- /code/10_组合数学/母函数模版.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mazicwong/ACM_code/b4e774e8fb2087c89c607688600318a7ee6d4571/code/10_组合数学/母函数模版.cpp -------------------------------------------------------------------------------- /code/10_组合数学/生成排列与组合.md: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mazicwong/ACM_code/b4e774e8fb2087c89c607688600318a7ee6d4571/code/10_组合数学/生成排列与组合.md -------------------------------------------------------------------------------- /code/11_计算几何/hdu 1392 凸包(Graham扫描法).cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mazicwong/ACM_code/b4e774e8fb2087c89c607688600318a7ee6d4571/code/11_计算几何/hdu 1392 凸包(Graham扫描法).cpp -------------------------------------------------------------------------------- /code/12_二分答案+判断/cf round 402 D 二分+暴力判断(好题).cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mazicwong/ACM_code/b4e774e8fb2087c89c607688600318a7ee6d4571/code/12_二分答案+判断/cf round 402 D 二分+暴力判断(好题).cpp -------------------------------------------------------------------------------- /code/12_二分答案+判断/hdu 1969 二分查找(难在精度).cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mazicwong/ACM_code/b4e774e8fb2087c89c607688600318a7ee6d4571/code/12_二分答案+判断/hdu 1969 二分查找(难在精度).cpp -------------------------------------------------------------------------------- /code/12_二分答案+判断/hdu 2199 二分暴力查找.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | using namespace std; 4 | double result(double x) 5 | { 6 | return 8 * x*x*x*x + 7 * x*x*x + 2 * x*x + 3 * x + 6; 7 | } 8 | double bs(double front, double tail, double value) 9 | { 10 | if (value < 6 || value>807020306) 11 | return -1; 12 | double mid = (front+tail) / 2; 13 | while (front < tail) 14 | { 15 | if (-1e-5 < result(mid) - value && result(mid) - value < 1e-5) 16 | return mid; 17 | else if (result(mid) < value) 18 | front = mid; 19 | else 20 | tail = mid; 21 | mid = (front + tail) / 2; 22 | } 23 | return mid; 24 | } 25 | int main() 26 | { 27 | int t; 28 | cin >> t; 29 | double y; 30 | while (t--) 31 | { 32 | scanf("%lf", &y); 33 | double ans = bs(0, 100, y); 34 | if (ans < 0) 35 | puts("No solution!"); 36 | else 37 | printf("%.4lf\n", ans); 38 | } 39 | return 0; 40 | } -------------------------------------------------------------------------------- /code/12_二分答案+判断/poj 2456 最大化最小值 largest minimum distance.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mazicwong/ACM_code/b4e774e8fb2087c89c607688600318a7ee6d4571/code/12_二分答案+判断/poj 2456 最大化最小值 largest minimum distance.cpp -------------------------------------------------------------------------------- /code/13_概率期望/hdu 1099 期望入门+分数通分.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mazicwong/ACM_code/b4e774e8fb2087c89c607688600318a7ee6d4571/code/13_概率期望/hdu 1099 期望入门+分数通分.cpp -------------------------------------------------------------------------------- /code/13_概率期望/hdu 1204 Markov过程求期望.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mazicwong/ACM_code/b4e774e8fb2087c89c607688600318a7ee6d4571/code/13_概率期望/hdu 1204 Markov过程求期望.cpp -------------------------------------------------------------------------------- /code/13_概率期望/hdu 4438 简单求期望值.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mazicwong/ACM_code/b4e774e8fb2087c89c607688600318a7ee6d4571/code/13_概率期望/hdu 4438 简单求期望值.cpp -------------------------------------------------------------------------------- /code/13_概率期望/hdu 5245 矩阵概率题求期望.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mazicwong/ACM_code/b4e774e8fb2087c89c607688600318a7ee6d4571/code/13_概率期望/hdu 5245 矩阵概率题求期望.cpp -------------------------------------------------------------------------------- /code/14_递归/hdu 2049 递推.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mazicwong/ACM_code/b4e774e8fb2087c89c607688600318a7ee6d4571/code/14_递归/hdu 2049 递推.cpp -------------------------------------------------------------------------------- /code/14_递归/hdu 2050 递推.cpp: -------------------------------------------------------------------------------- 1 | // 2050 2 | #include 3 | #include 4 | #include 5 | using namespace std; 6 | int main() 7 | { 8 | int t; 9 | cin >> t; 10 | while (t--) 11 | { 12 | int n; 13 | cin >> n; 14 | cout << 2 * n*n - n + 1 << endl; 15 | } 16 | system("pause"); 17 | return 0; 18 | } -------------------------------------------------------------------------------- /code/14_递归/hdu 2067 简单递推.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mazicwong/ACM_code/b4e774e8fb2087c89c607688600318a7ee6d4571/code/14_递归/hdu 2067 简单递推.cpp -------------------------------------------------------------------------------- /code/14_递归/hdu 2431 递推 .cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mazicwong/ACM_code/b4e774e8fb2087c89c607688600318a7ee6d4571/code/14_递归/hdu 2431 递推 .cpp -------------------------------------------------------------------------------- /code/14_递归/hdu 2502 简单递推(好题,可以复习下).cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mazicwong/ACM_code/b4e774e8fb2087c89c607688600318a7ee6d4571/code/14_递归/hdu 2502 简单递推(好题,可以复习下).cpp -------------------------------------------------------------------------------- /code/14_递归/hdu 2563 很好的递推题(列公式算).cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mazicwong/ACM_code/b4e774e8fb2087c89c607688600318a7ee6d4571/code/14_递归/hdu 2563 很好的递推题(列公式算).cpp -------------------------------------------------------------------------------- /code/14_递归/hdu 5965 递推.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mazicwong/ACM_code/b4e774e8fb2087c89c607688600318a7ee6d4571/code/14_递归/hdu 5965 递推.cpp -------------------------------------------------------------------------------- /code/15_分治/hdu5127.cpp: -------------------------------------------------------------------------------- 1 | /************************************************************************* 2 | > File Name: hdu5127.cpp 3 | > Author: mazicwong 4 | > Mail: mazicwong@gmail.com 5 | > Created Time: 2017年09月05日 星期二 15时26分29秒 6 | ************************************************************************/ 7 | 8 | #include 9 | #include 10 | #include 11 | #include 12 | #include 13 | #include 14 | #include 15 | #include 16 | #include 17 | #include 18 | #include 19 | #include 20 | using namespace std; 21 | 22 | int main() 23 | { 24 | freopen("in","r",stdin); 25 | 26 | return 0; 27 | } 28 | -------------------------------------------------------------------------------- /code/16_分块/template: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mazicwong/ACM_code/b4e774e8fb2087c89c607688600318a7ee6d4571/code/16_分块/template -------------------------------------------------------------------------------- /code/17_矩阵/(未完成)5950 矩阵快速幂,构造矩阵.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mazicwong/ACM_code/b4e774e8fb2087c89c607688600318a7ee6d4571/code/17_矩阵/(未完成)5950 矩阵快速幂,构造矩阵.cpp -------------------------------------------------------------------------------- /code/18_常用技巧/xor/hdu 2095 异或找出现奇数次的数.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mazicwong/ACM_code/b4e774e8fb2087c89c607688600318a7ee6d4571/code/18_常用技巧/xor/hdu 2095 异或找出现奇数次的数.cpp -------------------------------------------------------------------------------- /code/18_常用技巧/离散化/STL离散化.cpp: -------------------------------------------------------------------------------- 1 | 离散化:就是将n个数字和1~n对应起来 2 | 使用STL算法离散化: 3 | 思路:先排序,再删除重复元素,然后就是索引元素离散化后对应的值。 4 | 5 | /* 6 | * eg: 7 | * 一组数据:1,4,1000,100000;直接开线段树很浪费,则先离散化 8 | * 9 | * 离散化前 a[i]: 1, 4, 1000, 100000, 10 | * 离散化后 a[i]: 1, 2, 3, 4, 11 | * a[0], a[1], a[2], a[3], 12 | */ 13 | 14 | const int maxn = 100; 15 | int n=6; 16 | int a[maxn];//离散化后的数组a 17 | void lisan(int *arr)//传入数组arr[0..n-1],返回a[0..n-1] 18 | { 19 | for (int i=0;i 2 | 3 | //int型: 4 | srand(time(NULL)); 5 | printf("%d\n",rand()); 6 | 7 | //给定范围: 8 | int t=100; 9 | srand(time(NULL)); 10 | printf("%d\n",rand()%t); 11 | 12 | //double型: 13 | srand(time(NULL)); 14 | printf("%.6lf\n",rand()*1.0/100); 15 | 16 | //字符串 17 | int len=100; 18 | srand(time(NULL)); 19 | while(len--) 20 | { 21 | printf("%c\n",'A'+rand()%26); 22 | } 23 | -------------------------------------------------------------------------------- /code/19_STL/hdu 1113 map(string).cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mazicwong/ACM_code/b4e774e8fb2087c89c607688600318a7ee6d4571/code/19_STL/hdu 1113 map(string).cpp -------------------------------------------------------------------------------- /code/19_STL/hdu 1196 lowbit.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mazicwong/ACM_code/b4e774e8fb2087c89c607688600318a7ee6d4571/code/19_STL/hdu 1196 lowbit.cpp -------------------------------------------------------------------------------- /code/19_STL/hdu 2095 set|map.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mazicwong/ACM_code/b4e774e8fb2087c89c607688600318a7ee6d4571/code/19_STL/hdu 2095 set|map.cpp -------------------------------------------------------------------------------- /code/19_STL/hdu 3785 利用优先队列的排序.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mazicwong/ACM_code/b4e774e8fb2087c89c607688600318a7ee6d4571/code/19_STL/hdu 3785 利用优先队列的排序.cpp -------------------------------------------------------------------------------- /code/19_STL/hdu 3823 vector+暴力枚举.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mazicwong/ACM_code/b4e774e8fb2087c89c607688600318a7ee6d4571/code/19_STL/hdu 3823 vector+暴力枚举.cpp -------------------------------------------------------------------------------- /code/19_STL/hdu 4287 法1--简单字典树+hash映射4.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mazicwong/ACM_code/b4e774e8fb2087c89c607688600318a7ee6d4571/code/19_STL/hdu 4287 法1--简单字典树+hash映射4.cpp -------------------------------------------------------------------------------- /code/19_STL/hdu 4287 法2--STL做法,好题.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mazicwong/ACM_code/b4e774e8fb2087c89c607688600318a7ee6d4571/code/19_STL/hdu 4287 法2--STL做法,好题.cpp -------------------------------------------------------------------------------- /code/19_STL/hdu 4858 vector.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mazicwong/ACM_code/b4e774e8fb2087c89c607688600318a7ee6d4571/code/19_STL/hdu 4858 vector.cpp -------------------------------------------------------------------------------- /code/19_STL/hdu 5127 VectorList区别.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mazicwong/ACM_code/b4e774e8fb2087c89c607688600318a7ee6d4571/code/19_STL/hdu 5127 VectorList区别.cpp -------------------------------------------------------------------------------- /code/19_STL/hdu 6015 STL map,pque.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | using namespace std; 10 | typedef long long ll; 11 | const int maxn = 5e4 + 5; 12 | int main() 13 | { 14 | int t; 15 | int n; 16 | scanf("%d", &t); 17 | while(t--) 18 | { 19 | scanf("%d", &n); 20 | map < string, priority_queue >mp; 21 | string str; 22 | int num; 23 | int ans = 0; 24 | for (int i = 0; i < n; i++) 25 | { 26 | cin >> str >> num; 27 | mp[str].push(num); 28 | } 29 | int tt = mp.size(); 30 | map < string, priority_queue >::iterator it=mp.begin(); 31 | for (; it != mp.end(); it++) 32 | { 33 | int cnt = 0; 34 | while (cnt < 2 &&!it->second.empty()) 35 | { 36 | ans += it->second.top(); 37 | it->second.pop(); 38 | cnt++; 39 | } 40 | } 41 | printf("%d\n", ans); 42 | } 43 | return 0; 44 | } -------------------------------------------------------------------------------- /code/19_STL/map-set练习.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mazicwong/ACM_code/b4e774e8fb2087c89c607688600318a7ee6d4571/code/19_STL/map-set练习.cpp -------------------------------------------------------------------------------- /code/20_数学题/hdu 1006 钟表角度问题(模拟+区间交集+数学).cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mazicwong/ACM_code/b4e774e8fb2087c89c607688600318a7ee6d4571/code/20_数学题/hdu 1006 钟表角度问题(模拟+区间交集+数学).cpp -------------------------------------------------------------------------------- /code/20_数学题/hdu 1029 鸽巢原理(出现次数大于一半的数).cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mazicwong/ACM_code/b4e774e8fb2087c89c607688600318a7ee6d4571/code/20_数学题/hdu 1029 鸽巢原理(出现次数大于一半的数).cpp -------------------------------------------------------------------------------- /code/20_数学题/hdu 1071 定积分.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | using namespace std; 5 | int main() 6 | { 7 | // y = k*x+b 8 | // y = a(x-h)^2+c 9 | int t; 10 | scanf("%d", &t); 11 | double x0, y0, x1, y1, x2, y2; 12 | double k, b; 13 | double a, c, h; 14 | while (t--) 15 | { 16 | scanf("%lf %lf %lf %lf %lf %lf", &x0, &y0, &x1, &y1, &x2, &y2); 17 | k = (y2 - y1) / (x2 - x1); 18 | b = y1 - k*x1; 19 | h = x0; 20 | c = y0; 21 | a = (y1 - c) / ((x1 - h)*(x1 - h)); 22 | double ans = (a*x2*x2*x2 / 3 - (2 * a*h + k)*x2*x2 / 2 + (a*h*h + c - b)*x2) - (a*x1*x1*x1 / 3 - (2 * a*h + k)*x1*x1 / 2 + (a*h*h + c - b)*x1); 23 | printf("%.2f\n", ans); 24 | } 25 | return 0; 26 | } -------------------------------------------------------------------------------- /code/20_数学题/hdu 1076 从y开始的第n个闰年.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mazicwong/ACM_code/b4e774e8fb2087c89c607688600318a7ee6d4571/code/20_数学题/hdu 1076 从y开始的第n个闰年.cpp -------------------------------------------------------------------------------- /code/20_数学题/hdu 1086 求m个线段交点数.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mazicwong/ACM_code/b4e774e8fb2087c89c607688600318a7ee6d4571/code/20_数学题/hdu 1086 求m个线段交点数.cpp -------------------------------------------------------------------------------- /code/20_数学题/hdu 1271 (数学题)把一个数拆成整数对.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mazicwong/ACM_code/b4e774e8fb2087c89c607688600318a7ee6d4571/code/20_数学题/hdu 1271 (数学题)把一个数拆成整数对.cpp -------------------------------------------------------------------------------- /code/20_数学题/hdu 1999 因子和,类似筛选素数.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mazicwong/ACM_code/b4e774e8fb2087c89c607688600318a7ee6d4571/code/20_数学题/hdu 1999 因子和,类似筛选素数.cpp -------------------------------------------------------------------------------- /code/20_数学题/hdu 2056 矩形面积.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mazicwong/ACM_code/b4e774e8fb2087c89c607688600318a7ee6d4571/code/20_数学题/hdu 2056 矩形面积.cpp -------------------------------------------------------------------------------- /code/20_数学题/hdu 2073 计算距离.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mazicwong/ACM_code/b4e774e8fb2087c89c607688600318a7ee6d4571/code/20_数学题/hdu 2073 计算距离.cpp -------------------------------------------------------------------------------- /code/20_数学题/hdu 2086 数学题---可怕....cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mazicwong/ACM_code/b4e774e8fb2087c89c607688600318a7ee6d4571/code/20_数学题/hdu 2086 数学题---可怕....cpp -------------------------------------------------------------------------------- /code/20_数学题/hdu 2393 水题,判断是否直角三角形.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | using namespace std; 8 | int main() 9 | { 10 | int t; 11 | cin >> t; 12 | for (int cas = 1; cas <= t; cas++) 13 | { 14 | int a, b, c; 15 | cin >> a >> b >> c; 16 | if (a*a + b*b == c*c || b*b + c*c == a*a || a*a + c*c == b*b) 17 | cout << "Scenario #" << cas << ':' << endl << "yes" << endl; 18 | else 19 | cout << "Scenario #" << cas << ':' << endl << "no" << endl; 20 | cout << endl; 21 | } 22 | return 0; 23 | } -------------------------------------------------------------------------------- /code/20_数学题/hdu 2503 分数化简.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mazicwong/ACM_code/b4e774e8fb2087c89c607688600318a7ee6d4571/code/20_数学题/hdu 2503 分数化简.cpp -------------------------------------------------------------------------------- /code/20_数学题/hdu 2504 gcd最大公因数.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mazicwong/ACM_code/b4e774e8fb2087c89c607688600318a7ee6d4571/code/20_数学题/hdu 2504 gcd最大公因数.cpp -------------------------------------------------------------------------------- /code/20_数学题/hdu 3299 枚举+扫描(难).cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mazicwong/ACM_code/b4e774e8fb2087c89c607688600318a7ee6d4571/code/20_数学题/hdu 3299 枚举+扫描(难).cpp -------------------------------------------------------------------------------- /code/20_数学题/hdu 4432 求n因子和+进制转化.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mazicwong/ACM_code/b4e774e8fb2087c89c607688600318a7ee6d4571/code/20_数学题/hdu 4432 求n因子和+进制转化.cpp -------------------------------------------------------------------------------- /code/20_数学题/hdu 4452 模拟,太多方向,略复杂.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mazicwong/ACM_code/b4e774e8fb2087c89c607688600318a7ee6d4571/code/20_数学题/hdu 4452 模拟,太多方向,略复杂.cpp -------------------------------------------------------------------------------- /code/20_数学题/hdu 5495 置换群+LCS.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mazicwong/ACM_code/b4e774e8fb2087c89c607688600318a7ee6d4571/code/20_数学题/hdu 5495 置换群+LCS.cpp -------------------------------------------------------------------------------- /code/20_数学题/未完成 poj 3716 beyes.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mazicwong/ACM_code/b4e774e8fb2087c89c607688600318a7ee6d4571/code/20_数学题/未完成 poj 3716 beyes.cpp -------------------------------------------------------------------------------- /code/GDCPC2013/A Temple Run 简单公式.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mazicwong/ACM_code/b4e774e8fb2087c89c607688600318a7ee6d4571/code/GDCPC2013/A Temple Run 简单公式.cpp -------------------------------------------------------------------------------- /code/GDCPC2013/B Young Tableau (STL multiset).cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mazicwong/ACM_code/b4e774e8fb2087c89c607688600318a7ee6d4571/code/GDCPC2013/B Young Tableau (STL multiset).cpp -------------------------------------------------------------------------------- /code/GDCPC2013/F Pokemon.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mazicwong/ACM_code/b4e774e8fb2087c89c607688600318a7ee6d4571/code/GDCPC2013/F Pokemon.cpp -------------------------------------------------------------------------------- /code/GDCPC2013/README.md: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mazicwong/ACM_code/b4e774e8fb2087c89c607688600318a7ee6d4571/code/GDCPC2013/README.md -------------------------------------------------------------------------------- /code/GDCPC2013/prepareFor2017GDCPC.doc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mazicwong/ACM_code/b4e774e8fb2087c89c607688600318a7ee6d4571/code/GDCPC2013/prepareFor2017GDCPC.doc -------------------------------------------------------------------------------- /code/README.md: -------------------------------------------------------------------------------- 1 | # python code 2 | - https://github.com/mazicwong/algorithm-pattern-python 3 | - 4 | 5 | # Deep Learning 6 | - https://github.com/scutan90/DeepLearning-500-questions 7 | - https://github.com/datawhalechina/pumpkin-book -------------------------------------------------------------------------------- /code/basic/acm_class/1001.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | //开始结束, 求最多 4 | const int maxn = 105; 5 | int st[maxn]; int en[maxn]; 6 | int ans=0; 7 | struct Node{ 8 | int st; 9 | int en; 10 | bool operator <(const Node &x)const{ 11 | if(en == x.en) 12 | return st>n && n) 20 | { 21 | for(int i=0;i>node[i].st>>node[i].en; 22 | sort(node,node+n); 23 | int now=0; 24 | ans=0; 25 | for(int i=0;i 2 | #include 3 | #include 4 | #include 5 | #include 6 | using namespace std; 7 | typedef long long ll; 8 | const int maxn = 100 + 5; 9 | int a[maxn]; 10 | int b[maxn]; 11 | 12 | int main() 13 | { 14 | freopen("in.txt", "r", stdin); 15 | int n, k; 16 | cin >> n >> k; 17 | for (int i = 0; i < n; i++) 18 | cin >> a[i]; 19 | for (int i = 0; i < k; i++) 20 | cin >> b[i]; 21 | if (k > 1) 22 | cout << "Yes"; 23 | else 24 | { 25 | for (int i = 0; i < n; i++) 26 | { 27 | if (a[i] == 0) 28 | { 29 | a[i] = b[0]; 30 | break; 31 | } 32 | } 33 | for (int i = 0; i < n - 1; i++) 34 | { 35 | if (a[i] > a[i + 1]) 36 | { 37 | cout << "Yes"; 38 | return 0; 39 | } 40 | } 41 | cout << "No"; 42 | } 43 | 44 | 45 | return 0; 46 | } -------------------------------------------------------------------------------- /code/basic/cf 816A 简单规律.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mazicwong/ACM_code/b4e774e8fb2087c89c607688600318a7ee6d4571/code/basic/cf 816A 简单规律.cpp -------------------------------------------------------------------------------- /code/basic/cf 817A.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | using namespace std; 8 | 9 | int main() 10 | { 11 | freopen("in.txt", "r", stdin); 12 | int x1, y1, x2, y2; 13 | int x, y; 14 | cin >> x1 >> y1 >> x2 >> y2; 15 | cin >> x >> y; 16 | 17 | int abxx = abs(x1 - x2); 18 | int abyy = abs(y1 - y2); 19 | if (abxx%x != 0 || abyy%y != 0) 20 | { 21 | cout << "NO"; 22 | return 0; 23 | } 24 | abxx /= x; 25 | abyy /= y; 26 | 27 | 28 | 29 | if (abs(abxx - abyy) % 2 == 0) 30 | cout << "YES"; 31 | else 32 | cout << "NO"; 33 | 34 | 35 | return 0; 36 | } -------------------------------------------------------------------------------- /code/basic/cf865a.cpp: -------------------------------------------------------------------------------- 1 | /************************************************************************* 2 | > File Name: 2.cpp 3 | > Author: mazicwong 4 | > Mail: mazicwong@gmail.com 5 | > Created Time: 2017年10月01日 星期日 01时11分46秒 6 | ************************************************************************/ 7 | 8 | #include 9 | #include 10 | #include 11 | #include 12 | #include 13 | #include 14 | #include 15 | #include 16 | #include 17 | #include 18 | #include 19 | #include 20 | using namespace std; 21 | 22 | int main() 23 | { 24 | int n; 25 | cin>>n; 26 | 27 | if (n==1) 28 | { 29 | printf("1 1\n1"); 30 | return 0; 31 | } 32 | 33 | cout << (n-1)*2 << ' ' << 2 << endl; 34 | cout << "1 2"; 35 | 36 | return 0; 37 | } 38 | -------------------------------------------------------------------------------- /code/basic/guanggong/a.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | long long dp[35]; 5 | void pre() 6 | { 7 | dp[1]=1; 8 | dp[2]=2; 9 | for(int i=3;i<=30;i++){ 10 | for(int j=1;j>t; 21 | while(t--) 22 | { 23 | long long n;cin>>n; 24 | cout< 2 | using namespace std; 3 | 4 | int main() 5 | { 6 | cout << "a"<<"c";//what?? 7 | 8 | return 0; 9 | } 10 | -------------------------------------------------------------------------------- /code/basic/guanggong/l.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | const double eps=1e-6; 4 | int main() 5 | { 6 | int t;cin>>t; 7 | while(t--) 8 | { 9 | int x,a,y,b; 10 | cin>>x>>a>>y>>b; 11 | //cout << pow(2,20) << endl; 12 | //cout << pow(4,10) << endl; 13 | if((double)x-pow(y,(double)b/(double)a) < eps) 14 | cout << "Yes" << endl; 15 | else cout << "No" << endl; 16 | } 17 | 18 | return 0; 19 | } 20 | -------------------------------------------------------------------------------- /code/basic/guanggong/l.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # coding=utf-8 3 | t=int(input()) 4 | for i in range(t): 5 | x=int(input()) 6 | a=int(input()) 7 | y=int(input()) 8 | b=int(input()) 9 | if(x == pow(y,b/a)): 10 | print("Yes") 11 | else: 12 | print("No") 13 | 14 | -------------------------------------------------------------------------------- /code/basic/hdu 1017.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | using namespace std; 6 | 7 | int main() 8 | { 9 | int a, b; 10 | int n, m; 11 | int t; 12 | cin >> t; 13 | while(t--) 14 | { 15 | int cas = 0; 16 | while (1) 17 | { 18 | int ans = 0; 19 | cin >> n >> m; 20 | if (n == 0 && m == 0) 21 | break; 22 | for (int a = 1; a < n; a++) 23 | { 24 | for (int b = a + 1; b < n; b++) 25 | { 26 | if ((a*a + b*b + m) % (a*b) == 0) 27 | ans++; 28 | } 29 | } 30 | printf("Case %d: %d\n", ++cas, ans); 31 | } 32 | if (t!=0) 33 | puts(""); 34 | } 35 | 36 | return 0; 37 | } -------------------------------------------------------------------------------- /code/basic/hdu 1021.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mazicwong/ACM_code/b4e774e8fb2087c89c607688600318a7ee6d4571/code/basic/hdu 1021.cpp -------------------------------------------------------------------------------- /code/basic/hdu 1033 模拟水题.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mazicwong/ACM_code/b4e774e8fb2087c89c607688600318a7ee6d4571/code/basic/hdu 1033 模拟水题.cpp -------------------------------------------------------------------------------- /code/basic/hdu 1037.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | using namespace std; 6 | 7 | int main() 8 | { 9 | int a; 10 | int cnt = 168; 11 | bool flag = false; 12 | for (int i = 1; i <= 3; i++) 13 | { 14 | scanf("%d", &a); 15 | if (!flag && a <= 168) 16 | { 17 | printf("CRASH %d\n", a); 18 | flag = true; 19 | } 20 | } 21 | if (!flag) 22 | printf("NO CRASH\n"); 23 | 24 | return 0; 25 | } -------------------------------------------------------------------------------- /code/basic/hdu 1048.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | using namespace std; 5 | int main() 6 | { 7 | char str[200]; 8 | int n; 9 | while (gets_s(str) != NULL && strcmp(str, "ENDOFINPUT")) 10 | { 11 | if (strcmp(str, "START") == 0 || strcmp(str, "END") == 0) 12 | continue; 13 | for (int i = 0; i < strlen(str); i++) 14 | { 15 | if (str[i] >= 'A') 16 | { 17 | if (str[i] <= 'E') 18 | { 19 | str[i] = 'V' + str[i] - 'A'; 20 | printf("%c", str[i]); 21 | } 22 | else 23 | printf("%c", str[i] - 5); 24 | } 25 | else 26 | printf("%c", str[i]); 27 | } 28 | puts(""); 29 | } 30 | return 0; 31 | } -------------------------------------------------------------------------------- /code/basic/hdu 1064.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mazicwong/ACM_code/b4e774e8fb2087c89c607688600318a7ee6d4571/code/basic/hdu 1064.cpp -------------------------------------------------------------------------------- /code/basic/hdu 1084 水题 排序+模拟.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mazicwong/ACM_code/b4e774e8fb2087c89c607688600318a7ee6d4571/code/basic/hdu 1084 水题 排序+模拟.cpp -------------------------------------------------------------------------------- /code/basic/hdu 1106 排序 水题 .cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mazicwong/ACM_code/b4e774e8fb2087c89c607688600318a7ee6d4571/code/basic/hdu 1106 排序 水题 .cpp -------------------------------------------------------------------------------- /code/basic/hdu 1170 水题-switch.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | using namespace std; 4 | int main() 5 | { 6 | int t; 7 | scanf("%d%*c", &t); 8 | while (t--) 9 | { 10 | char x; 11 | int a, b; 12 | scanf("%c%d%d%*c", &x, &a, &b); 13 | switch (x) 14 | { 15 | case '+': 16 | printf("%d\n", a + b); 17 | break; 18 | case '-': 19 | printf("%d\n", a - b); 20 | break; 21 | case '*': 22 | printf("%d\n", a*b); 23 | break; 24 | case '/': 25 | double ans = (double)a / (double)b; 26 | if ((int)ans - ans == 0) 27 | printf("%.0lf\n", ans); 28 | else 29 | printf("%.2lf\n", ans); 30 | } 31 | } 32 | return 0; 33 | } -------------------------------------------------------------------------------- /code/basic/hdu 1228 简单map.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | hdu 1228 3 | */ 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | using namespace std; 10 | /* 11 | 12 | 13 | 14 | */ 15 | const int maxn = 1 << 15 + 5; 16 | mapmp; 17 | 18 | int main() 19 | { 20 | mp["zero"] = 0; 21 | mp["one"] = 1; 22 | mp["two"] = 2; 23 | mp["three"] = 3; 24 | mp["four"] = 4; 25 | mp["five"] = 5; 26 | mp["six"] = 6; 27 | mp["seven"] = 7; 28 | mp["eight"] = 8; 29 | mp["nine"] = 9; 30 | mp["ten"] = 10; 31 | string str; 32 | while (1) 33 | { 34 | int a = 0; 35 | int b = 0; 36 | while (cin >> str) 37 | { 38 | if (str == "+") 39 | break; 40 | a = a * 10 + mp[str]; 41 | } 42 | while (cin >> str) 43 | { 44 | if (str == "=") 45 | break; 46 | b = b * 10 + mp[str]; 47 | } 48 | if (a == 0 & b == 0) 49 | break; 50 | else 51 | cout << a + b << endl; 52 | } 53 | 54 | return 0; 55 | } -------------------------------------------------------------------------------- /code/basic/hdu 1229 简单a+b.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mazicwong/ACM_code/b4e774e8fb2087c89c607688600318a7ee6d4571/code/basic/hdu 1229 简单a+b.cpp -------------------------------------------------------------------------------- /code/basic/hdu 1622 简单模拟.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mazicwong/ACM_code/b4e774e8fb2087c89c607688600318a7ee6d4571/code/basic/hdu 1622 简单模拟.cpp -------------------------------------------------------------------------------- /code/basic/hdu 1994.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | using namespace std; 9 | typedef long long ll; 10 | 11 | const int maxn = 1e6 + 5; 12 | 13 | int t; 14 | double y, q, e, f, g; 15 | int main() 16 | { 17 | cin >> t; 18 | while (t--) 19 | { 20 | cin >> y >> q >> e >> f >> g; 21 | double ans1 = 0, ans2 = 0; 22 | ans1 = y*(1 + e / 100 * q / 365); 23 | ans1 += ans1* g / 100; 24 | ans2 = y*(1 + f / 100 * (365 + q) / 365); 25 | printf("%.1lf\n%.1lf\n", ans1, ans2); 26 | } 27 | return 0; 28 | } -------------------------------------------------------------------------------- /code/basic/hdu 2053 模拟.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mazicwong/ACM_code/b4e774e8fb2087c89c607688600318a7ee6d4571/code/basic/hdu 2053 模拟.cpp -------------------------------------------------------------------------------- /code/basic/hdu 2060水题.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | using namespace std; 4 | int main() 5 | { 6 | int n; 7 | cin >> n; 8 | while (n--) 9 | { 10 | int left, a, b; 11 | cin >> left >> a >> b; 12 | if (left > 6)//there must have red left behind 13 | a += (left - 6) * 7 + (left - 6) + 2 + 3 + 4 + 5 + 6 + 7; 14 | else 15 | a += left*(15-left)/2; 16 | cout << (a >= b ? "Yes" : "No") < 2 | #include 3 | #include 4 | #include 5 | using namespace std; 6 | int main() 7 | { 8 | int n; 9 | cin >> n; 10 | string str = "HDU"; 11 | int t; 12 | while (n--) 13 | { 14 | cin >> t; 15 | for (int i = 0; i < 3*t; i++) 16 | { 17 | for (int j = 0; j < t; j++) 18 | { 19 | cout << str; 20 | } 21 | cout << endl; 22 | } 23 | } 24 | return 0; 25 | } -------------------------------------------------------------------------------- /code/basic/hdu 2501 简单方块递推.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | using namespace std; 6 | const int maxn = 33; 7 | int dp[maxn]; 8 | void init() 9 | { 10 | dp[0] = 0; dp[1] = 1; dp[2] = 3; 11 | for (int i = 3; i < maxn; i++) 12 | dp[i] = dp[i - 1] + dp[i - 2] * 2; 13 | } 14 | int main() 15 | { 16 | int n,t; 17 | cin >> t; 18 | init(); 19 | while (t--) 20 | { 21 | cin >> n; 22 | cout << dp[n] << endl; 23 | } 24 | return 0; 25 | } -------------------------------------------------------------------------------- /code/basic/hdu 2510 暴力打表.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mazicwong/ACM_code/b4e774e8fb2087c89c607688600318a7ee6d4571/code/basic/hdu 2510 暴力打表.cpp -------------------------------------------------------------------------------- /code/basic/hdu 2561 水题排序.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | using namespace std; 9 | int main() 10 | { 11 | int t; 12 | cin >> t; 13 | priority_queue, greater > pque; 14 | while (t--) 15 | { 16 | while (!pque.empty()) 17 | pque.pop(); 18 | int n; 19 | cin >> n; 20 | for (int i = 0; i < n; i++) 21 | { 22 | int a; 23 | cin >> a; 24 | pque.push(a); 25 | } 26 | pque.pop(); 27 | printf("%d\n", pque.top()); 28 | } 29 | return 0; 30 | } -------------------------------------------------------------------------------- /code/basic/hdu 2562.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | using namespace std; 9 | const int maxn = 55; 10 | char x[maxn]; 11 | int main() 12 | { 13 | int t; 14 | cin >> t; 15 | while (t--) 16 | { 17 | scanf("%s", x); 18 | int len = strlen(x); 19 | for (int i = 0; i < len; i+=2 ) 20 | { 21 | printf("%c%c", x[i + 1], x[i]); 22 | } 23 | puts(""); 24 | } 25 | return 0; 26 | } -------------------------------------------------------------------------------- /code/basic/hdu 4278 简单 转换为八进制.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mazicwong/ACM_code/b4e774e8fb2087c89c607688600318a7ee6d4571/code/basic/hdu 4278 简单 转换为八进制.cpp -------------------------------------------------------------------------------- /code/basic/hdu 4450 水.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | hdu 4450 3 | */ 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | using namespace std; 12 | typedef long long ll; 13 | int main() 14 | { 15 | int n; 16 | while (scanf("%d", &n) != EOF&&n) 17 | { 18 | int ans = 0; 19 | for (int i = 0; i < n; i++) 20 | { 21 | int x; 22 | scanf("%d", &x); 23 | ans += x*x; 24 | } 25 | printf("%d\n", ans); 26 | } 27 | return 0; 28 | } -------------------------------------------------------------------------------- /code/basic/hdu 5038 简单模拟求解.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mazicwong/ACM_code/b4e774e8fb2087c89c607688600318a7ee6d4571/code/basic/hdu 5038 简单模拟求解.cpp -------------------------------------------------------------------------------- /code/basic/hdu 5567 简单暴力 .cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | 6 | using namespace std; 7 | const int maxn = 105; 8 | int a[maxn],n, b, c; 9 | int main() 10 | { 11 | while (scanf("%d%d%d", &n, &b, &c)!=EOF) 12 | { 13 | int ans = 0; 14 | for (int i = 0; i 2 | #include 3 | #include 4 | using namespace std; 5 | /* 6 | give a string of 01 (0 means off) 7 | and then find if there is a path that can turn off all the light and finally reach to the right 8 | for each crossing one light,the status will be reversed 9 | Obviously,if light a[i] is 0,which will become 1 I reaching it, 10 | so a[i+1] have to become 1-a[i] to pass a[i] twice, 11 | finally if a[n-1] is 0 ,then yes 12 | else no 13 | */ 14 | const int maxn = 1e6 + 5; 15 | int a[maxn]; 16 | int n; 17 | bool dfs() 18 | { 19 | for (int i = 0; i < n; i++) 20 | if (!a[i]) 21 | a[i + 1] = 1 - a[i + 1]; 22 | return a[n - 1]; 23 | } 24 | int main() 25 | { 26 | int t; 27 | cin >> t; 28 | while (t--) 29 | { 30 | cin >> n; 31 | for (int i = 0; i < n; i++) 32 | scanf("%d", &a[i]); 33 | if (dfs()) 34 | cout << "YES" << endl; 35 | else cout << "NO" << endl; 36 | } 37 | 38 | return 0; 39 | } -------------------------------------------------------------------------------- /code/basic/hdu 5601 简单模拟.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mazicwong/ACM_code/b4e774e8fb2087c89c607688600318a7ee6d4571/code/basic/hdu 5601 简单模拟.cpp -------------------------------------------------------------------------------- /code/basic/hdu 6106 二分图思维题.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mazicwong/ACM_code/b4e774e8fb2087c89c607688600318a7ee6d4571/code/basic/hdu 6106 二分图思维题.cpp -------------------------------------------------------------------------------- /code/basic/hdu2212.cpp: -------------------------------------------------------------------------------- 1 | //hdu2212.cpp 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 | using namespace std; 15 | typedef long long ll; 16 | int fac[10]={1,1,2,6,24,120,720,5040,40320,362880}; 17 | int main() 18 | { 19 | //freopen("in","r",stdin); 20 | queue Q; while(!Q.empty()) Q.pop(); 21 | /*for (int i=1;i<=2147483647;i++) { 22 | int tmp=i; 23 | int sum=0; 24 | while(tmp){ 25 | int tt = tmp%10; 26 | tmp/=10; 27 | sum+=fac[tt]; 28 | } 29 | if (sum==i) { 30 | Q.push(i); 31 | cout << i << endl; 32 | } 33 | }*/ 34 | cout << "1\n2\n145\n40585\n"; 35 | 36 | return 0; 37 | } 38 | -------------------------------------------------------------------------------- /code/basic/hdu4920.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | inline int read() 5 | { 6 | int x=0,f=1;char ch=getchar(); 7 | while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();} 8 | while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();} 9 | return x*f; 10 | } 11 | 12 | int main() 13 | { 14 | int n; 15 | while(cin>>n) 16 | { 17 | for(int i=1;i<=n;i++) for (int j=1;j<=n;j++) a[i][j]=read(); 18 | for(int i=1;i<=n;i++) for (int j=1;j<=n;j++) b[i][j]=read(); 19 | } 20 | 21 | return 0; 22 | } 23 | -------------------------------------------------------------------------------- /code/basic/jisuanke/lq/1.cpp: -------------------------------------------------------------------------------- 1 | //1.cpp 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 | using namespace std; 15 | 16 | int main() 17 | { 18 | //freopen("in","r",stdin); 19 | int cnt = 0; 20 | for (int i=10;i<100;i++) 21 | { 22 | for (int j=10;j<100;j++) 23 | { 24 | if (i == (j%10+j/10)*2 && j == (i%10+i/10)*3) 25 | { 26 | cnt++; 27 | cout << i << " " << j << endl; 28 | } 29 | } 30 | } 31 | cout << cnt; 32 | 33 | return 0; 34 | } 35 | -------------------------------------------------------------------------------- /code/basic/jisuanke/lq/17/1.cpp: -------------------------------------------------------------------------------- 1 | //1.cpp 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 | using namespace std; 15 | const int maxn = 1e6+5; 16 | 17 | int yu[maxn]; 18 | int num[maxn]; 19 | int main() 20 | { 21 | //freopen("in","r",stdin); 22 | int n; cin>>n; 23 | yu[0]=0; yu[1]=1; yu[2]=1; 24 | for (int i=3;i 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | #include 12 | #include 13 | #include 14 | using namespace std; 15 | const double pi = acos(-1); 16 | int main() 17 | { 18 | //freopen("in","r",stdin); 19 | int r; 20 | cin >> r; 21 | printf("%.7lf",pi*r*r); 22 | return 0; 23 | } 24 | -------------------------------------------------------------------------------- /code/basic/jisuanke/lq/17/3.cpp: -------------------------------------------------------------------------------- 1 | //3.cpp 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 | using namespace std; 15 | typedef long long ll; 16 | 17 | int main() 18 | { 19 | //freopen("in","r",stdin); 20 | int n;cin>>n; 21 | cout << 1ll*(1+n)*n/2; 22 | 23 | return 0; 24 | } 25 | -------------------------------------------------------------------------------- /code/basic/jisuanke/lq/17/4.cpp: -------------------------------------------------------------------------------- 1 | //4.cpp 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 | using namespace std; 15 | 16 | int main() 17 | { 18 | //freopen("in","r",stdin); 19 | int a,b; cin>>a>>b; 20 | cout << a+b; 21 | 22 | return 0; 23 | } 24 | -------------------------------------------------------------------------------- /code/basic/jisuanke/lq/2014-03-25/21.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | int n; 4 | bool check(int x) 5 | { 6 | int res=0; 7 | while(x>0) 8 | { 9 | res += x%10; 10 | x/=10; 11 | } 12 | return res==n; 13 | } 14 | 15 | bool judge(int x) 16 | { 17 | int a[10]; 18 | int b[10]; 19 | int cnt=0; 20 | while(x>0) 21 | { 22 | a[cnt++] = x%10; 23 | x/=10; 24 | } 25 | for(int i=0;i>n; 38 | int cnt=0; 39 | for(int i=10000;i<=999999;i++) 40 | { 41 | if(check(i)==true && judge(i)==true) 42 | { 43 | cout< 2 | using namespace std; 3 | 4 | int main() 5 | { 6 | 7 | return 0; 8 | } 9 | -------------------------------------------------------------------------------- /code/basic/jisuanke/lq/practice5/2.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | int main() 5 | { 6 | 7 | return 0; 8 | } 9 | -------------------------------------------------------------------------------- /code/basic/jisuanke/lq/practice5/3.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | int a[25]; 4 | int main() 5 | { 6 | int ans=0; 7 | a[1]=1; 8 | a[2]=3; 9 | a[3]=6; 10 | a[4]=10; 11 | 12 | int now=0; 13 | int pre=10; 14 | for(int n=5;n<=20;n++) 15 | { 16 | a[n] = a[n-1]*1 + n; 17 | } 18 | cout << a[20]; 19 | cout << endl << a[6]; 20 | 21 | return 0; 22 | } 23 | -------------------------------------------------------------------------------- /code/basic/jisuanke/lq/practice5/4.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | 5 | const int mod = 1e9+7; 6 | 7 | int quick_mod(int x,int n) 8 | { 9 | int res=1; 10 | while(n) 11 | { 12 | if(n&1) res=res*x%mod; 13 | x=x*x%mod; 14 | n>>=1; 15 | } 16 | return res; 17 | } 18 | 19 | int pw(int x, int n) { 20 | if (!n) { 21 | return 1; 22 | } 23 | int res = pw(x*x%mod,n>>1); 24 | if (n & 1) { 25 | res = res * x % mod; 26 | } 27 | return res; 28 | } 29 | 30 | int main() 31 | { 32 | cout << quick_mod(5,2) << endl; 33 | cout << quick_mod(5,3) << endl; 34 | cout << quick_mod(2,10) << endl; 35 | cout << pw(5,2) << endl; 36 | cout << pw(5,3) << endl; 37 | cout << pw(2,10) << endl; 38 | return 0; 39 | } 40 | -------------------------------------------------------------------------------- /code/basic/jisuanke/lq/practice5/e.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | int main() { 4 | int n, ans = 0; 5 | cin >> n; 6 | while (n) { 7 | ans += n/5; 8 | n/=5; 9 | } 10 | cout << ans << endl; 11 | return 0; 12 | } 13 | 14 | -------------------------------------------------------------------------------- /code/basic/jisuanke/lq/practice5/f.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | typedef long long ll; 4 | ll a[30]={ 5 | 258055, 69760, 163908, 249856, 53440, 6 | 151684, 77958, 176134, 8262, 229446, 7 | 245953, 20676, 45189, 69826, 131075, 8 | 28672, 155717, 118851, 221318, 254150, 9 | 135235, 86083, 41089, 28743, 32772, 10 | 225475, 118855, 249862, 184320, 217154 11 | }; 12 | 13 | map mp; //mp[state] = num 14 | int n=16; 15 | ll ans=0; 16 | void dfs(int st,int idx) 17 | { 18 | ans=max(ans,mp[st]); 19 | if(idx==n) 20 | return; 21 | mp[st+(1<b; 28 | } 29 | 30 | int main() 31 | { 32 | //sort(a,a+30,cmp); 33 | dfs(0,0); //因为第一个数就有可取可不取,所以从st=0开始,idx=0 34 | cout< 2 | using namespace std; 3 | const int maxn = 300+5; 4 | int dp[maxn][maxn]; 5 | void init() 6 | { 7 | for(int i=1;i>n>>k; 22 | cout << dp[n][k]; 23 | return 0; 24 | } 25 | -------------------------------------------------------------------------------- /code/basic/jisuanke/ningxia/1.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | const int maxn = 1e5+5; 4 | int a[maxn]; 5 | 6 | int main() 7 | { 8 | int t;cin>>t; 9 | while(t--) 10 | { 11 | int v1,v2; cin>>v1>>v2; 12 | 13 | int n; cin>>n; 14 | 15 | } 16 | 17 | 18 | return 0; 19 | } 20 | -------------------------------------------------------------------------------- /code/basic/jisuanke/ningxia/b.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | typedef long long ll; 4 | 5 | int main() 6 | { 7 | int t; cin>>t; 8 | ll n; 9 | while(t--) 10 | { 11 | cin>>n; 12 | 13 | 14 | } 15 | return 0; 16 | } 17 | -------------------------------------------------------------------------------- /code/basic/jisuanke/ningxia/data.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | typedef unsigned long long ull; 4 | int main() 5 | { 6 | ull tmp = pow(2,63); 7 | //cout << tmp; 8 | for(ull i=4;i<=tmp;i+=2) 9 | { 10 | cout< 2 | using namespace std; 3 | const long long mod = 1000000007; 4 | const long long maxn = 1000000+5; 5 | 6 | long long inline read() 7 | { 8 | long long x=0,f=1; char ch=getchar(); 9 | while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();} 10 | while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();} 11 | return x*f; 12 | } 13 | 14 | int main() 15 | { 16 | int n; 17 | while(cin>>n) 18 | { 19 | long long x; 20 | long long sum=1; 21 | for(int i=0;i 2 | using namespace std; 3 | const int maxn = 1000+5; 4 | int a[maxn]; 5 | int main() 6 | { 7 | int t;cin>>t; 8 | while(t--) 9 | { 10 | int ans=-1; 11 | int n; cin>>n; 12 | 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 | using namespace std; 15 | const int mod = 19260817; 16 | const int maxn = 12; 17 | long long dp[maxn][maxn]; 18 | //毒瘤张力豪 19 | int main() 20 | { 21 | int n,m; 22 | cin>>n>>m; 23 | if(n 2 | using namespace std; 3 | 4 | int n,m; 5 | int k; 6 | 7 | vector G[maxn]; 8 | 9 | void dfs(int u,int fa) 10 | { 11 | if(u==fa) 12 | return; 13 | for(int i=0;i>n>>m>>k; 22 | 23 | for(int i=1;i<=m;i++) 24 | { 25 | cin>>u>>v; 26 | G[u].push_back(v); 27 | G[v].push_back(u); 28 | } 29 | for(int i=1;i<=n;i++) 30 | { 31 | dfs(i); 32 | } 33 | 34 | return 0; 35 | } 36 | -------------------------------------------------------------------------------- /code/basic/jnu/4/1.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 | using namespace std; 15 | 16 | int main() 17 | { 18 | //freopen("in","r",stdin); 19 | int n,k,idx; 20 | cin>>n>>k>>idx; 21 | 22 | int kuai=pow(2,k-1); 23 | int kuai2=kuai*2; 24 | 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 | using namespace std; 15 | int main() 16 | { 17 | long long n; cin>>n; 18 | long long now=2; 19 | long long pre=2; 20 | if(n==1){ 21 | cout<<"2"; 22 | return 0; 23 | } 24 | for(long long i=2;i<=n;i++) 25 | { 26 | now=pre+2*(i-1); 27 | pre=now; 28 | } 29 | cout << now; 30 | return 0; 31 | } 32 | -------------------------------------------------------------------------------- /code/basic/jnu/5/4.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 | using namespace std; 15 | typedef long long ll; 16 | const ll mod = 1e9+7; 17 | ll quick_mod(ll x,ll n) 18 | { 19 | ll res=1; 20 | while(n>0) 21 | { 22 | if(n&1) res = res*x%mod; 23 | x = x*x%mod; 24 | n>>=1; 25 | } 26 | return res; 27 | } 28 | int main() 29 | { 30 | long long m,n; 31 | cin>>m>>n; 32 | //cout << (m*(m-1)^(n-1))< 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 | ios::sync_with_stdio(false); 20 | int n,m; 21 | while(cin>>n>>m) 22 | { 23 | set > st; 24 | int a; 25 | for (int i=0;i>a; //scanf("%d",&a); 28 | st.insert(a); 29 | } 30 | 31 | 32 | bool flag=true; 33 | for (set >::iterator it = st.begin();it!=st.end();it++) 34 | { 35 | if (flag) flag=false,cout<<*it; 36 | else cout << ' ' << *it; 37 | } 38 | cout << endl; 39 | } 40 | 41 | return 0; 42 | } 43 | -------------------------------------------------------------------------------- /code/basic/jnu/5_pre/2.cpp: -------------------------------------------------------------------------------- 1 | //2.cpp 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 | using namespace std; 15 | 16 | int main() 17 | { 18 | //freopen("in","r",stdin); 19 | int a,b; 20 | int tmp[1000000]={0}; 21 | while(scanf("%d%d",&a,&b)!=EOF) 22 | { 23 | memset(tmp,0,sizeof(tmp)); 24 | for (int i=0;i<=1000;i++) 25 | { 26 | for (int j=0;j<=1000;j++) 27 | { 28 | int qq = a*i+b*j; 29 | tmp[qq]=1; 30 | } 31 | } 32 | for (int i=0;i<1000;i++) 33 | { 34 | if (tmp[i]==0) cout << i << endl; 35 | } 36 | cout << endl; 37 | 38 | } 39 | return 0; 40 | } 41 | -------------------------------------------------------------------------------- /code/basic/jnu/8_pre/2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mazicwong/ACM_code/b4e774e8fb2087c89c607688600318a7ee6d4571/code/basic/jnu/8_pre/2 -------------------------------------------------------------------------------- /code/basic/jnu/8_pre/3: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mazicwong/ACM_code/b4e774e8fb2087c89c607688600318a7ee6d4571/code/basic/jnu/8_pre/3 -------------------------------------------------------------------------------- /code/basic/jnu/acm_class/DP03-30/1018.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | const int maxn = 3000; 4 | int t[maxn]; 5 | int p[maxn]; 6 | int f[maxn]; //f[i]: 当前第i个信息下来的最简单 7 | 8 | int main() 9 | { 10 | int n,m; 11 | 12 | while(cin>>n>>m) //n个T, m 13 | { 14 | for(int i=0;i 2 | using namespace std; 3 | const int maxn = 105; 4 | char str[maxn][maxn]; 5 | 6 | bool check(string s1, string s2) 7 | { 8 | 9 | } 10 | int main() 11 | { 12 | int t; cin>>t; 13 | while(t--) 14 | { 15 | int n; cin>>n; 16 | int minn = 105; 17 | for(int i=0;i=0; len--) 30 | { 31 | 32 | } 33 | } 34 | return 0; 35 | } 36 | -------------------------------------------------------------------------------- /code/basic/jnu/acm_class/搜索4-20/1025.cpp: -------------------------------------------------------------------------------- 1 | //假设: 2 | //S1 = 1 3 | //S2 = 12 4 | //S3 = 123 5 | //S4 = 1234 6 | //hdu 1597 7 | #include 8 | using namespace std; 9 | // n=1 s=1 10 | // n=2 s=2..3 11 | // n=3 s=4..6 1,3,6... n(1+n)/2; 12 | typedef long long ll; 13 | 14 | int main() 15 | { 16 | int k; cin>>k; 17 | for(int i=0;i>n; 20 | ll cnt=1; 21 | while(n>cnt) 22 | n-=cnt++; 23 | n%=9; if(n==0) n=9; 24 | cout << n << endl; 25 | } 26 | return 0; 27 | } 28 | -------------------------------------------------------------------------------- /code/basic/jnu/acm_class/数组03-12/1001数塔.cpp: -------------------------------------------------------------------------------- 1 | //在讲述DP算法的时候,一个经典的例子就是数塔问题 2 | #include 3 | using namespace std; 4 | const int maxn = 105; 5 | int dp[maxn][maxn]; 6 | int main() 7 | { 8 | int t;cin>>t; 9 | while(t--) 10 | { 11 | memset(dp,0,sizeof(dp)); 12 | int n;cin>>n; 13 | for(int i=1;i<=n;i++) 14 | for(int j=1;j<=i;j++) 15 | cin>>dp[i][j]; 16 | for(int i=n;i>=1;i--) 17 | for(int j=1;j<=i;j++) 18 | dp[i][j] = max(dp[i+1][j], dp[i+1][j+1]) + dp[i][j]; 19 | cout< 3 | using namespace std; 4 | const int maxn = 205; 5 | int s[maxn]; 6 | int t[maxn]; 7 | int cnt[maxn]; 8 | int main() 9 | { 10 | int t;cin>>t; 11 | while(t--) 12 | { 13 | int n;cin>>n; 14 | int st,en; 15 | memset(cnt,0,sizeof(cnt)); 16 | for(int i=0;i>st>>en; 19 | st = (st+1)>>1; 20 | en = (en+1)>>1; 21 | if(st>en) swap(st,en); 22 | for(int k=st;k<=en;k++) 23 | cnt[k]++; 24 | } 25 | int ans=-1; 26 | for(int i=1;i<=200;i++) 27 | ans = max(ans,cnt[i]); 28 | cout << ans*10 << endl; 29 | } 30 | return 0; 31 | } 32 | -------------------------------------------------------------------------------- /code/basic/jnu/acm_class/数组03-12/1003jumping.cpp: -------------------------------------------------------------------------------- 1 | //Nowadays, a kind of chess game called “Super Jumping! Jumping! Jumping 2 | #include 3 | using namespace std; 4 | const int maxn = 1005; 5 | long long a[maxn]; 6 | int n; 7 | //LIS 8 | long long dp[maxn]; 9 | int main() 10 | { 11 | while(cin>>n && n) 12 | { 13 | memset(dp,0,sizeof(dp)); 14 | for(int i=0;i>a[i], dp[i]=a[i]; 15 | for(int i=1;i a[j]) dp[i]=max(dp[i],dp[j]+a[i]); 20 | } 21 | } 22 | long long ans=0; 23 | for(int i=0;i 4 | using namespace std; 5 | int n; 6 | const int maxn = 105; 7 | struct Node{ 8 | int st,en; 9 | }node[maxn]; 10 | bool cmp(const Node a, const Node b) 11 | { 12 | return a.en>n && n) 17 | { 18 | for(int i=0;i>node[i].st>>node[i].en; 21 | } 22 | sort(node,node+n,cmp); 23 | int now=node[0].en; 24 | int cnt=1; 25 | for(int i=1;i=now) 28 | { 29 | now=node[i].en; 30 | cnt++; 31 | } 32 | } 33 | cout< 2 | using namespace std; 3 | int a[15] = { 4 | 1,4, 5 | } 6 | int main() 7 | { 8 | int n; 9 | while(cin>>n & n) 10 | { 11 | 12 | } 13 | 14 | return 0; 15 | } 16 | -------------------------------------------------------------------------------- /code/basic/nowcoder/pku_kaoyan/10.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | struct Node{ 4 | int w; 5 | string color; 6 | bool operator < (const Node &rhs) const { 7 | return w > rhs.w; 8 | } 9 | }node[105]; 10 | 11 | bool cmp(const Node a,const Node b) 12 | { 13 | return a.w>b.w; 14 | } 15 | 16 | int main() 17 | { 18 | ios::sync_with_stdio(false); 19 | int n; 20 | while(cin>>n) 21 | { 22 | for(int i=0;i>node[i].w>>node[i].color; 25 | } 26 | sort(node,node+n); 27 | for(int i=0;i 2 | using namespace std; 3 | 4 | int main() 5 | { 6 | long long n; 7 | while(cin>>n) 8 | { 9 | bool flag=false; 10 | for(long long i=2;i<=9;i++) 11 | { 12 | if(n%i == 0) 13 | { 14 | if(!flag) cout << i; 15 | else cout << ' ' << i; 16 | flag=true; 17 | } 18 | } 19 | if(!flag) cout << "none" << endl; 20 | else cout << endl; 21 | } 22 | return 0; 23 | } 24 | -------------------------------------------------------------------------------- /code/basic/nowcoder/pku_kaoyan/14.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | //dp[n][m] = dp[m][m] (n>n>>m; 20 | cout << dfs(n,m); 21 | return 0; 22 | } 23 | -------------------------------------------------------------------------------- /code/basic/nowcoder/pku_kaoyan/16.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | int main() 5 | { 6 | string str; 7 | while(cin>>str) 8 | { 9 | sort(str.begin(),str.end()); 10 | cout << str << endl; 11 | while(next_permutation(str.begin(),str.end())) 12 | { 13 | cout << str << endl; 14 | } 15 | cout << endl; 16 | } 17 | return 0; 18 | } 19 | -------------------------------------------------------------------------------- /code/basic/nowcoder/pku_kaoyan/17.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | int main() 5 | { 6 | int n,k; cin>>n>>k; 7 | for(int i=0;i>p[i]; 10 | for(int j=0;j>left[j]; 11 | for(int j=0;j>right[j]; 12 | } 13 | 14 | return 0; 15 | } 16 | -------------------------------------------------------------------------------- /code/basic/nowcoder/pku_kaoyan/2.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | const int maxn = 200+5; 5 | int p[maxn]; 6 | map mp; 7 | 8 | int main() 9 | { 10 | int n,m; 11 | cin>>n>>m; 12 | for(int i=0;i>p[i]; 15 | mp[p[i]]++; 16 | } 17 | for(int i=0;i 2 | using namespace std; 3 | 4 | int main() 5 | { 6 | string str; 7 | getline(cin,str); 8 | int len = str.size(); 9 | for(int i=0;i='a'&&str[i]<='z') str[i]++; 15 | else if (str[i]>='A'&&str[i]<='Z') str[i]++; 16 | } 17 | cout << str; 18 | return 0; 19 | } 20 | -------------------------------------------------------------------------------- /code/basic/nowcoder/pku_kaoyan/8.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | const int maxn = 600+5; 4 | int a[maxn]; 5 | typedef pair pii; 6 | 7 | int gcd(int a,int b) 8 | { 9 | return b==0?a:gcd(b,a%b); 10 | } 11 | 12 | int main() 13 | { 14 | int n; cin>>n; 15 | for(int i=1;i<=n;i++) cin>>a[i]; 16 | sort(a+1,a+n+1); 17 | set st; 18 | int ans=0; 19 | for(int i=1;i<=n;i++) 20 | { 21 | for(int j=i+1;j<=n;j++) 22 | { 23 | if(gcd(a[i],a[j]) == 1) 24 | ans++; 25 | } 26 | } 27 | cout << ans; 28 | return 0; 29 | } 30 | -------------------------------------------------------------------------------- /code/basic/nowcoder/pku_kaoyan/9.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | const int maxn = 1e4+5; 4 | int a[maxn]; 5 | int main() 6 | { 7 | int n; 8 | while(cin>>n && n) 9 | { 10 | for(int i=0;i>a[i]; 11 | sort(a,a+n); 12 | if(n%2==1) 13 | cout << a[n/2] << endl; 14 | else 15 | cout << (a[n/2]+a[n/2-1])/2 << endl; 16 | } 17 | return 0; 18 | } 19 | -------------------------------------------------------------------------------- /code/basic/nowcoder/pku_kaoyan/h12.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mazicwong/ACM_code/b4e774e8fb2087c89c607688600318a7ee6d4571/code/basic/nowcoder/pku_kaoyan/h12.class -------------------------------------------------------------------------------- /code/basic/nowcoder/pku_kaoyan/h12.java: -------------------------------------------------------------------------------- 1 | import java.math.*; 2 | import java.util.*; 3 | 4 | public class h12 5 | { 6 | public static void main(String[] args) 7 | { 8 | Scanner cin = new Scanner(System.in); 9 | while(cin.hasNext()) 10 | { 11 | BigInteger n = cin.nextBigInteger(); 12 | boolean flag=false; 13 | for(int i=2;i<=9;i++) 14 | { 15 | BigInteger tmp = BigInteger.valueOf(i); 16 | if(n.remainder(tmp).equals(BigInteger.valueOf(0)) == true) 17 | { 18 | if(!flag) ;//System.out.print(i); 19 | else System.out.print(' '); 20 | System.out.print(i); 21 | flag=true; 22 | } 23 | } 24 | if(!flag) System.out.println("none"); 25 | else System.out.println(); 26 | } 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /code/basic/nowcoder/practice17/1.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | int main() 5 | { 6 | double a,b,c; 7 | cin>>a>>b>>c; 8 | cout << 1LL*4*(int)(sqrt(a*c/b) + sqrt(b*a/c) + sqrt(b*c/a)); 9 | return 0; 10 | } 11 | -------------------------------------------------------------------------------- /code/basic/nowcoder/practice17/2.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | //给s和x,问s中每一个字符,是否都能与s中的其他字符组成一个串x,字符在s中的相对位置不变 4 | 5 | typedef unsigned long long ull; 6 | 7 | string s,x; 8 | ull X = 123; //基数 9 | 10 | int main() 11 | { 12 | int t; 13 | 14 | return 0; 15 | } 16 | -------------------------------------------------------------------------------- /code/basic/nowcoder/practice17/4.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | void solve() 4 | { 5 | double lat1,lng1,lat2,lng2; 6 | cin>>lat1>>lng1>>lat2>>lng2; 7 | lat1 = abs(lat1-lat2); 8 | lng1 = abs(lng1-lng2); 9 | double r = 6371009; 10 | cout << (double)((double)802333*802333-r*r-r*r-2*r*r) << endl; 11 | } 12 | 13 | int main() 14 | { 15 | int t;cin>>t; 16 | while(t--) 17 | solve(); 18 | return 0; 19 | } 20 | -------------------------------------------------------------------------------- /code/basic/nowcoder/华中科技大学_4-29/b.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | const int mod = 1000000007; 4 | int main() 5 | { 6 | int k; cin>>k; 7 | string str; cin>>str; 8 | 9 | 10 | return 0; 11 | } 12 | -------------------------------------------------------------------------------- /code/basic/nowcoder/华中科技大学_4-29/c.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | const int maxn = 1e5+5; 4 | int arr[maxn]; 5 | int fa[maxn]; 6 | 7 | int t; 8 | int n,q; 9 | 10 | inline int read() 11 | { 12 | int x=0,f=1; char ch=getchar(); 13 | while(ch<'0'||ch>'9'){if(ch=='0')f=-1;ch=getchar();} 14 | while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();} 15 | return x*f; 16 | } 17 | 18 | //// 19 | void init(){ 20 | for(int i=0;i<=n;i++) fa[i]=i; 21 | } 22 | int find(int x){ 23 | return x==fa[x]?x:fa[x]=find(fa[x]); 24 | } 25 | void unite(int a,int b){ 26 | a = find(a); 27 | b = find(b); 28 | if(a!=b) fa[a] = b; 29 | } 30 | 31 | 32 | 33 | int main() 34 | { 35 | cin>>t; 36 | while(t--) 37 | { 38 | n=read(); q=read(); 39 | init(n); 40 | for(int i=0;i 2 | using namespace std; 3 | const int maxn = 1e5+5; 4 | int a[maxn]; 5 | int arr[maxn]; 6 | bool cmp(int a,int b){return a>b;} 7 | int main() 8 | { 9 | int n,k; 10 | cin>>n>>k; 11 | for(int i=1;i<=n;i++) 12 | { 13 | scanf("%d",&a[i]); 14 | arr[i]=a[i]; 15 | } 16 | if(k==1){ 17 | cout << "-1"; 18 | return 0; 19 | } 20 | sort(arr+1,arr+n+1,cmp); 21 | 22 | for(int i=1;in) continue; 27 | if(a[j+k]>a[j]) swap(a[j+k],a[j]); 28 | } 29 | int test = n-i+k; 30 | if(test>n) continue; 31 | if(a[test]!=arr[test]){ 32 | cout << n-test+1; 33 | return 0; 34 | } 35 | } 36 | cout << "-1"; 37 | return 0; 38 | } 39 | -------------------------------------------------------------------------------- /code/basic/nowcoder/华中科技大学_4-29/j.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | int f(int x) 5 | { 6 | int ans=0; 7 | while(x>0){ 8 | if(x&1==1){ 9 | ans++; 10 | } 11 | x>>=1; 12 | } 13 | return ans; 14 | } 15 | 16 | int main() 17 | { 18 | int a,b; 19 | cin>>a>>b; 20 | 21 | 22 | 23 | 24 | return 0; 25 | } 26 | -------------------------------------------------------------------------------- /code/basic/nowcoder/华中科技大学_4-29/k.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | //走k步,最小化最大的一步 4 | typedef long long ll; 5 | int n,k; 6 | const int maxn = 1e5+5; 7 | ll a[maxn]; 8 | 9 | bool check(ll mid) 10 | { 11 | int cnt=0; 12 | ll sum=0; 13 | for(int i=0;i>n>>k; 29 | ll maxx = 0; 30 | for(int i=0;i 2 | using namespace std; 3 | 4 | int wx,wy; 5 | int bx,by; 6 | int dirx,diry; 7 | int power; 8 | 9 | int main() 10 | { 11 | cin>>wx>>wy; 12 | cin>>bx>>by; 13 | cin>>dirx>>diry; 14 | cin>>power; //x=[0,16]; y=[0,5] 15 | int flag=1; //1=white; 16 | int ans=-2; 17 | while(power>0) 18 | { 19 | if(dirx==-1 && diry==-1) 20 | { 21 | if(flag==) 22 | 23 | } 24 | else if(dirx==-1 && diry==1) 25 | { 26 | 27 | } 28 | else if(dirx==1 && diry==-1) 29 | { 30 | 31 | } 32 | else if(dirx==1 && diry==1) 33 | { 34 | 35 | } 36 | 37 | 38 | 39 | } 40 | 41 | return 0; 42 | } 43 | -------------------------------------------------------------------------------- /code/basic/百练/2018研究生上机测试/d.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | const int maxn = 1e4+5; 4 | struct Node{ 5 | int st; 6 | int en; 7 | bool operator < (const Node rhs){ 8 | if(en == rhs.en) return st>n; 16 | for(int i=0;i>node[i].st>>node[i].en; 19 | } 20 | sort(node,node+n); 21 | int cur=node[0].en; 22 | int ans=1; 23 | for(int i=1;i 2 | using namespace std; 3 | typedef long long ll; 4 | const int maxn = 50+5; 5 | ll a[maxn]; 6 | void init() 7 | { 8 | a[1]=1; 9 | a[2]=2; 10 | for(int i=3;i<=50;i++) 11 | a[i] = a[i-1]+a[i-2]; 12 | } 13 | int main() 14 | { 15 | int n; cin>>n; 16 | int ta,tb; 17 | init(); 18 | while(n--) 19 | { 20 | cin>>ta>>tb; 21 | cout< 2 | using namespace std; 3 | typedef pair pii; 4 | map mp; 5 | int main() 6 | { 7 | int n; 8 | while(cin>>n) 9 | { 10 | int x,y; 11 | mp.clear(); 12 | for(int i=0;i 2 | using namespace std; 3 | const int maxn = 100000+4; 4 | int a[maxn]; 5 | int b[maxn]; 6 | 7 | inline int read() 8 | { 9 | int x=0,f=1;char ch=getchar(); 10 | while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();} 11 | while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();} 12 | return x*f; 13 | } 14 | 15 | int main() 16 | { 17 | int t;t=read(); 18 | while(t--) 19 | { 20 | memset(a,0,sizeof(a)); 21 | memset(b,0,sizeof(b)); 22 | int n; n=read(); 23 | for(int i=1;i<=n;i++) a[i]=read(); 24 | for(int i=1;i<=n;i++) b[i]=read(); 25 | for(int i=1;i<=n;i++) a[i]-=b[i]; 26 | long long ans = 0; 27 | for(int i=1;i 2 | using namespace std; 3 | long long f[25]; 4 | int main() 5 | { 6 | f[1]=2; 7 | for(int i=2;i<=21;i++) 8 | { 9 | f[i] = f[i-1]*2; 10 | } 11 | int n; cin>>n; 12 | cout << f[n]; 13 | return 0; 14 | } 15 | -------------------------------------------------------------------------------- /code/basic/金马五校赛/f.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mazicwong/ACM_code/b4e774e8fb2087c89c607688600318a7ee6d4571/code/basic/金马五校赛/f.class -------------------------------------------------------------------------------- /code/basic/金马五校赛/k.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | const int maxn = 1e5+5; 4 | long long a[maxn]; 5 | long long pre[maxn]; 6 | 7 | long long get(int i,int j) 8 | { 9 | return pre[j]-pre[i-1]; 10 | } 11 | 12 | int main() 13 | { 14 | int n,k; cin>>n>>k; 15 | for(int i=1;i<=n;i++) 16 | { 17 | cin>>a[i]; 18 | pre[i]=pre[i-1]+a[i]; 19 | } 20 | for(int len=n;len>=1;len--) 21 | { 22 | for(int i=1;i<=n,i+len-1<=n;i++) 23 | { 24 | int j = i+len-1; 25 | if(get(i,j) % k == 0) 26 | { 27 | cout << len; 28 | return 0; 29 | } 30 | } 31 | } 32 | return 0; 33 | } 34 | -------------------------------------------------------------------------------- /code/big num/hdu 1002 大数相加.java: -------------------------------------------------------------------------------- 1 | // A+B 2 | import java.math.*; 3 | import java.util.*; 4 | 5 | public class hdu1002 6 | { 7 | public static void main(String[] args) 8 | { 9 | Scanner cin = new Scanner(System.in); 10 | int n = cin.nextInt(); 11 | for (int cas=1;cas<=n;cas++) 12 | { 13 | BigInteger a = cin.nextBigInteger(); 14 | BigInteger b = cin.nextBigInteger(); 15 | System.out.println("Case "+cas+":"); 16 | System.out.println(a+" + "+b+" = "+a.add(b)); 17 | if (cas!=n) 18 | System.out.println(""); 19 | } 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /code/big num/hdu 1042 大数阶乘.java: -------------------------------------------------------------------------------- 1 | import java.math.*; 2 | import java.util.*; 3 | 4 | public class hdu1024 5 | { 6 | public static void main(String[] args) 7 | { 8 | Scanner cin = new Scanner(System.in); 9 | while(cin.hasNext()) 10 | { 11 | int n = cin.nextInt(); 12 | //BigDecimal ans = new BigDecimal(1); 13 | BigInteger ans = BigInteger.ONE; 14 | for (int i=1;i<=n;i++) 15 | { 16 | //BiDecimal a = new BigDecimal(i); 17 | ans = ans.multiply(BigInteger.valueOf(i)); 18 | } 19 | System.out.println(ans); 20 | } 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /code/big num/hdu 1047 大数相加.java: -------------------------------------------------------------------------------- 1 | import java.math.*; 2 | import java.util.*; 3 | 4 | public class hdu1047 5 | { 6 | public static void main(String[] args) 7 | { 8 | Scanner cin = new Scanner(System.in); 9 | int n = cin.nextInt(); 10 | while(n-->0) 11 | { 12 | BigInteger ans = new BigInteger("0"); 13 | while(cin.hasNextBigInteger()) 14 | { 15 | BigInteger a = cin.nextBigInteger(); 16 | if (a.equals(BigInteger.valueOf(0))) 17 | break; 18 | ans = ans.add(a); 19 | } 20 | System.out.println(ans); 21 | if (n!=0) 22 | System.out.println(); 23 | } 24 | 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /code/big num/hdu 1047 大数相加string.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | using namespace std; 8 | 9 | 10 | void plusABtoA(string &a, string &b) 11 | { 12 | string c; 13 | int n = a.size(), m = b.size(); 14 | int carry = 0; 15 | for (int i = n - 1, j = m - 1; i >= 0 || j >= 0 || carry > 0; i--, j--) 16 | { 17 | int an = i >= 0 ? a[i] - '0' : 0; 18 | int bn = j >= 0 ? b[j] - '0' : 0; 19 | carry += an + bn; 20 | c += char(carry % 10 + '0'); 21 | carry /= 10; 22 | } 23 | reverse(c.begin(), c.end()); 24 | a = c; 25 | } 26 | 27 | int main() 28 | { 29 | int n; 30 | string a, b; 31 | cin >> n; 32 | while (n--) 33 | { 34 | cin >> a; 35 | if (a == "0") 36 | { 37 | cout << a << endl; 38 | if (n) cout << endl; 39 | continue; 40 | } 41 | while (cin >> b&&b != "0") 42 | plusABtoA(a, b); 43 | cout << a << endl; 44 | if (n) cout << endl; 45 | } 46 | return 0; 47 | } -------------------------------------------------------------------------------- /code/big num/hdu 1061 大数取模 模版.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mazicwong/ACM_code/b4e774e8fb2087c89c607688600318a7ee6d4571/code/big num/hdu 1061 大数取模 模版.cpp -------------------------------------------------------------------------------- /code/big num/hdu 1063 R的n次幂.java: -------------------------------------------------------------------------------- 1 | // R^n 2 | 3 | import java.math.BigDecimal; 4 | import java.util.*; 5 | 6 | public class hdu1063 7 | { 8 | public static void main(String[] args) 9 | { 10 | Scanner cin = new Scanner(System.in); 11 | while(cin.hasNext()) 12 | { 13 | BigDecimal a = cin.nextBigDecimal(); 14 | int b = cin.nextInt(); 15 | String ans = a.pow(b).stripTrailingZeros().toPlainString(); 16 | if (ans.startsWith("0")) 17 | ans = ans.substring(1); 18 | System.out.println(ans); 19 | } 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /code/big num/hdu 1715 fibonaqi.java: -------------------------------------------------------------------------------- 1 | import java.math.*; 2 | import java.util.*; 3 | 4 | public class hdu1715 5 | { 6 | public static void main(String[] args) 7 | { 8 | Scanner cin = new Scanner(System.in); 9 | int n = cin.nextInt(); 10 | BigDecimal a[] = new BigDecimal[1005]; 11 | a[1]=a[2]=new BigDecimal(1); 12 | for (int i=3;i<=1000;i++) 13 | a[i] = a[i-1].add(a[i-2]); 14 | while(n-->0) 15 | { 16 | int x = cin.nextInt(); 17 | System.out.println(a[x]); 18 | } 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /code/big num/hdu 1753 大浮点数相加.java: -------------------------------------------------------------------------------- 1 | import java.math.BigDecimal; 2 | import java.util.*; 3 | 4 | public class hdu1753 5 | { 6 | public static void main(String[] args) 7 | { 8 | Scanner cin = new Scanner(System.in); 9 | BigDecimal a,b; 10 | while(cin.hasNext()) 11 | { 12 | a = cin.nextBigDecimal(); 13 | b = cin.nextBigDecimal(); 14 | System.out.println(a.add(b).stripTrailingZeros().toPlainString()); 15 | } 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /code/big num/hdu 5237 大数模拟.java: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mazicwong/ACM_code/b4e774e8fb2087c89c607688600318a7ee6d4571/code/big num/hdu 5237 大数模拟.java -------------------------------------------------------------------------------- /code/big num/hdu 5241 大数乘法.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mazicwong/ACM_code/b4e774e8fb2087c89c607688600318a7ee6d4571/code/big num/hdu 5241 大数乘法.cpp -------------------------------------------------------------------------------- /code/big num/hdu5920高精度.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | using namespace std; 6 | int main() 7 | { 8 | while (1) 9 | { 10 | int t; 11 | scanf("%d", &t); 12 | int h, min; 13 | if (t == 12) 14 | { 15 | scanf("%d:%d", &h, &min); 16 | if (min >= 60) 17 | { 18 | min -= 60; 19 | h += 1; 20 | } 21 | if (h > 12) 22 | h %= 10; 23 | } 24 | else if (t == 24) 25 | { 26 | scanf("%d:%d", &h, &min); 27 | if (min >= 60) 28 | { 29 | min %= 10; 30 | } 31 | if (h >= 24) 32 | { 33 | h %= 10; 34 | } 35 | } 36 | if (h < 10) 37 | printf("0%d:", h); 38 | else 39 | printf("%d:", h); 40 | if (min < 10) 41 | printf("0%d", min); 42 | else 43 | printf("%d", min); 44 | } 45 | 46 | return 0; 47 | } 48 | -------------------------------------------------------------------------------- /code/ccf/2013_12_1.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | const int maxn = 1000+5; 4 | typedef pair pii; 5 | int a[maxn]; 6 | int main() 7 | { 8 | int n;cin>>n; 9 | for(int i=0;imax_cnt) 24 | { 25 | ans = a[i-1]; 26 | max_cnt=cnt; 27 | } 28 | cnt=1; 29 | } 30 | } 31 | cout << ans; 32 | return 0; 33 | } 34 | -------------------------------------------------------------------------------- /code/ccf/2013_12_3.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | const int maxn = 1000+5; 4 | int dp[maxn][maxn]; 5 | int a[maxn]; 6 | int main() 7 | { 8 | int n; cin>>n; 9 | int maxx=0; 10 | for (int i=1;i<=n;i++) scanf("%d",&a[i]),dp[i][i]=a[i],maxx=max(maxx,a[i]); 11 | for (int i=1;i<=n;i++) 12 | { 13 | for (int j=i+1;j<=n;j++) 14 | { 15 | dp[i][j] = min(dp[i][j-1], a[j]); 16 | maxx = max(maxx,dp[i][j]*(j-i+1)); 17 | } 18 | } 19 | cout << maxx; 20 | return 0; 21 | } 22 | -------------------------------------------------------------------------------- /code/ccf/2014_03_1.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | int main() 5 | { 6 | int n;cin>>n; 7 | int a[1005]; 8 | for (int i=0;i 2 | using namespace std; 3 | int a[1005]; 4 | int main() 5 | { 6 | int n;cin>>n; 7 | for(int i=0;i 2 | using namespace std; 3 | 4 | int main() 5 | { 6 | int n;cin>>n; 7 | int mp[105][105]; 8 | memset(mp,0,sizeof(mp)); 9 | for(int i=1;i<=n;i++) 10 | { 11 | int x1,y1,x2,y2; 12 | cin>>x1>>y1>>x2>>y2; 13 | for(int x=x1;x 2 | using namespace std; 3 | typedef long long ll; 4 | const ll mod = 1e9+7; 5 | 6 | //pow 8line 7 | ll pow_mod(ll x,ll n) 8 | { 9 | ll res=1; 10 | while(n>0) 11 | { 12 | if(n&1) res=res*x%mod; 13 | x=x*x%mod; 14 | n>>=1; 15 | } 16 | return res; 17 | } 18 | 19 | int main() 20 | { 21 | int n,m; 22 | cin>>n>>m; 23 | int ans=0; 24 | if( (m%2!=0 && m%3!=0) || (n%2!=0 && n%3!=0)) 25 | { 26 | cout<<"0"< 2 | using namespace std; 3 | 4 | int main() 5 | { 6 | int n; cin>>n;int a[1005]; 7 | int flag=0;int cnt=0; 8 | for(int i=0;i>a[i]; 9 | for(int i=0;i a[i+1]) 20 | { 21 | if(flag==1) 22 | { 23 | cnt++; 24 | } 25 | flag=-1; 26 | } 27 | } 28 | cout<< cnt; 29 | 30 | return 0; 31 | } 32 | -------------------------------------------------------------------------------- /code/ccf/2016_09_1.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | int main() 5 | { 6 | int ans=-20000; 7 | int n;cin>>n; 8 | int a[1050];for(int i=0;i>a[i]; 9 | for(int i=0;i 2 | using namespace std; 3 | const int maxn = 1e4+5; 4 | //一个带限制的最短路 5 | //初步思路,首都到所有城市的最短路先选,然后求最小生成树 6 | struct Edge{ 7 | int to; 8 | int cost; 9 | Edge(int _to=0,int _cost=0):to(_to),cost(_cost){} 10 | }edge; 11 | struct Node{ 12 | int to; 13 | int cost; 14 | Node(int _to=0,int _cost=0) 15 | { 16 | to=_to; 17 | cost=_cost; 18 | } 19 | }; 20 | vector G[maxn]; 21 | int n,m; 22 | void dijkstra(int begin) 23 | { 24 | for(int i=1;i<=n;i++) 25 | } 26 | int main() 27 | { 28 | cin>>n>>m; 29 | for(int i=0;i>u>>v>>w; 33 | G[u].push_back({v,w}); 34 | } 35 | 36 | return 0; 37 | } 38 | -------------------------------------------------------------------------------- /code/ccf/2016_12_1.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | const int maxn=1e3+5; 4 | int a[maxn]; 5 | int main() 6 | { 7 | int n;cin>>n; 8 | for(int i=0;i>a[i]; 9 | sort(a,a+n); 10 | 11 | bool flag=false; 12 | for(int i=0;i 2 | using namespace std; 3 | int n; 4 | void solve() 5 | { 6 | n-=3500; 7 | if(n<=1455) 8 | { 9 | n = n*100/97; 10 | } 11 | else if (n<=4155) 12 | { 13 | n = (n-1455)*100/90 + 1500; 14 | } 15 | else if (n<=7755) 16 | { 17 | n = (n-4155)*100/80 + 4500; 18 | } 19 | else if (n<=27255) 20 | { 21 | n = (n-7755)*100/75 + 9000; 22 | } 23 | else if (n<=41255) 24 | { 25 | n = (n-27255)*100/70 + 35000; 26 | } 27 | else if (n<=57505) 28 | { 29 | n = (n-41255)*100/65 + 55000; 30 | } 31 | else 32 | { 33 | n = (n-57505)*100/55 + 80000; 34 | } 35 | cout << n+3500; 36 | } 37 | int main() 38 | { 39 | cin>>n; 40 | if(n<=3500) 41 | { 42 | cout << n; 43 | } 44 | else solve(); 45 | return 0; 46 | } 47 | -------------------------------------------------------------------------------- /code/ccf/2016_12_4.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | //经典的石子归并问题 4 | 5 | const int maxn = 1e3+5; 6 | int dp[maxn][maxn]; 7 | int sum[maxn]; 8 | int a[maxn]; 9 | int main() 10 | { 11 | int n;cin>>n; 12 | for(int i=1;i<=n;i++) cin>>a[i],sum[i]=sum[i-1]+a[i]; 13 | //按照区间长度从小到大DP 14 | for(int len=1;len 2 | using namespace std; 3 | 4 | int main() 5 | { 6 | int n,k; cin>>n>>k; 7 | int a; 8 | int sum=0; 9 | int ans=0; 10 | for(int i=0;i=k) 15 | { 16 | ans++; 17 | sum=0; 18 | } 19 | } 20 | if(sum!=0)ans++; 21 | cout << ans; 22 | 23 | return 0; 24 | } 25 | -------------------------------------------------------------------------------- /code/ccf/2017_09_1.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | int main() 5 | { 6 | int n;cin>>n; 7 | n/=10; 8 | int ans = n/5*(5+2); 9 | int tmp = n%5; 10 | if(tmp>=3) 11 | ans++; 12 | ans += tmp; 13 | cout << ans; 14 | return 0; 15 | } 16 | -------------------------------------------------------------------------------- /code/ccf/2017_09_3.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | const int maxn = 100+5; 5 | vector vec[maxn]; 6 | map mp; 7 | map mp1; 8 | 9 | string str; 10 | char tmp[maxn]; 11 | int getWord(int idx) 12 | { 13 | for(int i=idx;i>n>>m; 24 | int cnt=0; 25 | int flag=0; 26 | for(int i=0;i>str; 29 | for(int j=0;j>ss; 41 | if(mp[ss].size()!=0) 42 | cout< 2 | using namespace std; 3 | 4 | int main() 5 | { 6 | int n;cin>>n; 7 | int a[1005]; 8 | for(int i=0;i>a[i]; 9 | sort(a,a+n); 10 | int ans=0x3f3f3f3f; 11 | for(int i=1;i 2 | using namespace std; 3 | 4 | int main() 5 | { 6 | int n,k;cin>>n>>k; 7 | if(k==1) 8 | { 9 | cout << n; 10 | return 0; 11 | } 12 | queue Q; 13 | for(int i=1;i<=n;i++) 14 | { 15 | if(i%k!=0 && i%10!=k) 16 | Q.push(i); 17 | } 18 | 19 | long long cnt=n; 20 | while(Q.size()>1) 21 | { 22 | int tmp=Q.front(); Q.pop(); 23 | cnt++; 24 | if(cnt%k==0 || cnt%10==k) continue; 25 | else Q.push(tmp); 26 | } 27 | cout< 2 | using namespace std; 3 | typedef long long ll; 4 | 5 | int main() 6 | { 7 | ll n,s,t; 8 | cin>>n>>s>>t; 9 | ll min;//0-59 10 | ll hours;//0-23 11 | ll day;//1-31 12 | ll month;//1-12 Jan-Dec 13 | ll week;//0-6 Sun-Sat 14 | 15 | 16 | return 0; 17 | } 18 | -------------------------------------------------------------------------------- /code/ccf/readme.md: -------------------------------------------------------------------------------- 1 | ### 只写后面三题 2 | 3 | 2017-09 4 | - 模拟json 5 | - dfs1000个点能过(图是单向的,O(nm)) 6 | - 树状数组(满足区间减法,直接树状数组就行了,不用线段树) 7 | 8 | 2017-03 9 | - 很难受的模拟 10 | - 路径上最小边 11 | - 费用流 12 | 13 | 2016-12 14 | - 15 | - 石子归并(区间DP) 16 | - 17 | 18 | 2014-09 19 | - KMP 20 | - 图论,bfs 21 | - 插头DP 22 | 23 | 2014-03 24 | - 很难受的模拟 25 | - 图论,dfs 26 | - 27 | 28 | 2013-12 29 | 有价值就是第4跟第5题,趁着第4题顺便学了一波数位dp,这方法太强了 30 | - 模拟 31 | - 数位DP 32 | - 复杂搜索 33 | -------------------------------------------------------------------------------- /code/ccf/test.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | long long tree[101024]; 4 | const int maxn = 1e5+5; 5 | int a[maxn]; 6 | int main() 7 | { 8 | int n,m; 9 | cin>>n>>m; 10 | vector G; 11 | 12 | G.push_back(n); 13 | G.push_back(m); 14 | for(vector::iterator it=G.begin();it!=G.end();it++) 15 | cout << *it << endl; 16 | 17 | //G.pop_back(); 18 | for(vector::iterator it=G.begin();it!=G.end();it++) 19 | cout << *it << endl; 20 | 21 | cout << endl << *G.begin(); 22 | cout << endl << *G.end(); 23 | 24 | return 0; 25 | } 26 | -------------------------------------------------------------------------------- /code/cf/340/5.cpp: -------------------------------------------------------------------------------- 1 | //5.cpp 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 | using namespace std; 15 | /* 16 | * n个数,m个询问[l,r] 17 | * 问[l,r]中有多少个pair使得a[i,j]异或和为k 18 | * 19 | */ 20 | int main() 21 | { 22 | //freopen("in","r",stdin); 23 | int n,m,k; 24 | cin>>n>>m>>k; 25 | for (int i=0;i 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | #include 12 | #include 13 | #include 14 | using namespace std; 15 | 16 | int main() 17 | { 18 | //freopen("in","r",stdin); 19 | int a[3]; 20 | cin>>a[0]>>a[1]>>a[2]; 21 | sort(a,a+3); 22 | cout << (a[2]-a[1]+(a[1]-a[0])); 23 | 24 | return 0; 25 | } 26 | -------------------------------------------------------------------------------- /code/cf/375/2.cpp: -------------------------------------------------------------------------------- 1 | //2.cpp 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 | using namespace std; 15 | char str[260]; 16 | int main() 17 | { 18 | //freopen("in","r",stdin); 19 | int n;cin>>n; 20 | cin>>str; 21 | 22 | 23 | return 0; 24 | } 25 | -------------------------------------------------------------------------------- /code/cf/428/4.cpp: -------------------------------------------------------------------------------- 1 | /************************************************************************* 2 | > File Name: 4.cpp 3 | > Author: mazicwong 4 | > Mail: mazicwong@gmail.com 5 | > Created Time: 2017年08月13日 星期日 00时20分05秒 6 | ************************************************************************/ 7 | 8 | #include 9 | #include 10 | #include 11 | #include 12 | #include 13 | #include 14 | using namespace std; 15 | /* 16 | * 最小的, 17 | * 18 | */ 19 | const int mod = 1e9+7; 20 | const int maxn = 2e5+5 21 | int a[maxn]; 22 | int main() 23 | { 24 | freopen("in","r",stdin); 25 | int n; 26 | cin >> n; 27 | for(int i=0;i 3 | using namespace std; 4 | typedef long long ll; 5 | const int Maxn = 1e6+10; 6 | const int Mod = 1e9+7; 7 | ll a[Maxn]={}; 8 | ll b[Maxn]={},p[Maxn]={}; 9 | 10 | int main() { 11 | freopen("in4","r",stdin); 12 | int n; 13 | cin >> n; 14 | for (int i=1;i<=n;i++) 15 | { 16 | int x; 17 | scanf("%d",&x); 18 | a[x]++; 19 | } 20 | ll ans=0,x=1; 21 | for (int i=0;i<=1e6;i++){ 22 | b[i]=x; 23 | x = (x*2) % Mod; 24 | } 25 | for (int i=2;i<=1e6;i++){ 26 | p[i] = i; 27 | } 28 | for (int i=2;i<=1e6;i++){ 29 | for (int j=i+i;j<=1e6;j+=i) p[j]-= p[i]; 30 | } 31 | for (ll i=2;i<=1e6;i++){ 32 | ll cnt=0; 33 | for (int j=i;j<=1e6;j+=i) cnt+=a[j]; 34 | if (cnt==0) continue; 35 | ans+= (cnt * p[i]) % Mod * b[cnt-1] % Mod; 36 | //cout << ans << endl; 37 | ans %= Mod; 38 | } 39 | cout << ans << endl; 40 | return 0; 41 | } 42 | -------------------------------------------------------------------------------- /code/cf/428/in3: -------------------------------------------------------------------------------- 1 | 5 2 | 1 2 3 | 1 3 4 | 3 4 5 | 2 5 6 | -------------------------------------------------------------------------------- /code/cf/428/in4: -------------------------------------------------------------------------------- 1 | 4 2 | 2 3 4 6 3 | 4 | -------------------------------------------------------------------------------- /code/cf/430/a.cpp: -------------------------------------------------------------------------------- 1 | /************************************************************************* 2 | > File Name: a.cpp 3 | > Author: mazicwong 4 | > Mail: mazicwong@gmail.com 5 | > Created Time: 2017年08月29日 星期二 23时00分55秒 6 | ************************************************************************/ 7 | 8 | #include 9 | #include 10 | #include 11 | #include 12 | #include 13 | #include 14 | #include 15 | #include 16 | #include 17 | #include 18 | #include 19 | #include 20 | using namespace std; 21 | typedef long long ll; 22 | 23 | 24 | int main() 25 | { 26 | freopen("in","r",stdin); 27 | ll l,r,x,y,k; 28 | cin>>l>>r>>x>>y>>k; 29 | ll flag=1; 30 | ll t=y*k; 31 | ll t2=x*k; 32 | if((l>=x*k&&l<=y*k)||(r>=x*k&&r<=y*k)) 33 | puts("YES"); 34 | else 35 | puts("NO"); 36 | return 0; 37 | } 38 | -------------------------------------------------------------------------------- /code/cf/431/3.cpp: -------------------------------------------------------------------------------- 1 | /************************************************************************* 2 | > File Name: 3.cpp 3 | > Author: mazicwong 4 | > Mail: mazicwong@gmail.com 5 | > Created Time: 2017年09月02日 星期六 00时27分56秒 6 | ************************************************************************/ 7 | 8 | #include 9 | #include 10 | #include 11 | #include 12 | #include 13 | #include 14 | #include 15 | #include 16 | #include 17 | #include 18 | #include 19 | #include 20 | using namespace std; 21 | 22 | int main() 23 | { 24 | freopen("in","r",stdin); 25 | 26 | 27 | return 0; 28 | } 29 | -------------------------------------------------------------------------------- /code/cf/431/in3: -------------------------------------------------------------------------------- 1 | 3 2 | -------------------------------------------------------------------------------- /code/cf/438/in3: -------------------------------------------------------------------------------- 1 | 5 3 2 | 1 0 1 3 | 1 1 0 4 | 1 0 0 5 | 1 0 0 6 | 1 0 0 7 | -------------------------------------------------------------------------------- /code/cf/440/cc.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | typedef long long ll; 5 | 6 | bool isPrime(int n) { 7 | int sq = sqrt(n); 8 | for(int i=2; i<=sq; i++) { 9 | if(n % i == 0 ) return false; 10 | } 11 | return true; 12 | 13 | } 14 | 15 | 16 | typedef long long LL; 17 | int q; 18 | int n; 19 | int main() 20 | { 21 | cin>>q; 22 | for(int cas=1;cas<=q;cas++){ 23 | int n; 24 | scanf("%d",&n); 25 | int num=n%4; 26 | int res=n/4; 27 | if(num==0){ 28 | cout<>q; 13 | for(int cas=1;cas<=q;cas++) 14 | { 15 | int n; 16 | scanf("%d",&n); 17 | int num=n%4; 18 | int res=n/4; 19 | if(num==0) 20 | cout< 2 | #include 3 | #include 4 | #include 5 | using namespace std; 6 | const int maxn = 1e5 + 5; 7 | typedef long long ll; 8 | const ll inf = 0x3f3f3f3f; 9 | priority_queue pq; 10 | int main() 11 | { 12 | int n; 13 | cin >> n; 14 | ll sum = 0; 15 | int a; 16 | for (int i = 0; i < n; i++) { 17 | scanf("%d", &a); 18 | sum += a; 19 | } 20 | while (!pq.empty()) pq.pop(); 21 | int b; 22 | for (int i = 0; i < n; i++) { 23 | scanf("%d", &b); 24 | pq.push(b); 25 | } 26 | ll tt = pq.top(); pq.pop(); 27 | ll qq = pq.top(); 28 | tt += qq; 29 | if (tt >= sum) 30 | cout << "YES"; 31 | else cout << "NO"; 32 | return 0; 33 | } -------------------------------------------------------------------------------- /code/cf/446b.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | using namespace std; 6 | const int maxn = 1e6 + 5; 7 | typedef long long ll; 8 | const ll inf = 0x3f3f3f3f; 9 | 10 | int L[maxn]; 11 | int main() 12 | { 13 | int n; cin >> n; 14 | int ans = 0; 15 | for (int i = 1; i <= n; i++) { 16 | scanf("%d", &L[i]); 17 | } 18 | int now = n+1; 19 | for (int i = n; i >= 1; i--) { 20 | if (now > i) { 21 | ans++; 22 | } 23 | now = min(now, i - L[i]); 24 | } 25 | cout << ans; 26 | return 0; 27 | } -------------------------------------------------------------------------------- /code/cf/446d.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | using namespace std; 7 | const int maxn = 20 + 5; 8 | typedef long long ll; 9 | const int inf = 0x3f3f3f3f; 10 | 11 | int a[maxn]; 12 | ll pre[maxn]; 13 | int n; 14 | bool flag = false; 15 | void dfs(ll sum, int dep) 16 | { 17 | if (dep == n) { 18 | flag = true; 19 | } 20 | if (flag) return; 21 | if (sum == pre[dep]) { 22 | return; 23 | } 24 | for (int i = dep + 1; i < n; i++) { 25 | swap(a[dep], a[i]); 26 | dfs(sum + a[dep],dep+1); 27 | swap(a[dep], a[i]); 28 | } 29 | } 30 | int main() 31 | { 32 | cin >> n; 33 | for (int i = 0; i < n; i++) { 34 | scanf("%d", &a[i]); 35 | } 36 | pre[0] = a[0]; 37 | for (int i = 1; i < n; i++) { 38 | pre[i] = pre[i - 1] + a[i]; 39 | } 40 | dfs(0, 0); 41 | if (flag) 42 | 43 | 44 | return 0; 45 | } -------------------------------------------------------------------------------- /code/cf/447/b.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | using namespace std; 7 | const int maxn = 2000 + 5; 8 | typedef long long ll; 9 | const int inf = 0x3f3f3f3f; 10 | const ll mod = 1e9 + 7; 11 | 12 | 13 | ll mod_pow(ll x, ll n)//x^n%mod 14 | { 15 | ll res=1; 16 | x=x%mod; 17 | while(n>0) 18 | { 19 | if (n&1) res = res*x%mod; 20 | x = x*x%mod; 21 | n>>=1; 22 | } 23 | return res; 24 | } 25 | 26 | int main() 27 | { 28 | ll n, m, k; 29 | while(1) { 30 | cin >> n >> m >> k; 31 | ll p = min(n,m); 32 | ll q = max(n,m); 33 | if(p==1 && ((q%2)==0 && k == -1)){ 34 | cout <<"0"< 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | #include 12 | #include 13 | #include 14 | using namespace std; 15 | 16 | int f[1005] = {1,1,1}; 17 | char ans[1005]; 18 | int main() 19 | { 20 | //freopen("in","r",stdin); 21 | int n;cin>>n; 22 | for (int i=1;i<=n;i++) ans[i]='o'; 23 | for (int i=3;i<=1003;i++) { 24 | f[i] = f[i-1]+f[i-2]; 25 | if (f[i]>n) break; 26 | ans[f[i]]='O'; 27 | } 28 | ans[1]=ans[2]='O'; 29 | for (int i=1;i<=n;i++) 30 | cout << ans[i]; 31 | 32 | return 0; 33 | } 34 | -------------------------------------------------------------------------------- /code/cf/459/2.cpp: -------------------------------------------------------------------------------- 1 | //2.cpp 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 | using namespace std; 15 | 16 | 17 | int main() 18 | { 19 | //freopen("in","r",stdin); 20 | map mp1; 21 | string str1,str2; 22 | int n,m;cin>>n>>m; 23 | for (int i=0;i> str1; 25 | cin >> str2; 26 | mp1[str2] = str1; 27 | } 28 | 29 | for (int i=0;i>str1; 31 | //str1 = str1.substr(0,str1.size()-1); 32 | cin>>str2; 33 | str2 = str2.substr(0,str2.size()-1); 34 | cout << str1 << ' ' << str2 << "; #" << mp1[str2] << endl; 35 | } 36 | return 0; 37 | } 38 | -------------------------------------------------------------------------------- /code/cf/460/1.cpp: -------------------------------------------------------------------------------- 1 | //1.cpp 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 | using namespace std; 15 | 16 | int main() 17 | { 18 | //freopen("in","r",stdin); 19 | int n,m;cin>>n>>m; 20 | double a,b; 21 | double minn = 0x3f3f3f3f; 22 | for (int i=1;i<=n;i++) 23 | { 24 | scanf("%lf%lf",&a,&b); 25 | minn = min(minn,a/b); 26 | } 27 | printf("%.8lf",minn*m); 28 | 29 | return 0; 30 | } 31 | -------------------------------------------------------------------------------- /code/cf/460/2.cpp: -------------------------------------------------------------------------------- 1 | //2.cpp 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | #include 12 | #include 13 | using namespace std; 14 | 15 | int calc(int a) 16 | { 17 | int ans = 0; 18 | while(a) 19 | { 20 | ans+=a%10; 21 | a/=10; 22 | } 23 | return ans; 24 | } 25 | 26 | int main() 27 | { 28 | //freopen("in","r",stdin); 29 | int k;cin>>k; 30 | int cnt=0,i=1; 31 | for ( i=1;i<20100000;i++) 32 | { 33 | if (calc(i)==10) 34 | { 35 | cnt++; 36 | if (cnt==k) break; 37 | } 38 | } 39 | cout << i; 40 | 41 | return 0; 42 | } 43 | -------------------------------------------------------------------------------- /code/cf/461/1.cpp: -------------------------------------------------------------------------------- 1 | //1.cpp 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 | using namespace std; 15 | 16 | int main() 17 | { 18 | //freopen("in","r",stdin); 19 | int x,y; cin>>x>>y; 20 | if (y==0) 21 | cout << "NO"; 22 | else if (y==1) 23 | { 24 | if (x%2==0) cout << "YES"; 25 | else cout << "NO"; 26 | } 27 | else if (x==0) 28 | { 29 | cout << "NO"; 30 | } 31 | else if (x==1) 32 | { 33 | if (y==2) cout << "YES"; 34 | else cout << "NO"; 35 | } 36 | else 37 | { 38 | y--; 39 | x=x-y; 40 | if (x<0) cout << "NO"; 41 | else if (x%2==0) cout << "YES"; 42 | else cout << "NO"; 43 | } 44 | return 0; 45 | } 46 | -------------------------------------------------------------------------------- /code/cf/461/2.cpp: -------------------------------------------------------------------------------- 1 | //2.cpp 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 | using namespace std; 15 | 16 | int main() 17 | { 18 | //freopen("in","r",stdin); 19 | int n; cin>>n; 20 | int ans = 0; 21 | //for(int time=1;time<=2500;time++) 22 | //{ 23 | //n=time; 24 | for (int i=1;i<=n;i++) 25 | { 26 | for (int j=i;j<=n;j++) 27 | { 28 | for (int k=j;k<=n && i+j>k && k-j 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | #include 12 | #include 13 | #include 14 | using namespace std; 15 | const int maxn = 1005; 16 | char str[1005]; 17 | 18 | int main() 19 | { 20 | scanf("%s",str); 21 | int len = strlen(str); 22 | for (int i=0;i=0;i--) 27 | { 28 | printf("%c",str[i]); 29 | } 30 | 31 | return 0; 32 | } 33 | -------------------------------------------------------------------------------- /code/cf/465/1.cpp: -------------------------------------------------------------------------------- 1 | //1.cpp 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 | using namespace std; 15 | 16 | int main() 17 | { 18 | //freopen("in","r",stdin); 19 | int n; cin>>n; 20 | int ans =0; 21 | for (int i=1;i<=n/2;i++) 22 | { 23 | if (n%i == 0) 24 | { 25 | ans++; 26 | } 27 | } 28 | cout << ans; 29 | 30 | return 0; 31 | } 32 | -------------------------------------------------------------------------------- /code/cf/466/1: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mazicwong/ACM_code/b4e774e8fb2087c89c607688600318a7ee6d4571/code/cf/466/1 -------------------------------------------------------------------------------- /code/cf/466/1.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | int a[105]; 4 | int main() 5 | { 6 | int n,d; cin>>n>>d; 7 | for (int i=0;itmp) 20 | { 21 | flag=true; 22 | ans = min(ans,(i)+(n-j) ); //[0,i) [j,n) 23 | break; 24 | } 25 | } 26 | if (flag==false) 27 | { 28 | ans = min(ans,i); 29 | } 30 | } 31 | cout << ans; 32 | 33 | 34 | 35 | return 0; 36 | } 37 | -------------------------------------------------------------------------------- /code/cf/466/2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mazicwong/ACM_code/b4e774e8fb2087c89c607688600318a7ee6d4571/code/cf/466/2 -------------------------------------------------------------------------------- /code/cf/466/2.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | typedef long long ll; 4 | ll n,k,A,B; 5 | int main() 6 | { 7 | cin>>n>>k>>A>>B; 8 | ll ans = 0; 9 | ll x = n; 10 | ans = (x-(x/k*k))*A; x=x/k*k; 11 | while((x-x/k)*A > B) 12 | { 13 | ans += B; 14 | x = x/k; 15 | 16 | ans += (x-x/k*k)*A; x=x/k*k; 17 | } 18 | ans += (x-1)*A; 19 | 20 | cout << ans; 21 | return 0; 22 | } 23 | -------------------------------------------------------------------------------- /code/cf/466/3: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mazicwong/ACM_code/b4e774e8fb2087c89c607688600318a7ee6d4571/code/cf/466/3 -------------------------------------------------------------------------------- /code/cf/466/4: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mazicwong/ACM_code/b4e774e8fb2087c89c607688600318a7ee6d4571/code/cf/466/4 -------------------------------------------------------------------------------- /code/cf/467/1: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mazicwong/ACM_code/b4e774e8fb2087c89c607688600318a7ee6d4571/code/cf/467/1 -------------------------------------------------------------------------------- /code/cf/467/1.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | int a[105]; 4 | int main() 5 | { 6 | int n; cin>>n; 7 | for (int i=0;i>a[i]; 8 | int flag=0; 9 | set st; 10 | for (int i=0;i 2 | using namespace std; 3 | typedef long long ll; 4 | 5 | 6 | int main() 7 | { 8 | //k off 9 | //t 2t 10 | //d circule 11 | 12 | ll k,d,t; cin>>k>>d>>t; 13 | double ans = 0; 14 | if (k%d == 0) 15 | ans = t; 16 | else 17 | { 18 | double tmp = k/d; 19 | double m = (tmp+1)*d; 20 | double ss = k+(m-k)*0.5; 21 | ll cnt = t/ss; 22 | ans += cnt*m; 23 | double left_time = t-ss*cnt; 24 | if(left_time<=k) ans+=left_time; 25 | else ans+=k+(left_time-k)*2; 26 | } 27 | printf("%.10lf",ans); 28 | //cout << ans; 29 | return 0; 30 | } 31 | -------------------------------------------------------------------------------- /code/cf/468/1: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mazicwong/ACM_code/b4e774e8fb2087c89c607688600318a7ee6d4571/code/cf/468/1 -------------------------------------------------------------------------------- /code/cf/468/1.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | int main() 5 | { 6 | int a,b;cin>>a>>b; 7 | int ans = abs(a-b); 8 | if(ans%2==0) 9 | cout << (ans/2*(1+ans/2)); 10 | else cout << (((ans/2)*(1+ans/2))/2+(ans/2+1)*(2+ans/2)/2); 11 | 12 | 13 | return 0; 14 | } 15 | -------------------------------------------------------------------------------- /code/cf/468/2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mazicwong/ACM_code/b4e774e8fb2087c89c607688600318a7ee6d4571/code/cf/468/2 -------------------------------------------------------------------------------- /code/cf/468/2.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | int main() 5 | { 6 | int n; cin>>n; 7 | int a,b; cin>>a>>b; 8 | a--; b--; 9 | while(a!=b) 10 | { 11 | cnt++; 12 | a/=2; 13 | b/=2; 14 | n/=2; 15 | } 16 | if(n==1) cout << "Final!"; 17 | else cout << cnt; 18 | 19 | return 0; 20 | } 21 | -------------------------------------------------------------------------------- /code/cf/468/4: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mazicwong/ACM_code/b4e774e8fb2087c89c607688600318a7ee6d4571/code/cf/468/4 -------------------------------------------------------------------------------- /code/cf/468/4.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | const int maxn = 1e6+5; 4 | int a[maxn]; 5 | int mp[maxn]; 6 | int mp1[maxn]; 7 | int main() 8 | { 9 | int n; cin>>n; 10 | mp[1]=1; 11 | mp[2]=1; 12 | for (int i=2;i<=n;i++) 13 | { 14 | scanf("%d",&a[i]); 15 | mp[i]=mp[a[i]]+1; 16 | } 17 | for(int i=2;i<=n;i++) 18 | { 19 | mp1[mp[i]]++; 20 | } 21 | int ans = 1; 22 | for(int i=2;i<=n;i++) 23 | { 24 | if(mp1[i]!=0 && mp1[i]%2!=0) 25 | { 26 | ans++; 27 | } 28 | } 29 | cout << ans; 30 | 31 | 32 | return 0; 33 | } 34 | -------------------------------------------------------------------------------- /code/cf/470/1: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mazicwong/ACM_code/b4e774e8fb2087c89c607688600318a7ee6d4571/code/cf/470/1 -------------------------------------------------------------------------------- /code/cf/470/2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mazicwong/ACM_code/b4e774e8fb2087c89c607688600318a7ee6d4571/code/cf/470/2 -------------------------------------------------------------------------------- /code/cf/470/2.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | const int maxn = 1e6+5; //78498 4 | bool isprime[maxn]; 5 | int cnt=0; 6 | int prime[maxn]; 7 | void get_prime(int n) 8 | { 9 | memset(isprime,true,sizeof(isprime)); 10 | isprime[0]=isprime[1]=false; 11 | for(int i=2;i>n; 22 | get_prime(n); 23 | for(int i=1;i 2 | using namespace std; 3 | 4 | int main() 5 | { 6 | int hh,mm; 7 | cin>>hh>>mm; 8 | 9 | int h,d,c,n; 10 | cin>>h>>d>>c>>n; 11 | if(hh>=20) 12 | { 13 | double num = h/n + (h%n!=0); 14 | double ans = num*0.8*c; 15 | printf("%.4lf",ans); 16 | return 0; 17 | } 18 | 19 | double num1 = h/n+(h%n!=0); 20 | double ans1=num1*c; 21 | //cout << ans1 << endl; 22 | 23 | int qaq2 = ((20-hh)*60-mm)*d+h; 24 | //cout << qaq2< 2 | using namespace std; 3 | const int maxn = 1e5+5; 4 | char str[maxn]; 5 | mapmp; 6 | int main() 7 | { 8 | cin>>str; 9 | int len=strlen(str); 10 | //sort(str,str+len); 11 | for(int i=0;i1) cnt2++; 22 | } 23 | if(cnt1+cnt2 > 4) 24 | { 25 | cout << "No"; return 0; 26 | } 27 | if(cnt1+2*cnt2 >=4) 28 | { 29 | cout << "Yes"; return 0; 30 | } 31 | else 32 | { 33 | cout << "No"; return 0; 34 | } 35 | return 0; 36 | } 37 | -------------------------------------------------------------------------------- /code/cf/472/3.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | typedef long long ll; 4 | const int maxn = 1e5+5; 5 | int a[maxn]; 6 | /* 7 | * 5 3 8 | * 4 6 8 9 10 9 | */ 10 | int main() 11 | { 12 | int n,u; 13 | cin>>n>>u; 14 | for(int i=0;ians) ans=tmp; 27 | } 28 | printf("%.09lf",ans); 29 | return 0; 30 | } 31 | -------------------------------------------------------------------------------- /code/cf/473/1.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | int main() 5 | { 6 | int n; 7 | cin>>n; 8 | if(n%2==1) 9 | { 10 | cout << "Ehab"; 11 | } 12 | else 13 | { 14 | cout << "Mahmoud"; 15 | } 16 | 17 | return 0; 18 | } 19 | -------------------------------------------------------------------------------- /code/cf/473/2.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | const int maxn = 1e5+5; 4 | int cost[maxn]; 5 | int tmp[maxn]; 6 | string str[maxn]; 7 | map mp; 8 | int main() 9 | { 10 | int n,k,m; cin>>n>>k>>m; 11 | for(int i=1;i<=n;i++) 12 | { 13 | cin>>str[i]; 14 | mp[str[i]] = i; 15 | } 16 | for(int i=1;i<=n;i++) scanf("%d",&cost[i]); 17 | for(int i=1;i<=k;i++) 18 | { 19 | int cnt; cin>>cnt; 20 | int minn = 0x3f3f3f3f; 21 | for(int j=0;j>tmp[j]; 24 | minn = min(minn, cost[tmp[j]]); 25 | } 26 | for(int j=0;j>qq; 36 | ans += cost[mp[qq]]; 37 | } 38 | cout << ans; 39 | return 0; 40 | } 41 | -------------------------------------------------------------------------------- /code/cf/473/3.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | int main() 5 | { 6 | int n; cin>>n; 7 | if(n>=6) 8 | { 9 | cout << "1 2\n"; 10 | cout << "2 3\n"; 11 | cout << "2 4\n"; 12 | for(int i=5;i<=n;i++) 13 | { 14 | cout << "1 " << i << endl; 15 | } 16 | } 17 | else 18 | { 19 | cout << "-1\n"; 20 | } 21 | for(int i=2;i<=n;i++) 22 | { 23 | cout << '1' << ' ' << i << endl; 24 | } 25 | return 0; 26 | } 27 | -------------------------------------------------------------------------------- /code/cf/473/4.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | const int maxn = 1e5+5; 4 | int a[maxn]; 5 | int gcd(int a,int b) 6 | { 7 | return b==0?a:gcd(b,a%b); 8 | } 9 | int main() 10 | { 11 | /*int n; cin>>n; 12 | for(int i=1;i<=n;i++) scanf("%d",&a[i]);*/ 13 | cout << gcd(6,12) << endl; 14 | cout << gcd(6,9) << endl; 15 | 16 | return 0; 17 | } 18 | -------------------------------------------------------------------------------- /code/cf/473/5.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | //1, 3, 4, 8, 9, 11, 12, 20, 21 4 | //oeis: 5 | long long dfs(long long n) 6 | { 7 | if(n==1) return 1; 8 | else if (n%2==0) return 2*dfs(n/2)+n/2; 9 | else return 2*dfs((n-1)/2)+(n-1)/2+1; 10 | } 11 | int main() 12 | { 13 | long long n; cin>>n; 14 | n--; 15 | cout << dfs(n); 16 | return 0; 17 | } 18 | -------------------------------------------------------------------------------- /code/cf/473/test.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #define LL long long int 3 | using namespace std; 4 | LL f(LL x) 5 | { 6 | if(x==1)return 1; 7 | if(x%2==0) return 2*f(x/2)+x/2; 8 | else return 2*f((x-1)/2)+(x-1)/2+1; 9 | } 10 | int main() 11 | { 12 | LL n; 13 | for(LL i=2;i<=20;i++) 14 | { 15 | n=i; 16 | n--; 17 | cout< 2 | using namespace std; 3 | int n,a,b; 4 | const int maxn = 1e5+5; 5 | int s[maxn]; 6 | int main() 7 | { 8 | cin>>n>>a>>b; 9 | for(int i=0;i 2 | using namespace std; 3 | 4 | int main() 5 | { 6 | int a[5]={0,1,1,2,3}; 7 | cout << lower_bound(a,a+5,4)-a; 8 | 9 | return 0; 10 | } 11 | -------------------------------------------------------------------------------- /code/cf/478/1.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | const int maxn = 1e3+5; 4 | int main() 5 | { 6 | int n; cin>>n; 7 | string str; 8 | map mp; mp.clear(); 9 | map mpp; mpp.clear(); 10 | int ans=0; 11 | string ss = "abcdefghijklmnopgrstuvwxyz"; 12 | set st; st.clear(); 13 | while(n--) 14 | { 15 | cin>>str; 16 | int len=str.size(); 17 | mp.clear(); 18 | for(int i=0;i File Name: A.cpp 3 | > Author: mazicwong 4 | > Mail: mazicwong@gmail.com 5 | > Created Time: 2017年07月24日 星期一 22时24分05秒 6 | ************************************************************************/ 7 | 8 | #include 9 | #include 10 | #include 11 | #include 12 | #include 13 | #include 14 | using namespace std; 15 | typedef long long ll; 16 | ll n,k; 17 | 18 | int main() 19 | { 20 | //freopen("in","r",stdin); 21 | cin >> n >> k; 22 | ll tmp = n/k; 23 | if (tmp%2==1) 24 | puts("YES"); 25 | else 26 | puts("NO"); 27 | return 0; 28 | } 29 | -------------------------------------------------------------------------------- /code/cf/835A.cpp: -------------------------------------------------------------------------------- 1 | /************************************************************************* 2 | > File Name: 1.cpp 3 | > Author: mazicwong 4 | > Mail: mazicwong@gmail.com 5 | > Created Time: 2017年07月31日 星期一 22时31分58秒 6 | ************************************************************************/ 7 | 8 | #include 9 | #include 10 | #include 11 | #include 12 | #include 13 | #include 14 | #include 15 | using namespace std; 16 | typedef long long ll; 17 | int main() 18 | { 19 | freopen("in","r",stdin); 20 | int s,v1,v2,t1,t2; 21 | scanf("%d%d%d%d%d",&s,&v1,&v2,&t1,&t2); 22 | int a=s*v1+2*t1; 23 | int b=s*v2+2*t2; 24 | if (ab) 27 | printf("Second"); 28 | else printf("Friendship"); 29 | 30 | 31 | 32 | return 0; 33 | } 34 | -------------------------------------------------------------------------------- /code/cf/edu35/4.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | using namespace std; 5 | const int maxn = 2e6+500; 6 | const int maxm = 1e6+500; 7 | int ans,n,m,r,l,a[maxn]; 8 | 9 | int main() 10 | { 11 | cin>>n; 12 | for (int i=1;i<=n;i++) 13 | scanf("%d",&a[i]); 14 | for (int i=1;i<=n;i++) 15 | for (int j=1;j<=i-1;j++) 16 | if(a[j] > a[i]) 17 | ans ^= 1; 18 | cin>>m; 19 | for (int i=1;i<=m;i++) 20 | { 21 | scanf("%d%d",&l,&r); 22 | if(l > r) swap(l,r); 23 | int mm = (r - l + 1)/2; 24 | ans ^= (mm&1); 25 | puts(ans?"odd":"even"); 26 | } 27 | return 0; 28 | } 29 | -------------------------------------------------------------------------------- /code/cf/edu38/1.cpp: -------------------------------------------------------------------------------- 1 | nclude 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | #include 12 | #include 13 | using namespace std; 14 | 15 | bool sss(char c) 16 | { 17 | if (c == 'a' || c=='e' || c=='i' || c=='o' || c=='u' || c=='y') 18 | return true; 19 | return false; 20 | } 21 | 22 | bool flag[105]; 23 | int main() 24 | { 25 | int n; cin>>n; 26 | string str; cin>>str; 27 | for (int i=str.size();i>=1;i--) 28 | { 29 | if (sss(str[i]) && sss(str[i-1])) 30 | { 31 | flag[i]=1; 32 | } 33 | } 34 | for (int i=0;i 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | #include 12 | #include 13 | #include 14 | using namespace std; 15 | const int maxn = 1e6; 16 | int a[maxn+5]; 17 | int main() 18 | { 19 | //freopen("in","r",stdin); 20 | int n; cin>>n; 21 | 22 | int ans = 0; 23 | for (int i=0;i 2 | using namespace std; 3 | 4 | int main() 5 | { 6 | int n;cin>>n; 7 | int maxx=0; 8 | int minn=0; 9 | int tmp; 10 | for (int i=0;i>tmp; 13 | if(tmp>0) maxx+=tmp; 14 | else if (tmp<0) minn+=(-tmp); 15 | } 16 | cout << (maxx+minn); 17 | 18 | return 0; 19 | } 20 | -------------------------------------------------------------------------------- /code/cf/edu39/2.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | typedef long long ll; 4 | ll a,b; 5 | int main() 6 | { 7 | cin>>a>>b; 8 | while(a!=0 && b!=0) 9 | { 10 | if (a>=2*b) 11 | { 12 | ll tmp = a/b; 13 | if(tmp%2==1) tmp--; 14 | a=a-tmp*b; 15 | } 16 | else if (b>=2*a) 17 | { 18 | ll tmp = b/a; 19 | if(tmp%2==1) tmp--; 20 | b=b-tmp*a; 21 | } 22 | else break; 23 | } 24 | cout< 2 | using namespace std; 3 | int main() 4 | { 5 | string str; 6 | cin>>str; 7 | int cnt=0; 8 | for(int i=0;i 2 | using namespace std; 3 | const int maxn = 1005; 4 | int c[maxn]; 5 | 6 | int n,m; 7 | bool check() 8 | { 9 | for(int i=1;i<=n;i++) 10 | { 11 | if(c[i]==0) return false; 12 | } 13 | return true; 14 | } 15 | void upd() 16 | { 17 | for(int i=1;i<=n;i++) c[i]--; 18 | } 19 | int main() 20 | { 21 | cin>>n>>m; 22 | int ans=0; 23 | for(int i=1;i<=m;i++) 24 | { 25 | int tmp; cin>>tmp; c[tmp]++; 26 | if(check()==true) 27 | { 28 | upd(); 29 | ans++; 30 | } 31 | } 32 | cout< 2 | using namespace std; 3 | const int maxn = 1e5+5; 4 | int a[maxn]; 5 | int t[maxn]; 6 | 7 | int main() 8 | { 9 | int n,k; cin>>n>>k; 10 | int ans = 0; 11 | for(int i=1;i<=n;i++) 12 | { 13 | cin>>a[i]; 14 | } 15 | for(int i=1;i<=n;i++) 16 | { 17 | cin>>t[i]; 18 | if(t[i]==1) ans+=a[i]; 19 | } 20 | 21 | int cnt=0; 22 | for(int i=1;i<=k;i++) 23 | { 24 | if(t[i] == 0) 25 | { 26 | cnt += a[i]; 27 | } 28 | } 29 | int maxx = cnt; 30 | 31 | for(int i=2;i<=n-k+1;i++) //[n-k, n] 32 | { 33 | if(t[i-1]==0) 34 | { 35 | cnt -= a[i-1]; 36 | } 37 | if(t[i+k-1]==0) 38 | { 39 | cnt += a[i+k-1]; 40 | } 41 | maxx = max(maxx,cnt); 42 | } 43 | cout << maxx+ans; 44 | return 0; 45 | } 46 | -------------------------------------------------------------------------------- /code/cf/edu43/1.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | int main() 5 | { 6 | int n; cin>>n; 7 | string str; cin>>str; 8 | int num1=0; 9 | for(int i=0;i 2 | using namespace std; 3 | typedef long long ll; 4 | 5 | int main() 6 | { 7 | ll n,m,k; cin>>n>>m>>k; 8 | if(k<=n-1){ 9 | cout << k+1 << ' ' << '1'; 10 | } 11 | else if(k<=n-1+m-1){ 12 | cout << n << ' ' << k-(n-2); 13 | } 14 | else{ 15 | k -= (n-1+m-1); 16 | //cout << k << endl; 17 | int tmp = k/(m-1); 18 | if(k%(m-1)!=0) tmp++; 19 | //cout << tmp << endl; 20 | cout << n-tmp << ' '; 21 | int qq = k%(m-1); if(qq==0) qq=m-1; 22 | if(tmp%2==1) // left 23 | { 24 | cout << m-qq+1; 25 | } 26 | else 27 | { 28 | cout << 1+qq; 29 | } 30 | } 31 | return 0; 32 | } 33 | -------------------------------------------------------------------------------- /code/cf/edu43/3.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | const int maxn = 3e5+5; 4 | int l[maxn]; 5 | int r[maxn]; 6 | struct Node{ 7 | int l,r; 8 | int idx; 9 | bool operator<(const Node & rhs){ 10 | 11 | if(l == rhs.l) return r>rhs.r; 12 | else return l>n; 18 | for(int i=0;i=node[i-1].l && node[i].r<=node[i-1].r){ 28 | cout << node[i].idx << " " << node[i-1].idx; 29 | return 0; 30 | } 31 | 32 | //cout << node[i].l << ' ' << node[i].r< 2 | using namespace std; 3 | const int mod = 3e5; 4 | const int maxn = 3e5+5; 5 | typedef long long ll; 6 | const ll mod1= 1e9; 7 | int main() 8 | { 9 | srand(time(NULL)); 10 | ll n = rand()%mod1; 11 | if(n&1==1) n++; 12 | cout << n << endl; 13 | ll m = rand()%mod1; 14 | cout << m << endl; 15 | ll k=rand()%mod1; 16 | if(k>n*m) k=n; 17 | cout << k << endl; 18 | 19 | return 0; 20 | } 21 | -------------------------------------------------------------------------------- /code/cf/edu43/data_maker: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mazicwong/ACM_code/b4e774e8fb2087c89c607688600318a7ee6d4571/code/cf/edu43/data_maker -------------------------------------------------------------------------------- /code/cf/edu43/sh.bash: -------------------------------------------------------------------------------- 1 | #bash 2 | while true; do 3 | ./data_maker>tmp.in #出数据 4 | ./a.outtmp.out #被测程序 5 | ./3.outtmp2.out #正确(暴力)程序 6 | if diff tmp.out tmp2.out; then #比较两个输出文件 7 | a=1 #printf "AC\n" #结果相同显示 AC 8 | elif diff -B -b tmp.out tmp2.out; then 9 | a=1 #printf "PE\n" 10 | else 11 | printf "WA\n" #结果不同显示 WA,并退出 12 | exit 0 13 | fi 14 | done 15 | -------------------------------------------------------------------------------- /code/cf/hdu6033.cpp: -------------------------------------------------------------------------------- 1 | /************************************************************************* 2 | > File Name: A.cpp 3 | > Author: mazicwong 4 | > Mail: mazicwong@gmail.com 5 | > Created Time: 2017年07月25日 星期二 12时00分44秒 6 | ************************************************************************/ 7 | 8 | #include 9 | #include 10 | #include 11 | #include 12 | #include 13 | #include 14 | #include 15 | using namespace std; 16 | const int maxn = 1e5+5; 17 | int main() 18 | { 19 | freopen("in","r",stdin); 20 | int n; 21 | int cas=1; 22 | int ans=0; 23 | while(scanf("%d",&n)!=EOF) 24 | { 25 | ans = n*log(2)/log(10); 26 | printf("Case #%d: %d\n",cas++,ans); 27 | } 28 | return 0; 29 | } 30 | -------------------------------------------------------------------------------- /code/leetcode/1.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using namespace std; 3 | 4 | class Solution { 5 | public: 6 | vector twoSum(vector& nums, int target) { 7 | vector ans; 8 | for (int i=0;i 2 | using namespace std; 3 | 4 | /** 5 | * Definition for singly-linked list. 6 | * struct ListNode { 7 | * int val; 8 | * ListNode *next; 9 | * ListNode(int x) : val(x), next(NULL) {} 10 | * }; 11 | */ 12 | class Solution { 13 | public: 14 | ListNode* addTwoNumbers(ListNode* l1, ListNode* l2) { 15 | ListNode *ans; 16 | int tmp1=0; 17 | while(l1!=NULL) 18 | { 19 | tmp1 = tmp1*10+*l1.val; 20 | l1 = l1.next; 21 | } 22 | int tmp2=0; 23 | while(l2!=NULL) 24 | { 25 | tmp2 = tmp2*10+l2.val; 26 | l2 = l2.next; 27 | } 28 | int tmp = tmp1+tmp2; 29 | while(tmp) 30 | { 31 | int now = tmp%10; 32 | tmp/=10; 33 | *ans = now; 34 | } 35 | return ans; 36 | } 37 | }; 38 | 39 | int main() 40 | { 41 | 42 | return 0; 43 | } 44 | -------------------------------------------------------------------------------- /code/notice.md: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mazicwong/ACM_code/b4e774e8fb2087c89c607688600318a7ee6d4571/code/notice.md -------------------------------------------------------------------------------- /code/poj/1004.cpp: -------------------------------------------------------------------------------- 1 | //1004.cpp 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 | using namespace std; 15 | 16 | int main() 17 | { 18 | int n=12; 19 | double sum=0.0; 20 | while(n--) 21 | { 22 | double tmp; cin>>tmp; 23 | sum+=tmp; 24 | } 25 | printf("$%.2lf\n",sum/12); 26 | 27 | return 0; 28 | } 29 | -------------------------------------------------------------------------------- /code/poj/1005.cpp: -------------------------------------------------------------------------------- 1 | //1005.cpp 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 | using namespace std; 15 | double PI = acos(-1); 16 | int main() 17 | { 18 | //freopen("in","r",stdin); 19 | int n;cin>>n; 20 | double x,y; 21 | for (int cas=1;cas<=n;cas++) 22 | { 23 | cin>>x>>y; 24 | double RR = x*x+y*y; 25 | double area = PI*RR/2; 26 | int ans = (int)(area/50)+1; 27 | printf("Property %d: This property will begin eroding in year %d.\n",cas,ans); 28 | } 29 | printf("END OF OUTPUT."); 30 | return 0; 31 | } 32 | -------------------------------------------------------------------------------- /code/poj/1006.cpp: -------------------------------------------------------------------------------- 1 | //1006.cpp 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 | using namespace std; 15 | 16 | int gcd(int a,int b) 17 | { 18 | return b==0?a:gcd(b,a%b); 19 | } 20 | int lcm(int a,int b) 21 | { 22 | return a*b/gcd(a,b); 23 | } 24 | 25 | /* 26 | * 问题等价于 27 | * (ans-a)%p = 0 28 | * (ans-b)%e = 0 29 | * (ans-c)%i = 0 30 | * ans > d 31 | */ 32 | 33 | int main() 34 | { 35 | //freopen("in","r",stdin); 36 | //time period: 23,28,33 37 | int p,e,i; 38 | int d; 39 | int cas=1; 40 | int ans = 0; 41 | //cout << lcm(lcm(33,28),23); 42 | while(cin>>p>>e>>i>>d && p!=-1) 43 | { 44 | 45 | printf("Case %d: the next triple peak occurs in %d days.\n",cas++,ans); 46 | } 47 | return 0; 48 | } 49 | -------------------------------------------------------------------------------- /code/poj/1008.cpp: -------------------------------------------------------------------------------- 1 | //1008.cpp 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 | using namespace std; 15 | 16 | typedef pair PII; 17 | 18 | 19 | struct Node{ 20 | int a,b; 21 | }node[maxn]; 22 | 23 | 24 | int main() 25 | { 26 | //freopen("in","r",stdin); 27 | int n;cin>>n; 28 | for (int i=0;i