ACM入门十题(杭电oj)

合集下载

(完整版)杭电acm部分答案

(完整版)杭电acm部分答案

Problem DescriptionCalculate A + B.InputEach line will contain two integers A and B. Process to end of file.OutputFor each case, output A + B in one line.Sample Input1 1Sample Output2#include<stdio.h>void main(){int a,b;while(scanf("%d %d",&a,&b)!=EOF){printf("%d\n",a+b);}}Problem DescriptionHey, welcome to HDOJ(Hangzhou Dianzi University Online Judge).In this problem, your task is to calculate SUM(n) = 1 + 2 + 3 + ... + n.InputThe input will consist of a series of integers n, one integer per line.OutputFor each case, output SUM(n) in one line, followed by a blank line. You may assume the result will be in the range of 32-bit signed integer.Sample Input1100Sample Output15050#include<stdio.h>void main(){int n,sum,i;while(scanf("%d",&n)!=EOF){sum=0;for( i=0;i<=n;i++)sum+=i;printf("%d\n\n",sum);}}Problem DescriptionI have a very simple problem for you. Given two integers A and B, your job is to calculate the Sum of A + B.InputThe first line of the input contains an integer T(1<=T<=20) which means the number of test cases. Then T lines follow, each line consists of two positive integers, A and B. Notice that the integers are very large, that means you should not process them by using 32-bit integer. You may assume the length of each integer will not exceed 1000.OutputFor each test case, you should output two lines. The first line is "Case #:", # means the number of the test case. The second line is the an equation "A + B = Sum", Sum means the result of A + B. Note there are some spaces int the equation. Output a blank line between two test cases.Sample Input21 2112233445566778899 998877665544332211Sample OutputCase 1:1 +2 = 3Case 2:112233445566778899 + 998877665544332211 = 1111111111111111110 #include<stdio.h>#include<string.h>int main(){char str1[1001], str2[1001];int t, i, len_str1, len_str2, len_max, num = 1, k;scanf("%d", &t);getchar();while(t--){int a[1001] = {0}, b[1001] = {0}, c[1001] = {0};scanf("%s", str1);len_str1 = strlen(str1);for(i = 0; i <= len_str1 - 1; ++i)a[i] = str1[len_str1 - 1 - i] - '0';scanf("%s",str2);len_str2 = strlen(str2);for(i = 0; i <= len_str2 - 1; ++i)b[i] = str2[len_str2 - 1 - i] - '0';if(len_str1 > len_str2)len_max = len_str1;elselen_max = len_str2;k = 0;for(i = 0; i <= len_max - 1; ++i){c[i] = (a[i] + b[i] + k) % 10;k = (a[i] + b[i] + k) / 10;}if(k != 0)c[len_max] = 1;printf("Case %d:\n", num);num++;printf("%s + %s = ", str1, str2);if(c[len_max] == 1)printf("1");for(i = len_max - 1; i >= 0; --i){printf("%d", c[i]);}printf("\n");if(t >= 1)printf("\n");}return 0;}Problem DescriptionGiven a sequence a[1],a[2],a[3]......a[n], your job is to calculate the max sum of a sub-sequence. For example, given (6,-1,5,4,-7), the max sum in this sequence is 6 + (-1) + 5 + 4 = 14.InputThe first line of the input contains an integer T(1<=T<=20) which means the number of test cases. Then T lines follow, each line starts with a number N(1<=N<=100000), then N integers followed(all the integers are between -1000 and 1000).OutputFor each test case, you should output two lines. The first line is "Case #:", # means the number of the test case. The second line contains three integers, the Max Sum in the sequence, the start position of the sub-sequence, the end position of the sub-sequence. If there are more than one result, output the first one. Output a blank line between two cases.Sample Input25 6 -1 5 4 -77 0 6 -1 1 -6 7 -5Sample OutputCase 1:14 1 4Case 2:7 1 6注:最大子序列是要找出由数组成的一维数组中和最大的连续子序列。

杭州电子科技大学OJ题目分类

杭州电子科技大学OJ题目分类

杭州电子科技大学OJ题目分类1001 整数求和水题1002 C语言实验题——两个数比较水题1003 1、2、3、4、5... 简单题1004 渊子赛马排序+贪心的方法归并1005 Hero In Maze 广度搜索1006 Redraiment猜想数论:容斥定理1007 童年生活二三事递推题1008 University 简单hash1009 目标柏林简单模拟题1010 Rails 模拟题(堆栈)1011 Box of Bricks 简单题1012 u Calculate e 简单数学计算1013 STAMPS 搜索or动态规划1014 Border 模拟题1015 Simple Arithmetics 高精度计算1016 Shoot-out 博弈+状态压缩DP1017 Tour Guide1018 Card Trick 简单题1019 Necklace Decomposition 贪心1020 Crashing Robots 模拟题1021 Electrical Outlets 简单题1022 Watchdog 简单题1023 Taxi Cab Scheme 图论:最小路径覆盖--->最大二分匹配1024 Pseudo-random Numbers 数论1025 Card Game Cheater 简单题1026 Investment 动态规划1027 Pipes1028 SETI 数学:高斯消元法1029 Minimax Triangulation 计算几何1030 Unequalled Consumption 母函数1031 Declaration of Content1032 Laserbox 搜索:DFS1033 Bowlstack1034 Pesky Heroes1035 Reduced ID Numbers 暴力1036 Tantrix1037 Guardian of Decency 图论:匈牙利算法求二分图的最大匹配1038 Up the Stairs 简单数学题1039 Sudoku 搜索:DFS1040 The SetStack Computer1041 Pie 二分法1042 Ticket to Ride 动态规划1043 The Bookcase 动态规划1044 Printer Queue 模拟题1045 Prime Path 搜索:BFS1046 Lineland's Airport1047 Leonardo's Notebook 数学题:群置换1048 简易版最长序列简单题1049 Jesse's problem 搜索:DFS1050 Error Correction 模拟题1051 A ×B problem 高精度计算1052 Redraiment的走法动态规划1053 Word Encoding 动态规划1054 Jesse's Code 组合数学:排列1055 简单密码破解水题1056 英文金曲大赛水题1057 有假币水题1058 寄居蟹与海葵水题1059 天仙配水题1060 鹊桥相会水题1061 杨辉三角水题1062 蟠桃记水题1063 养兔子水题1064 字符统计水题1065 完美数水题1066 亲和数水题1067 成绩评估水题1068 找零钱水题1069 漂亮菱形水题1070 Least Common Multiple 水题1071 第几天水题1072 编辑距离水题1073 支配值数目水题1074 等值数目水题1075 两数组最短距离水题1076 输入入门(1) 水题1077 输入入门(2) 水题1078 输入入门(3) 水题1079 输出入门水题1080 Counterfeit Dollar 组合数学1081 Dividing 动态规划1082 Sorting It All Out 图论:拓扑排序1083 False coin 暴力法1084 File Mapping1085 Color Me Less 简单题1086 Round and Round We Go 简单题1087 Microprocessor Simulation 简单题1088 求奇数的乘积水题1089 平方和与立方和水题1090 绝对值排序水题1091 JudgeOnline 水题1092 More Beautiful 水题1093 猴子分桃水题1094 C语言实验题——一元二次方程水题1095 C语言实验题——保留字母水题1096 C语言实验题——排列水题1097 C语言实验题——矩阵转置水题1098 C语言实验题——素数水题1099 Ambiguous permutations 简单题1100 Home Work 贪心法1101 Redraiment的遭遇数学题:找规律1102 Decorate the wall 搜索or动态规划1103 Economic phone calls 动态规划or贪心1104 Any fool can do it 记忆化搜索1105 Wine trading in Gergovia 贪心法1106 Homogeneous squares 随机算法1107 Automatic Correction of Misspellings 字符串处理:字典序1108 Black and white painting 简单数学题1109 Cylinder 计算几何:公式推导1110 Deli Deli 水题1111 Expressions 数据结构:树的遍历1112 Flavius Josephus Reloaded 数论:Pollard's Rho算法1113 Annoying painting tool 贪心法1114 Frequent values RMQ区间最值问题OR 线段树1115 Anagram Groups 字符串匹配1116 Let it Bead 组合数学->Polya定理1117 Simple Computers 简单题1118 Mondriaan's Dream 动态规划1119 Equidistance 计算几何1120 How many Fibs? 高精度计算1121 Hike on a Graph 搜索:BFS1122 ASCII Art1123 Billing Tables1124 Cellular Automaton 矩阵计算1125 Exchange1126 Fool's Game1127 Java vs C++ 字符串处理1128 Kickdown 字符串处理1129 Copying Books 贪心+二分法1130 Adding Reversed Numbers 简单题1131 Glass Beads 字符串的最小表示1132 The Circumference of the Circle 计算几何题1133 Knight Moves 搜索:BFS1134 Eeny Meeny Moo 变形的约瑟夫问题1135 Lotto 组合数学1136 Humble Numbers 动态规划1137 Average is not Fast Enough! 简单题1138 Etaoin Shrdlu 简单题1139 Hard to Believe, but True! 简单题1140 Code the Tree 简单题1141 Fiber Network 图论:全源最短路径,Floyd-Warshall算法1142 Global Roaming 3D几何题1143 All in All 字符串处理1144 The Sierpinski Fractal 递归1145 Assistance Required 简单题:预处理1146 Drink, on Ice 模拟题1147 All Discs Considered 搜索:BFS1148 In Danger 模拟题1149 Run Length Encoding 字符串处理1150 Bee Maja 模拟题1151 Friends 表达式求值1152 John 博弈论1153 Double Queue 最大堆与最小堆1154 ‘JBC’1155 Loan Scheduling 贪心+堆1156 Showstopper1157 Highway 贪心法1158 Computers 动态规划1159 The Stable Marriage Problem 组合数学1160 Arne Saknussemm 模拟题1161 Sum Problem 水题1162 Fire Net 搜索题1163 统计1到N之间数字1的个数推理题1164 最大公因子水题1165 C语言实验题——三个整数水题1166 C语言实验题——大小写转换水题1167 C语言实验题——分数序列水题1168 C语言实验题——最值水题1169 C语言实验题——保留整数水题1170 C语言实验题——矩阵下三角元素之和水题1171 C语言实验题——字符逆序水题1172 C语言实验题——打印菱形水题1173 C语言实验题——分割整数水题1174 C语言实验题——删除指定字符水题1175 C语言实验题——时间间隔水题1176 C语言实验题——数组逆序水题1177 C语言实验题——打印数字图形水题1178 C语言实验题——单词统计水题1179 C语言实验题——最小公倍数和最大公约数水题1180 Crashing Balloon 搜索题1181 念数字模拟题1182 A+B for Input-Output Practice(1) 水题1183 Anagrams by Stack 搜索:回溯1184 Elevator 数学:找规律1185 Substrings 字符串处理1186 Calling Extraterrestrial Intelligence Again 搜索:枚举法1187 Do the Untwist 简单数学题1188 数字对水题1189 A+B for Input-Output Practice (2) 水题1190 火星A+B 简单题1191 三齿轮问题:三个齿轮啮合简单数学题1192 A + B Problem II 高精度计算1193 The ones to remain 数学题1194 Chinese Chess 博弈论1195 Page Replacement 数据结构:队列or hash1196 RSA Signing 数论:Pollard's Rho算法1197 Number Guessing 搜索:穷举1198 求n的阶乘高精度计算1199 Area 计算几何1200 求两直线的夹角水题1201 三角形面积水题1202 Max Sum 动态规划1203 Number Sequence 大数问题1204 u Calculate e 水题1205 斐波那契数列高精度计算1206 Fibonacci Again 大数问题1207 Let the Balloon Rise 字符串处理1208 还是A+B 水题1209 A + B 水题1210 The area 简单计算几何1211 Ignatius's puzzle 简单数学问题1212 Computer Transformation 高精度计算1213 N! 高精度计算1217 Text Reverse 水题1220 填数字游戏搜索:DFS1221 Tempter of the Bone 搜索:DFS or BFS+剪枝1226 Last non-zero Digit in N! 数论1227 三角形递推求解1228 回文数猜想简单题1229 Factorial 简单题1230 Specialized Four-Digit Numbers 简单数学题1231 Lowest Bit 简单题1232 To and Fro 简单题1233 AC Me 简单题1234 Wolf and Rabbit 数论1235 最大连续子序列动态规划1236 开门人和关门人字符串处理1237 排名排序1238 统计难题字符串处理:字典树1239 Tick and Tick 数学题1240 Quoit Design 分治法1241 钱币兑换问题递推求解1242 求出前m大的数简单题1243 角谷猜想简单题1244 Reverse Number 简单题1245 寻找素数对简单题1246 ZJUTACM 简单题1247 Hat's Fibonacci 高精度计算1248 Encoding 简单题1249 四数相加高精度计算1250 两数相减高精度计算1251 Square Coins 母函数1252 Counting Triangles 递推求解1253 2^x mod n = 1 数论:费尔马小定理1254 Minimum Inversion Number 简单题1255 Surround the Trees 计算几何:凸包1256 Number Steps 简单题1257 Binary Numbers 简单题1258 Knight Moves 搜索:BFS1259 Lotto 组合数学1260 A Simple Task 简单题1261 The Drunk Jailer 数论1262 Hanoi Tower Troubles Again! 递推求解1263 IBM Minus One 水题1264 Definite Values 简单题1265 Box of Bricks 水题1266 Perfection 简单题1267 Reverse Text 水题1268 Inversion 模拟题1269 Prime Cuts 简单题1270 How Many Fibs? 高精度计算1271 Round and Round We Go 简单题1272 Red and Black 搜索:DFS1273 What Day Is It? 简单题1274 String Matching 字符串匹配1275 A Contesting Decision 简单题1276 Doubles 简单题1277 The Snail 简单题1278 Jungle Roads 图论:最小生成树1279 Prime Ring Problem 搜索:DFS1280 Big Number 大数问题1281 Least Common Multiple 简单题1283 简单排序水题1284 Gridland 简单题1285 An Easy Task 简单题1286 Calendar Game 模拟题1287 Human Gene Functions 动态规划1288 计算几何练习题——线段相交计算几何1289 计算几何练习题——线段相交II 计算几何1290 计算几何练习题——直线交点计算几何1291 Trees Made to Order 递归求解1292 排序简单题1293 18岁生日简单题1294 吃糖果递推求解1295 变种汉诺塔递推求解1296 洗牌递推求解1297 大数求余数论1298 圆桌会议递推求解1299 畅通工程并查集1300 还是畅通工程最小生成树1301 统计同成绩学生人数水题1302 简单计算器表达式求值:栈的应用1303 改进版计算器表达式求值:栈的应用1304 FatMouse' Trade 贪心法1305 Digital Roots 大数问题1306 Uniform Generator 数论1307 A Mathematical Curiosity 穷举法1308 Safecracker 穷举法1309 The 3n + 1 problem 简单题1310 分享糖果模拟题1311 宝物收集搜索:BFS1312 Climbing Worm 简单题1313 搬桌子贪心法1314 Humble Numbers 动态规划1315 Dividing 动态规划1316 Rightmost Digit 数学问题1317 Leftmost Digit 数学问题1318 Hangover 简单数学问题1319 Exponentiation 高精度计算1320 I Think I Need a Houseboat 简单题1321 Girls and Boys DFS+二分图1322 Monkey and Banana 动态规划1323 买牛奶简单题1324 Matrix Chain Multiplication 数据结构:栈的应用1325 计算成绩简单题1326 Holding Bin-Laden Captive! 母函数1327 You can Solve a Geometry Problem too 计算几何1328 Super Jumping! Jumping! Jumping! 动态规划1329 a^b 数论1330 计算GPA 水题1331 Give me an offer! 动态规划:0-1背包1332 田忌赛马贪心法1333 Asteroids! 搜索:BFS1334 Oil Deposits 搜索:DFS1335 营救天使搜索:BFS1336 小数化分数高精度计算1337 I Hate It 线段树1338 Strange Billboard 位运算+枚举1339 Frobenius 递推求解1340 奇怪的公式数学题1341 Fibonacci again and again 博弈论1342 A New Tetris Game 博弈论1343 Sum It Up 搜索:DFS1344 速算24点搜索1345 推箱子搜索:BFS1346 Pushing Boxes 搜索:BFS1347 The Worm Turns 搜索1348 Alfredo's Pizza Restaurant 简单题1349 Broken Keyboard 字符串处理1350 Convert Kilometers to Miles 简单题1351 单词数水题1352 仙人球的残影简单题1353 Family planning 简单题1354 Rout 66 简单题1355 LC-Display 模拟题1356 A == B ? 高精度计算1357 不容易系列之一递推求解1358 折线分割平面递推求解1359 find the nth digit 二分查找1360 奇数阶魔方(II) 简单题1361 Keep on Truckin' 简单题1362 Factstone Benchmark 简单题1363 Destroy the Well of Life 模拟题1365 Brave Game 博弈论1366 ASCII码排序水题1367 计算两点间的距离水题1368 计算球体积水题1369 求绝对值水题1370 数值统计水题1371 求数列的和水题1372 水仙花数水题1373 多项式求和水题1374 素数判定水题1375 偶数求和水题1376 母牛的故事水题1377 数列有序! 水题1378 发工资咯:)水题1379 C语言合法标识符水题1380 海选女主角水题1381 查找最大元素水题1382 首字母变大写水题1383 统计元音水题1384 Palindromes _easy version 水题1385 汉字统计水题1386 进制转换水题1387 人见人爱A+B 水题1388 人见人爱A-B 水题1389 人见人爱A^B 水题1390 改革春风吹满地计算几何1391 今年暑假不AC 动态规划1392 三角形水题1393 求平均成绩水题1394 不容易系列之二递推求解1395 密码水题1396 一只小蜜蜂... 递推求解1397 不容易系列之(3)——LELE的RPG难题递推求解1398 骨牌铺方格递推求解1399 阿牛的EOF牛肉串递推求解1400 神、上帝以及老天爷递推求解1401 不容易系列之(4)——考新郎递推求解1402 Bitset 简单题1403 Picture 简单模拟题1404 Switch Game 找规律1405 An easy problem 简单模拟题1406 A + B Again 简单题1407 The sum problem 简单数学题1408 龟兔赛跑动态规划1409 Snooker 简单数学题1410 Subset sequence 简单题1411 汉诺塔III 递推求解1412 "红色病毒"问题递推求解1413 小兔的棋盘递推求解1414 RPG的错排错排+排列组合1415 无限的路简单题1416 夹角有多大数学题1417 汉诺塔IV 递推求解1418 复习时间简单题1419 选课时间暴力求解1420 手机短号字符串处理1421 找单词母函数1422 简易版之最短距离数学题1423 数塔动态规划1424 核反应堆简单题1425 A1 = ? 公式推导1426 剪花布条字符串处理1427 不要62 数学题1428 空心三角形字符串处理1429 小明A+B 简单题1430 Sky数进制转换1431 整除的尾数简单题1432 分拆素数和数论1433 正整数解数学题1434 挂盐水模拟题1435 {A} + {B} 简单题1436 小数A+B 高精度计算1437 Zigzag 简单题1438 螺旋形简单题1439 行李寄存简单题1440 判断多边形凹凸计算几何1441 The centre of polygon 计算几何1442 最小正整数简单题1443 Elevator Stopping Plan 二分+贪心法1444 TOYS 计算几何1445 The Doors 计算几何1446 Polygon And Segment 计算几何1447 Fence 计算几何1448 两圆相交面积计算几何1449 Area of Circles 计算几何1450 Pipe 计算几何1451 zero sum 搜索:DFS1452 C语言实验题——Hello World 水题1453 C语言实验题——数日子水题1454 C语言实验题——三个数排序水题1455 C语言实验题——数字串求和水题1456 C语言实验题——拍皮球水题1457 C语言实验题——求一个3*3矩阵对角线元素之和水题1458 C语言实验题——数组逆序水题1459 C实验题——求最大值水题1460 C实验题——求绝对值最大值水题1461 C语言实验题——求平均值水题1462 C语言实验题——打印直角三角形水题1463 C语言实验题——相加和最大值水题1464 C语言实验题——简单编码水题1465 C语言实验题——某年某月的天数水题1466 C语言实验题——各位数字之和排序水题1467 C语言实验题——两个数最大水题1468 C语言实验题——求级数值水题1469 Pipe II 计算几何1470 Transmitters 计算几何1471 Wall 计算几何1472 C语言实验题——逆置正整数水题1473 C语言实验题——找中间数水题1474 C语言实验题——整数位水题1475 C语言实验题——一元二次方程II 水题1476 C语言实验题——圆周率水题1477 C语言实验题——余弦水题1478 C语言实验题——打印金字塔水题1479 C语言实验题——排序水题1480 C语言实验题——约瑟夫问题水题1481 C语言实验题——鞍点水题1482 C语言实验题——计算表达式水题1483 C语言实验题——汉诺塔水题1484 C语言实验题——字符串排序水题1485 C语言实验题——整除水题1486 Solitaire 搜索:(双向)BFS1487 Abbreviation 水题1488 C语言实验题——买糖果水题1489 C语言实验题——字符编码水题1490 C语言实验题——合法的C标识符水题1491 C语言实验题——三角形面积水题1492 C语言实验题——大小写转换水题1493 C语言实验题——圆柱体计算水题1494 C语言实验题——温度转换水题1495 C语言实验题——统计字串水题1496 C语言实验题——字符过滤水题1497 Coin Change 暴力求解1498 Beautiful Meadow 搜索题1499 C语言实验题——鸡兔同笼水题1500 Coins of Luck 数学题:数学期望1501 Friends 搜索:DFS1502 Find All M^N Please 数学题1503 Incredible Cows 搜索:二分+DFS1504 计算直线的交点数递推求解1505 Number Game 动态规划1506 Sort ZOJ7 字符串处理1507 Find 7 Faster Than John Von Neumann 高精度计算1508 免费馅饼动态规划1509 Worm 动态规划1510 Common Subsequence 动态规划1511 搬寝室动态规划1512 Daydream 字符串处理1513 Ballroom Lights1514 Drop the Triples1515 Finding Seats1516 He is offside!1517 Justice League1518 星星点点搜索1519 逆波兰表达式表达式求解:栈的应用1520 十六进制高精度计算1521 Palindromic sequence1522 Hotel 模拟题1523 Intersecting Lines 计算几何1524 Heap Construction 最短路径1525 Pizza Anyone?1526 Adam's Genes1527 Risk1528 Just the Facts 数论1529 Horse Shoe Scoring 计算几何1530 哥德巴赫猜想数论1531 爱的伟大意义简单题1532 校门外的树模拟题1533 最多约数问题数论1534 Quicksum 数学题1535 找规律填数字数学题1536 Accepted Necklace 搜索:DFS1537 除法表达式数论1538 A Walk Through the Forest 图论:最短路径1539 Accurately Say "CocaCola"! 简单题1540 Build The Electric System 图论:最小生成树1541 Colorful Rainbows 计算几何1542 Easy Task 数学题1543 Faster, Higher, Stronger 简单题1544 Give Me the Number 模拟题1545 Hurdles of 110m 动态规划1546 Just Pour the Water 矩阵计算1547 Kinds of Fuwas 穷举法1548 复数运算简单题1549 元素个数排序简单题1550 Fiber Communications1551 Power Hungry Cows 搜索:BFS1552 Cow Cycling 动态规划1553 Rebuilding Roads 树型DP1554 Triangular Pastures 动态规划1555 Chores 动态规划1556 Extra Krunch1557 BUY LOW, BUY LOWER 动态规划1558 Hypnotic Milk Improvement1559 Happy Cows1560 Unary Cow Counting1561 Dairy Route1562 Calf Numbers1563 Hide and Seek1564 Mountain Majesties1565 Secret Milk Pipes1566 Circus Tickets1567 Life Cycle1568 Wiggle Numbers1569 Superwords1570 Cow Brainiacs1571 Pasture Fences1572 New Years Party1573 Strolling Cows1574 Grazing Sets1575 Factorial Power1576 Friday the Thirteenth1577 Beef McNuggets1578 Calf Flac1579 Light Bulbs1580 Cow Math 图论1581 Cow Imposters 动态规划1582 Traffic Lights 递推求解1583 Farm Tour 图论:最短路径1584 Vertical Histogram 简单题1585 Cowties 动态规划1586 Travel Games 搜索:DFS1587 Best Cow Fences 二分法1588 Cornfields RMQ问题1589 Six Degrees of Cowvin Bacon 简单题1590 Herd Sums 简单题1591 Message Decoding 简单题1592 Mountain Walking 二分+flood fill1593 Millenium Leapcow 动态规划1594 Optimal Milking 最大流+二分法1595 Bale Figures 模拟+二分法1596 Jumping Cows 动态规划1597 Lost Cows SBT树1598 Bovine Math Geniuses 简单题1599 Dividing the Path 动态规划1600 Fence Obstacle Course 动态规划1601 Cow Ski Area 图论:flood fill1602 Cleaning Shifts 贪心法1603 Bad Cowtractors 最大生成树1604 Tree Cutting 树状动态规划1605 Navigation Nightmare 并查集1606 Cow Marathon 树状动态规划1607 Distance Queries LCA,tarjan算法1608 Distance Statistics 楼天成大牛“男人八题”中的一道1609 Moo University - Team Tryouts 排序+穷举法1610 Moo University - Emergency Pizza Order1611 Moo University - Financial Aid 最大堆、最小堆1612 Cube Stacking 并查集1613 The Cow Lineup 穷举法1614 MooFest 线段树1615 Turning in Homework 动态规划1616 Alignment of the Planets1617 Finding Bovine Roots1618 Cow Bowling1619 Cow Patterns 字符串匹配的扩展1620 Barn Expansion 二分查找1621 Layout 差分约束系统1622 Knights of Ni 搜索:BFS1623 Cleaning Shifts DP+Heap1624 Scales 搜索+剪枝1625 Secret Milking Machine 二分+网络流1626 Aggressive cows 二分法1627 Rigging the Bovine Election 穷举法1628 Feed Accounting 简单模拟题1629 Muddy Fields 穷举法1630 The Wedding Juicer 堆+flood fill1631 Naptime 动态规划1632 Sumsets 动态规划1633 Moo Volume 简单题1634 Ombrophobic Bovines Floyd-Warshall 1635 Space Elevator 动态规划1636 Yogurt factory 动态规划1637 Checking an Alibi 最短路径1638 Out of Hay1639 Satellite Photographs 搜索:BFS or DFS 1640 Asteroids 最大网络流1641 Grazing on the Run 动态规划1642 Walk the Talk 动态规划1643 City Skyline 栈的应用1644 Cow Acrobats 贪心法1645 Ant Counting 动态规划1646 Hopscotch 搜索:DFS1647 Securing the Barn 穷举法1648 Bovine Birthday 递推求解1649 Max Factor 简单题1650 Flying Right1651 Close Encounter1652 Allowance1653 Lazy Cows1654 Expedition1655 Around the world1656 Landscaping1657 Waves1658 Navigating the City1659 Disease Management1660 Muddy roads1661 Wormholes 最短路径1662 The Fewest Coins 动态规划1663 Milk Patterns 二分法or后缀树1664 Cow Picnic 搜索:BFS or DFS1665 Cow Roller Coaster 动态规划1666 River Hopscotch 二分法+贪心1667 The Moronic Cowmpouter 进制转换1668 DNA Assembly 穷举法1669 Cow Phrasebook 二分法1670 Cellphones 穷举法1671 Steady Cow Assignment 网络流1672 Treats for the Cows 动态规划1673 Backward Digit Sums 穷举法1674 Stump Removal 简单题1675 Finicky Grazers 动态规划1676 The Water Bowls 枚举二进制位1677 Redundant Paths 图论1678 Roping the Field 动态规划1679 Corral the Cows 二分法1680 The Cow Prom 图论1681 Dollar Dayz 动态规划1682 The Grove 最短路径1683 Fence Repair Huffman编码1684 Corn Fields 状态压缩DP1685 Roadblocks 图论:最短路径1686 Bad Hair Day 搜索1687 Big Square 穷举法1688 Round Numbers 枚举二进制位1689 Building A New Barn1690 Cow Sorting 置换群1691 Lilypad Pond 最短路径1692 The Cow Lexicon 动态规划1693 Silver Cow Party 最短路径1694 Problem Solving 动态规划1695 Cow School1696 Protecting the Flowers 贪心法1697 Tallest Cow 区间统计1698 Balanced Lineup RMQ问题1699 Gold Balanced Lineup RMQ问题1700 Ranking the Cows 搜索:DFS1701 Face The Right Way 穷举法1702 Cow Traffic 动态规划1703 Monthly Expense 贪心法1704 Cheapest Palindrome 动态规划1705 Dining 贪心+网络流1706 City Horizon 离散化+ 扫描1707 Catch That Cow 最短路径1708 Fliptile 枚举+位压缩1709 2-Dimensional Rubik's Cube 搜索:BFS 1710 Ball 计算几何1711 3D Camera 三维计算几何1712 Cipher 模拟题1713 Five in a Row 简单题1714 Pinhole Imaging 简单计算几何1715 URL 模拟题1716 Battle of Submarines 集合DP1717 WOJ 动态规划1718 钥匙计数之二递推求解1719 BrokenLED 模拟题1722 A+B again and again! 模拟题1723 Just calculate it! 数论1724 Guess how much I love you? 简单题1725 NBA Finals1726 Find Out an “E”1727 Judging ACM/ICPC1728 Cryptography of Alex1729 Rings of square grid1730 Fermat's Theorem1731 Cup 二分法1732 Find the Path DP+二分法1733 Five in a Row, Again 动态规划1734 Minimum Heap 递推求解1735 Name PK 模拟题1736 Pendant 动态规划1737 Radar 计算几何+搜索1738 Ring 多串模式匹配1739 Run 计算几何1740 Toxophily 简单题1741 通讯录编排简单题1742 超缘分ACM队伍简单题1743 集合运算简单题1744 矩阵计算简单题1745 Arbitrage 动态规划1746 The Tower of Babylon 动态规划1747 Binomial Showdown 组合数学1748 Dungeon Master 搜索:BFS1749 Equation Solver 表达式求值应用1750 Frogger 最短路径1751 Globetrotter 计算几何1752 Tree Recovery 数据结构:二叉树1753 Artificial Intelligence?1754 The Settlers of Catan 搜索1755 France '98 概率问题1756 Goldbach's Conjecture 数论1757 Heavy Cargo 最小生成树1758 Quadtree1759 From Dusk till Dawn or: Vladimir the Vampire 最短路径1760 Euro Cup 20001761 Quadtree II or: Florida Jones strikes back1762 HTML 简单题1763 Paths on a Grid 组合数学:T路问题1764 Balanced Food 动态规划1765 California Jones and the Gate to Freedom 组合数学1766 Diplomatic License 简单计算几何题1767 Polygon Programming with Ease 数学题1768 Hall of Fountains 搜索:BFS or DP1769 The Bottom of a Graph 图论:强连通分量1770 Edge1771 Fold1772 Largest Rectangle in a Histogram 动态规划1773 Boolean Logic1774 Code1775 In Danger 模拟题1776 Fractran1777 Huffman's Greed1778 Bullshit Bingo 字符串处理1779 A Song contest1780 Message1781 The skatepark's new ramps1782 Road1783 Warfare1784 Blackjack1785 Robintron1786 Diamond Dealer 计算几何:凸包1787 Best Compression Ever1788 Code Theft1789 Dinner1790 Event Planning1791 Getting Gold1792 Introspective Caching1793 Just A Few More Triangles!1794 Knights of the Round Table 图论:无向图的块判断奇圈1795 The Cow Doctor 穷举法1796 Wild West 线段树1797 Find the Clones1798 The Warehouse1799 Widget Factory 数论:同余方程组1800 Martian Mining 动态规划3301 字符串;AC自动机,动态规划;状态压缩3302 计算几何3303 数学;代数运算;高斯消元3304 图论;强连通分量;2-SAT3305 动态规划;凸单调性优化3306 枚举3307 贪心3308 数学;代数运算3309 最短路;佛洛伊德3310 动态规划3311 贪心3312 计数问题;递推,数状数组,二分查找3313 数论;欧拉定理,快速幂取模3314 计数问题,数状数组3315 博弈;Surreal数;Farey数列;3316 计数问题;递推,高精度3317 计数问题;容斥原理3318 递推;矩阵乘法3319 数学;概率3320 背包3321 动态规划3322 字符串;AC自动机3323 动态规划3324 博弈3325 搜索3326 贪心3327 最短路3328 数据结构(实现一种数据结构,支持要求的操作),数状数组3329 图论;二分图最大权匹配3330 数学;数论3331 递推;矩阵乘法3332 数学;数论,二分查找3333 计算几何3334 动态规划3335 字符串,后缀数组或拉宾卡普;动态规划3336 数据结构;并查集3337 计数问题,递推3338 二分查找,贪心3339 数学3340 计算几何;凸包,图论;佛洛伊德;最小环3341 动态规划3342 广搜3343 动态规划3344 计算几何3345 二分图最大匹配3346 树型DP3347 动态规划3348 数学;数论;进制3349 计数问题3350 贪心3351 数学;数论;进制3352 动态规划,数论,组合数学3353 数学;数论3354 计数;递推3355 图论;佛洛伊德3356 博弈3357 动态规划3358 数据结构;线段树,数状数组3359 计算几何,动态规划3360 博弈;SG函数3361 图论;最近公共祖先3362 图论;强连通分量;2-SAT 3363 计算几何3364 字符串;AC自动机,动态规划3365 搜索,舞蹈链3366 数学;数论3367 数学;代数运算;高斯消元3368 动态规划3369 计数问题;递推3370 网络流(错题)3371 树型DP3372 数学;高精度3373 数学;3374 RMQ3376 数学;进制3377 字符串;后缀数组3378 动态规划3379 计算几何3380 线段树3381 图论;欧拉路3382 简单题3383 字符串;AC自动机3384 广搜3385 计算几何,矩阵3386 语言处理3387 动态规划;状态压缩3388 图论;全局最小割3389 简单题3390 广搜3391 数学;Pell方程3392 背包3393 计算几何3394 广搜3395 搜索;迭代加深3396 数学;计数问题3397 数学;解方程3398 分析3399 模拟3400 数学;计数问题,数论6 热度。

杭电ACM试题详细分类,杭电oj详细分类,hdu详细分类,详细,ACM

杭电ACM试题详细分类,杭电oj详细分类,hdu详细分类,详细,ACM
数论
1164 1211 1215 1222 1286 1299
计算几何
1086 1115 1147
贪心
1009 1052 1055 1232 1272
线段树,离散化
1199 1255
图论 最短路相关的问题
1142 1162 1217 1301
二分图问题
1054 1068 1150 1151 1281
杭电ACM试题分类 枚举
1002 1004 1013 1015 1017 1020 1022 1029 1031 1033 1034 1035 1036 1037 1039 1042 1047 1048 1049 1050 1057 1062 1063 1064 1070 1073 1075 1082 1083 1084 1088 1106 1107 1113 1117 1119 1128 1129 1144 1148 1157 1161 1170 1172 1177 1197 1200 1201 1202 1205 1209 1212(大数取模) 1216(链表)1218 1219 1225 1228 1229 1230 1234 1235 1236 1237 1239 1250 1256 1259 1262 1263 1265 1266 1276 1279 1282 1283 1287 1296 1302 1303 1304 1305 1306 1309 1311 1314
2549、2550、2551、2552、2555、2560、2561、2562、2566、2567、 2568、2700、2710、
DP:1003、10240、1029、1069、1074、1087、1114、1159、1160、
1171、1176、1203、1231、1257、1260、1284、1421、1789、1978、 2059、2084、2159、2191、2544、2571、2602、2709、

整理出ACM所有题目及答案

整理出ACM所有题目及答案

1111111杭电:1000 A + B Problem (4)1001 Sum Problem (5)1002 A + B Problem II (6)1005 Number Sequence (8)1008 Elevator (9)1009 FatMouse' Trade (11)1021 Fibonacci Again (13)1089 A+B for Input-Output Practice (I) (14)1090 A+B for Input-Output Practice (II) (15)1091 A+B for Input-Output Practice (III) (16)1092 A+B for Input-Output Practice (IV) (17)1093 A+B for Input-Output Practice (V) (18)1094 A+B for Input-Output Practice (VI) (20)1095 A+B for Input-Output Practice (VII) (21)1096 A+B for Input-Output Practice (VIII) (22)1176 免费馅饼 (23)1204 糖果大战 (25)1213 How Many Tables (26)2000 ASCII码排序 (32)2001 计算两点间的距离 (34)2002 计算球体积 (35)2003 求绝对值 (36)2004 成绩转换 (37)2005 第几天? (38)2006 求奇数的乘积 (40)2007 平方和与立方和 (41)2008 数值统计 (42)2009 求数列的和 (43)2010 水仙花数 (44)2011 多项式求和 (46)2012 素数判定 (47)2014 青年歌手大奖赛_评委会打分 (49)2015 偶数求和 (50)2016 数据的交换输出 (52)2017 字符串统计 (54)2019 数列有序! (55)2020 绝对值排序 (56)2021 发工资咯:) (58)2033 人见人爱A+B (59)2037 今年暑假不AC (61)2039 三角形 (63)2040 亲和数 (64)2045 不容易系列之(3)—— LELE的RPG难题 (65)2049 不容易系列之(4)——考新郎 (66)2056 Rectangles (68)2073 无限的路 (69)2084 数塔 (71)2201 熊猫阿波的故事 (72)2212 DFS (73)2304 Electrical Outlets (74)2309 ICPC Score Totalizer Software (75)2317 Nasty Hacks (77)2401 Baskets of Gold Coins (78)2500 做一个正气的杭电人 (79)2501 Tiling_easy version (80)2502 月之数 (81)2503 a/b + c/d (82)2504 又见GCD (83)2519 新生晚会 (84)2520 我是菜鸟,我怕谁 (85)2521 反素数 (86)2522 A simple problem (88)2523 SORT AGAIN (89)2524 矩形A + B (90)2535 Vote (91)2537 8球胜负 (93)2539 点球大战 (95)2547 无剑无我 (98)2548 两军交锋 (99)2549 壮志难酬 (100)2550 百步穿杨 (101)2551 竹青遍野 (103)2552 三足鼎立 (104)2553 N皇后问题 (105)2554 N对数的排列问题 (106)2555 人人都能参加第30届校田径运动会了 (107)2560 Buildings (110)2561 第二小整数 (112)2562 奇偶位互换 (113)2563 统计问题 (114)2564 词组缩写 (115)2565 放大的X (117)2566 统计硬币 (118)2567 寻梦 (119)2568 前进 (121)2569 彼岸 (123)2700 Parity (124)2577 How to Type (126)北京大学:1035 Spell checker (129)1061 青蛙的约会 (133)1142 Smith Numbers (136)1200 Crazy Search (139)1811 Prime Test (141)2262 Goldbach's Conjecture (146)2407 Relatives (150)2447 RSA (152)2503 Babelfish (156)2513 Colored Sticks (159)ACM算法:kurXX最小生成树 (163)Prim (164)堆实现最短路 (166)最短路DIJ普通版 (167)floyd (168)BELL_MAN (168)拓扑排序 (169)DFS强连通分支 (170)最大匹配 (172)还有两个最大匹配模板 (173)最大权匹配,KM算法 (175)两种欧拉路 (177)无向图: (177)有向图: (178)【最大流】Edmonds Karp (178)dinic (179)【最小费用最大流】Edmonds Karp对偶算法 (181)ACM题目:【题目】排球队员站位问题 (182)【题目】把自然数N分解为若干个自然数之和。

杭电acm部分题目及答案答案

杭电acm部分题目及答案答案

自己刷的题这是我在杭电做题的记录,希望我的分享对你有帮助!!!1001 Sum Problem***********************************************************1 1089 A+B for Input-Output Practice (I)********************************21090 A+B for Input-Output Practice (II)********************************51091A+B for Input-Output Practice (III)****************************************7 1092A+B for Input-Output Practice (IV)********************************81093 A+B for Input-Output Practice (V)********************************101094 A+B for Input-Output Practice (VI)***************************************12 1095A+B for Input-Output Practice (VII)*******************************131096 A+B for Input-Output Practice (VIII)******************************15How to Type***************************************************************161001 Sum ProblemProblem DescriptionHey, welcome to HDOJ(Hangzhou Dianzi University Online Judge).In this problem, your task is to calculate SUM(n) = 1 + 2 + 3 + ... + n.InputThe input will consist of a series of integers n, one integer per line.OutputFor each case, output SUM(n) in one line, followed by a blank line. You may assume the result will be in the range of 32-bit signed integer.Sample Input1100Sample Output15050AuthorDOOM III解答:#include<stdio.h>main(){int n,i,sum;sum=0;while((scanf("%d",&n)!=-1)){sum=0;for(i=0;i<=n;i++)sum+=i;printf("%d\n\n",sum);}}1089 A+B for Input-Output Practice(I)Problem DescriptionYour task is to Calculate a + b.Too easy?! Of course! I specially designed the problem for acm beginners.You must have found that some problems have the same titles with this one, yes, all these problems were designed for the same aim.InputThe input will consist of a series of pairs of integers a and b, separated by a space, one pair of integers per line.OutputFor each pair of input integers a and b you should output the sum of a and b in one line, and with one line of output for each line in input.Sample Input1 510 20Sample Output630AuthorlcyRecommendJGShining解答:#include<stdio.h>main(){int a,b;while(scanf("%d%d",&a,&b)!=EOF)printf("%d\n",a+b);}1090 A+B for Input-Output Practice(II)Problem DescriptionYour task is to Calculate a + b.InputInput contains an integer N in the first line, and then N lines follow. Each line consists of a pair of integers a and b, separated by a space, one pair of integers per line.OutputFor each pair of input integers a and b you should output the sum of a and b in one line, and with one line of output for each line in input.Sample Input21 510 20Sample Output630AuthorlcyRecommendJGShining解答:#include<stdio.h>#define M 1000void main(){int a ,b,n,j[M],i;//printf("please input n:\n"); scanf("%d",&n);for(i=0;i<n;i++){scanf("%d%d",&a,&b);//printf("%d %d",a,b);j[i]=a+b;}i=0;while(i<n){printf("%d",j[i]);i++;printf("\n");}}1091A+B for Input-Output Practice(III)Problem DescriptionYour task is to Calculate a + b.InputInput contains multiple test cases. Each test case contains a pair of integers a and b, one pair of integers per line. A test case containing 0 0 terminates the input and this test case is not to be processed.OutputFor each pair of input integers a and b you should output the sum of a and b in one line, and with one line of output for each line in input.Sample Input1 510 200 0Sample Output630AuthorlcyRecommendJGShining解答:#include<stdio.h>main(){int a,b;scanf("%d %d",&a,&b);while(!(a==0&&b==0)){printf("%d\n",a+b);scanf("%d %d",&a,&b);}}1092A+B for Input-Output Practice(IV)Problem DescriptionYour task is to Calculate the sum of some integers.InputInput contains multiple test cases. Each test case contains a integer N, and then N integers followin the same line. A test case starting with 0 terminates the input and this test case is not to be processed.OutputFor each group of input integers you should output their sum in one line, and with one line of output for each line in input.Sample Input4 1 2 3 45 1 2 3 4 5Sample Output1015AuthorlcyRecommendJGShining解答:#include <stdio.h>int main(){int n,sum,i,t;while(scanf("%d",&n)!=EOF&&n!=0) {sum=0;for(i=0;i<n;i++){scanf("%d",&t);sum=sum+t;}printf("%d\n",sum);}}1093 A+B for Input-Output Practice(V)Problem DescriptionYour task is to calculate the sum of some integers.InputInput contains an integer N in the first line, and then N lines follow. Each line starts with a integer M, and then M integers follow in the same line.OutputFor each group of input integers you should output their sum in one line, and with one line of output for each line in input.Sample Input24 1 2 3 45 1 2 3 4 5Sample Output1015Authorlcy解答:#include<stdio.h>main(){int n,a,b,i,j,sum;sum=0;while(scanf("%d\n",&n)!=-1) {for(i=0;i<n;i++){scanf("%d",&b);for(j=0;j<b;j++){scanf("%d",&a);sum+=a;}printf("%d\n",sum); sum=0;}}}1094 A+B for Input-Output Practice (VI) Problem DescriptionYour task is to calculate the sum of some integers.InputInput contains multiple test cases, and one case one line. Each case starts with an integer N, and then N integers follow in the same line.OutputFor each test case you should output the sum of N integers in one line, and with one line of output for each line in input.Sample Input4 1 2 3 45 1 2 3 4 5Sample Output1015AuthorlcyRecommendJGShining解答:#include<stdio.h>main(){int n,a,b,i,j,sum;sum=0;while(scanf("%d\n",&n)!=-1){for(j=0;j<n;j++){scanf("%d",&a);sum+=a;}printf("%d\n",sum);sum=0;}}[ Copy to Clipboard ][ Save to File]1095A+B for Input-Output Practice (VII) Problem DescriptionYour task is to Calculate a + b.InputThe input will consist of a series of pairs of integers a and b, separated by a space, one pair of integers per line. OutputFor each pair of input integers a and b you should output the sum of a and b, and followed by a blank line.Sample Input1 510 20Sample Output630AuthorlcyRecommendJGShining解答:#include<stdio.h>main(){int a,b;while(scanf("%d%d",&a,&b)!=EOF)printf("%d\n\n",a+b);}1096 A+B for Input-Output Practice (VIII) Problem DescriptionYour task is to calculate the sum of some integers.InputInput contains an integer N in the first line, and then N lines follow. Each line starts with a integer M, and then M integers follow in the same line.OutputFor each group of input integers you should output their sum in one line, and you must note that there is a blank line between outputs.Sample Input34 1 2 3 45 1 2 3 4 53 1 2 3Sample Output10156AuthorlcyRecommendJGShining解答:int main(){int a,b,i,j,l[1000],k;scanf("%d",&i);getchar();for(j=1;j<=i;j++)l[j]=0;for(j=1;j<=i;j++){scanf("%d",&a);getchar();for(k=1;k<=a;k++){scanf("%d",&b);getchar();l[j]+=b;}}for(j=1;j<=i-1;j++)printf("%d\n\n",l[j]);printf("%d\n",l[i]);}How to TypeProblem DescriptionPirates have finished developing the typing software. He called Cathy to test his typing software. She is good at thinking. After testing for several days, she finds that if she types a string by some ways, she will type the key at least. But she has a bad habit that if the caps lock is on, she must turn off it, after she finishes typing. Now she wants to know the smallest times of typing the key to finish typing a string.InputThe first line is an integer t (t<=100), which is the number of test case in the input file. For each test case, there is only one string which consists of lowercase letter and upper case letter. The length of the string is at most 100.OutputFor each test case, you must output the smallest times of typing the key to finish typing this string.Sample Input 3Pirates HDUacm HDUACM Sample Output 888#include <stdio.h>#include <string.h>#define MAX 200int arr[MAX][4];char str[MAX];int letter(char ch){if(ch>='A'&&ch<='Z') return 1;return 0;}void proc(){int i;int tmp,min;int len=strlen(str);for(i=0;i<len;i++){if(i==0){if(letter(str[i])) { arr[i][1]=2; arr[i][2]=2; }else { arr[i][0]=1; arr[i][3]=3; }}else{if(letter(str[i])==letter(str[i-1])){if(arr[i-1][0]){ arr[i][0]=arr[i-1][0]+1;arr[i][3]=arr[i-1][0]+3;}if(arr[i-1][1]) { arr[i][1]=arr[i-1][1]+2; arr[i][2]=arr[i-1][1]+2;}if(arr[i-1][2]){if(arr[i][0]>arr[i-1][2]+1||!arr[i][0]) arr[i][0]=arr[i-1][2]+1;if(arr[i][3]>arr[i-1][2]+3||!arr[i][3]) arr[i][3]=arr[i-1][2]+3;}if(arr[i-1][3]){if(arr[i][1]>arr[i-1][3]+2||!arr[i][1]) arr[i][1]=arr[i-1][3]+2;if(arr[i][2]>arr[i-1][3]+2||!arr[i][2]) arr[i][2]=arr[i-1][3]+2;}}else{if(arr[i-1][0]){ arr[i][1]=arr[i-1][0]+2; arr[i][2]=arr[i-1][0]+2;}if(arr[i-1][1]){ arr[i][0]=arr[i-1][1]+1; arr[i][3]=arr[i-1][1]+3;}if(arr[i-1][2]){if(arr[i][1]>arr[i-1][2]+2||!arr[i][1]) arr[i][1]=arr[i-1][2]+2;if(arr[i][2]>arr[i-1][2]+2||!arr[i][2]) arr[i][2]=arr[i-1][2]+2;}if(arr[i-1][3]){if(arr[i][0]>arr[i-1][3]+1||!arr[i][0]) arr[i][0]=arr[i-1][3]+1;if(arr[i][3]>arr[i-1][3]+3||!arr[i][3]) arr[i][3]=arr[i-1][3]+3;}}}}min=3*MAX;if(letter(str[len-1])){if(arr[len-1][0]){ tmp=arr[len-1][0]+1; if(tmp<min) min=tmp;}if(arr[len-1][1]){ tmp=arr[len-1][1]; if(tmp<min) min=tmp; }if(arr[len-1][2]){ tmp=arr[len-1][2]+1; if(tmp<min) min=tmp;}if(arr[len-1][3]){ tmp=arr[len-1][3]; if(tmp<min) min=tmp; } }else{if(arr[len-1][0]) { tmp=arr[len-1][0]; if(tmp<min) min=tmp; }if(arr[len-1][1]) { tmp=arr[len-1][1]+1; if(tmp<min) min=tmp;}if(arr[len-1][2]) { tmp=arr[len-1][2]; if(tmp<min) min=tmp; }if(arr[len-1][3]) { tmp=arr[len-1][3]+1; if(tmp<min) min=tmp;} }printf("%d\n",min);}//Caps Shift:0-00;1-01;2-10;3-11int main(){int num;scanf("%d",&num);while(num--){scanf("%s",str);memset(arr,0,strlen(str)*4*sizeof(int));proc();}return 0;}。

杭州电子科技大学acm答案

杭州电子科技大学acm答案

杭州电子科技大学acm答案杭电2000~A+B for Input-Output Practice (VIII)Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 5573 Accepted Submission(s): 2058Problem DescriptionYour task is to calculate the sum of some integers.InputInput contains an integer N in the first line, and then N lines follow. Each line starts with a integer M, and then M integers follow in the same line.OutputFor each group of input integers you should output their sum in one line, and you must note that there is a blank line between outputs.Sample Input34 1 2 3 45 1 2 3 4 53 1 2 3Sample Output10156正确代码:#includeusing namespace std;int main(){int m,n,i,j,s,k;cin>>n;int c[1000];for(i=0;i<n;i++)< p="">{cin>>m;s=0;for(j=1;j<=m;j++){cin>>k;s+=k;}if(i==n-1){cout<<s<<endl;< p="">}else{cout<<s<<endl<<endl;< p="">}}return 0;}A+B ComingTime Limit: 1000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 902 Accepted Submission(s): 456Problem DescriptionMany classmates said to me that A+B is must needs. If youcan’t AC this problem, you would invite me for night meal. ^_^ InputInput may contain multiple test cases. Each case contains A and B in one line. A, B are hexadecimal number. Input terminates by EOF.OutputOutput A+B in decimal number in one line.Sample Input1 9A Ba bSample Output102121正确代码:#includeusing namespace std;int main(){int m,n,s;while(scanf("%x%x",&m,&n)!=EOF) //以十六进制输入{s=m+n;printf("%d\n",s); //以十进制输出,与上面}return 0;}此题的输入输出没有用cin>> 和cout<<,看到很多人说scanf和printf比较常用2001ASCII码排序Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) T otal Submission(s): 32853 Accepted Submission(s): 13545Problem Description输入三个字符后,按各字符的ASCII码从小到大的顺序输出这三个字符。

赛马网ACM试题(原杭电ojACM)java版答案(1000,10001,1002)

赛马网ACM试题(原杭电ojACM)java版答案(1000,10001,1002)

赛马⽹ACM试题(原杭电ojACM)java版答案(1000,10001,1002)赛马⽹ACM试题(原杭电OJ ACM试题)答案(java版)突然⼿痒,来做⼀下acm试题练练⼿,由于最近在学java,顺便练⼀下java编程。

但是对于ACM训练,c会更好,因为c的时间效率更⾼⼀些,这⽅⾯⽐java有优势。

其实调调⼩程序就像品茶⼀样也挺有意思的(怎么闻到⼀股屌丝⽓息)。

最近也在找⼯作阶段,对于新兴的在线⽐赛,在线程序测试略有感触,这是⼀个⼤趋势,也是互联⽹公司招聘的⼀个优势吧,不过诸多问题还有待改善,这⾥不详述。

对于计算机专业出⾝,编程是基础,想要进阶,就先积累点滴吧。

注意:提交的java代码的类名都必须为Main第1000题:A+B ProblemProblem DescriptionCalculateA + B.InputEach line will contain two integersA andB. Process to end of file.OutputFor each case, outputA +B in one line.Sample Input1 1Sample Output2题⽬解析:要求每⾏输⼊两个数,计算两数的和并输出,这⾥是要循环的输⼊,程序⾃动输出!代码:import java.util.Scanner;public class Main{public static void main(String[] args){Scanner in = new Scanner(System.in);while(in.hasNextInt()){int a = in.nextInt();int b = in.nextInt();System.out.println(a+b);}}}第1001题:Sum ProblemProblem DescriptionHey, welcome to HDOJ(Hangzhou Dianzi University Online Judge).In this problem, your task is to calculate SUM(n) = 1 + 2 + 3 + ... + n.InputThe input will consist of a series of integers n, one integer per line.OutputFor each case, output SUM(n) in one line, followed by a blank line. You may assume the result will be in the range of 32-bit signed integer. Sample Input1100Sample Output15050题⽬解析:输⼊⼀个数n,计算1+2+3+...+n的值。

杭电acm练习题100例(删减版)

杭电acm练习题100例(删减版)

杭电acm练习题100例(删减版)【程序1】题目:有1、2、3、4个数字,能组成多少个互不相同且无重复数字的三位数?都是多少?1.程序分析:可填在百位、十位、个位的数字都是1、2、3、4。

组成所有的排列后再去掉不满足条件的排列。

#include "stdio.h"#include "conio.h"main(){ int i,j,k;printf("\n");for(i=1;i<5;i++) /*以下为三重循环*/for(j=1;j<5;j++)for (k=1;k<5;k++){ if (i!=k&&i!=j&&j!=k) /*确保i、j、k三位互不相同*/printf("%d,%d,%d\n",i,j,k); }getch(); }==============================================================【程序2】题目:企业发放的奖金根据利润提成。

利润(I)低于或等于10万元时,奖金可提10%;利润高于10万元,低于20万元时,低于10万元的部分按10%提成,高于10万元的部分,可可提成7.5%;20万到40万之间时,高于20万元的部分,可提成5%;40万到60万之间时高于40万元的部分,可提成3%;60万到100万之间时,高于60万元的部分,可提成1.5%,高于100万元时,超过100万元的部分按1%提成,从键盘输入当月利润I,求应发放奖金总数?#include "stdio.h" #include "conio.h"main(){ long int i;int bonus1,bonus2,bonus4,bonus6,bonus10,bonus;scanf("%ld",&i);bonus1=100000*0. 1;bonus2=bonus1+100000*0.75;bonus4=bonus2+200000*0.5;bonus6=bonus4+200000*0.3;bonus10=bonus6+400000*0.15;if(i<=100000)bonus=i*0.1;else if(i<=200000)bonus=bonus1+(i-100000)*0.075;else if(i<=400000)bonus=bonus2+(i-200000)*0.05;else if(i<=600000)bonus=bonus4+(i-400000)*0.03;else if(i<=1000000)bonus=bonus6+(i-600000)*0.015;elsebonus=bonus10+(i-1000000)*0.01;printf("bonus=%d",bonus);getch(); }====================================== ========================【程序3】题目:一个整数,它加上100后是一个完全平方数,再加上168又是一个完全平方数,请问该数是多少?#include "math.h"#include "stdio.h"#include "conio.h"main(){ long int i,x,y,z;for (i=1;i<100000;i++){ x=sqrt(i+100); /*x为加上100后开方后的结果*/y=sqrt(i+268); /*y为再加上168后开方后的结果*/if(x*x==i+100&&y*y==i+268)printf("\n%ld\n",i); }getch(); }====================================== ========================【程序4】题目:输入某年某月某日,判断这一天是这一年的第几天?#include "stdio.h" #include "conio.h"main(){ int day,month,year,sum,leap;printf("\nplease input year,month,day\n");scanf("%d,%d,%d",&year,&month,&day);switch(month) /*先计算某月以前月份的总天数*/{ case 1:sum=0;break;case 2:sum=31;break;case 3:sum=59;break;case 4:sum=90;break;case 5:sum=120;break;case 6:sum=151;break;case 7:sum=181;break;case 8:sum=212;break;case 9:sum=243;break;case 10:sum=273;break;case 11:sum=304;break;case 12:sum=334;break;default:printf("data error");break; }sum=sum+day; /*再加上某天的天数*/if(year%400==0||(year%4==0&&year%100!=0)) /*判断是不是闰年*/leap=1;elseleap=0;if(leap==1&&month>2) /*如果是闰年且月份大于2,总天数应该加一天*/sum++;printf("It is the %dth day.",sum);getch(); }====================================== ======================== 【程序5】题目:输入三个整数x,y,z,请把这三个数由小到大输出。

杭州电子科技大学acm习题集锦

杭州电子科技大学acm习题集锦

目录1、数塔问题 (2)2、并查集类问题 (4)3、递推类问题 (9)4、动态规划系列 (10)5、概率类题型 (13)6、组合数学类题型 (15)7、贪心策略 (16)8、几何问题 (19)数塔类问题数塔Problem Description在讲述DP算法的时候,一个经典的例子就是数塔问题,它是这样描述的:有如下所示的数塔,要求从顶层走到底层,若每一步只能走到相邻的结点,则经过的结点的数字之和最大是多少?已经告诉你了,这是个DP的题目,你能AC吗?Input输入数据首先包括一个整数C,表示测试实例的个数,每个测试实例的第一行是一个整数N(1 <= N <= 100),表示数塔的高度,接下来用N行数字表示数塔,其中第i行有个i个整数,且所有的整数均在区间[0,99]内。

Output对于每个测试实例,输出可能得到的最大和,每个实例的输出占一行。

Sample Input1573 88 1 02 7 4 44 5 2 6 5Sample Output 30#include<stdio.h>#include<string.h>#define MAX 101int arr[MAX][MAX][2];void res(){int n; int i,j;memset(arr,0,MAX*MAX*sizeof(int));scanf("%d",&n);for(i=0;i<n;i++) //输入数塔for(j=0;j<=i;j++) { scanf("%d",&arr[i][j][0]); arr[i][j][1]=arr[i][j][0]; }for(i=n-2;i>=0;i--){for(j=0;j<=i;j++){if(arr[i+1][j][1]>arr[i+1][j+1][1]) arr[i][j][1]+=arr[i+1][j][1];else arr[i][j][1]+=arr[i+1][j+1][1];}}printf("%d\n",arr[0][0][1]);}int main(){int num;scanf("%d",&num);while(num--) { res(); }return 0;}免费馅饼Problem Description都说天上不会掉馅饼,但有一天gameboy正走在回家的小径上,忽然天上掉下大把大把的馅饼。

杭电ACM试题详细分类,杭电oj详细分类,hdu详细分类,详细,ACM.doc

杭电ACM试题详细分类,杭电oj详细分类,hdu详细分类,详细,ACM.doc

杭电ACM试题分类枚举1002 10041013 1015 1017 1020 1022 1029 1031 1033 1034 1035 1036 1037 10391042 10471048 1049 1050 1057 1062 1063 1064 1070 1073 1075 1082 1083 10841088 11061107 1113 1117 1119 1128 1129 1144 1148 1157 1161 1170 1172 117711971200 1201 1202 1205 1209 1212(大数取模)1216 (链表)1218 1219 12251228 12291230 1234 1235 1236 1237 1239 1250 1256 1259 1262 1263 1265 12661276 1279 1282 1283 1287 1296 1302 1303 1304 1305 1306 1309 1311 1314搜索,递归求解1010 1016 1026 1043(双广)1044 (BFS+DFS) 1045 1067 1072 1104 1175 1180 11951208 1226 1238 1240 1241 1242 1258 1271 1312 1317动态规划1003 1024 1025 1028 1051 1058 1059 1069 1074 1078 1080 1081 1085 1087 1114 1158 1159 1160 1171 1176 1181 1203 1224 1227 1231 1244 1248 1253 1254 1283 1300数学,递推,规律1005 1006 1012 1014 1018 1019 1021 1023 1027 1030 1032 1038 1041 1046 1059 1060 1061 1065 1066 1071(微积分)1097 1098 1099 1100 1108 1110 1112 1124 1130 1131 1132 1134 1141 1143 1152 1155(物理题)1163 1165 1178 1194 1196(lowbit) 1210 1214 1200 1221 1223 1249 1261 1267 1273 1290 1291 1292 1294 1297 1313 1316数论1164 1211 1215 1222 1286 1299计算几何1086 1115 1147贪心1009 1052 1055 1257 并查集11981213 1232 1272线段树,离散化11991255图论最短路相关的问题1142 1162 1217 1301二分图问题1054 1068 1150 1151 1281其他1053 (huffman) 1102(MST) 1116 (欧拉回路)1233(MST) 1269 (强连通)数据结构1103 (堆+模拟)1166 (数状树组)1247 1251 1285 (Topol) 1298以下是详细介绍1002简单的大数1003 DP经典问题,最大连续子段和1004简单题1005找规律(循环点)1007经典问题,最近点对问题,用分治1008简单题1010搜索题,剪枝很关1009贪心1012简单题1013简单题(有个小陷阱)1014简单题1015可以看作搜索题吧1016经典的搜索1017简单数学题1018简单数学题1019简单数学题1020简单的字符串处理找规律的数学题数据结构的题(栈的应用)特殊的数(Catalan Number)经典DP,最大M 子段和经典DP,最长递增子序列(要用NLogN的方法过)搜索数学题(或用STL)经典问题,整数拆分,用母函数做简单题(一般方法容易超时)简单题,可用模拟过简单题简单题模拟题Candy Sharing Game模拟题简单题简单题,不是一般的简单简单题字符串处理简单题,排序简单题,用大数大数经典搜索题,八数码问题稍微有点麻烦的搜索题搜索题,可用匹配做简单题简单的大数简单字符串处理简单题贪心经典贪心,也可以用DP贪心贪心,关于Huffman编码二分匹配二分匹配简单题模拟题经典问题,丑数,DP经典问题,可以用母函数或DP (不针对题目优化都会超时)数学题数学题简单字符串处理模拟大数简单题1065简单题1066数学题,找规律1068经典二分匹配1069经典DP1070简单题1071简单数学题1072搜索1073字符串处理1074 DP1075字典树1076简单题1078DP1079博弈(DP)1080DP 1081经典DP1082简单题1083二分匹配1084简单题1085母函数1086简单几何题1087简单DP1088字符串处理1089~1096 (练习输入输出的8个题目)1097简单数学题1098数学题,注意找规律1099数学HrH1500DP1501DP1502DP or记忆化1503DP1504模拟1505DP1506DP15072分匹配1508记忆化容易点1509模拟1510 DP1511搜索可以过1512左偏树1513DP1514DP1515DFS1516DP1517博奕搜索DP (不确定)树状DP 数学题稳定婚姻DP 博弈博弈Maxflow博弈2分匹配简单题最大团差分约束Maxflow入门题KM Or > 小费用流差分约束差分约束博弈模拟加置换群的理论CODE可以短些,其实没必要。

杭电oj入门题目列表

杭电oj入门题目列表

杭电oj⼊门题⽬列表[671原创,欢迎转载]以下题均为杭电acm⽹页的题号此次培训主要锻炼同学们的算法学习,更重要的是锻炼同学们的⾃学能⼒,对于我们学计算机的同学来说,⾃学能⼒是关键,如果你真的指望从⽼师那⾥学到什么的话。

(千万不能告诉⽼师)所以,这个真的很关键,⾸先是独⽴思考问题的能⼒,我对同学们的要求是,如果同学们遇到了问题,⾄少独⽴思考1⼩时以上,才可以从⽹上找答案或者问别⼈。

不要觉得这个要求苛刻,其实这是⼀个很好的⽅法,如果⼀遇到不会的难题就上⽹查或者问,虽然可能题⼀会做出来了,但是下次碰见还是不会,甚⾄根本就没有印象。

我经常调试程序3、4个⼩时以上,偶尔都会有10个⼩时的调试。

这对同学们⽇后的学习很有帮助。

第⼀阶段:开始⼊门吧!(15天,53题)⼀.输⼊输出练习(2天,10题)1000、1089—1096、1001⼆.简单操作:(2—4天,12题)2000—2011、2039三.英⽂题试⽔(3—4天,8题)1720、1062、2104、1064、2734、1170、1197、2629四.回归⽔题(4-6天,24题)2012—2030、2032、2040、2042、2054、2055(第⼀阶段⼤体结束之后,会由⼏位学长讲⼀些数据结构的知识,请同学们务必跟上进度!)第⼆阶段:我要学算法!(12天,31题)⼀.字符串我要会处理(2天,6题)2072、2081、2093、2091、1004、2057⼆.简单数学题(4天,12题)2031、2033、2070、2071、2075、2089、2090、2092、2096—2099三.要玩就玩汉诺塔(2天,5题)1995、1996、2064、2077、2175四.As easy as math(4天,8题)1108、2138、1713、1722、2136、2504、1717、1125第三阶段:acm⽆底洞啊!(10天,18题)⼀.初见dp(2—4天,4题)2062、1087、1203、1003⼆.迷宫之烟雾缭绕(2—4天,3题)1728、1010、1072三.数学题做不下去了。

ACM入门简单数学题

ACM入门简单数学题
对于每组数据,输出一行,包含一个"Yes"或者 "No"。
2019/9/3
28
请自己仔细分析...
哪位同学做个陈述?
2019/9/3
29
课后任务:
完成在线练习:
201309《ACM程序设计》作业(2)—— 刘春英 老师
特别提醒:
作业务必尽力完成(第一次的作 业尚未完成的,一定要补上~)
作业密码:helloworld
return 0;}Fra bibliotek2019/9/3
23
HDOJ_1005: Number Sequence
2019/9/3
24
Question:
暴力(Brute-Force) 能解决问题吗?
2019/9/3
25
题目分析:
对于这种题目,千万不能蛮干!实际上, 有经验的同学看到本题目的数据规模,很快就 能知道:这类题目有规律可循。
STD-O 56 5
STD-O ?6
TMP-O 55
TMP-O ??
2019/9/3
9
有什么问题呢?
享受今天的慢车旅程吧~~
2019/9/3
10
HDOJ_1008: Elevator
2019/9/3
11
题目评述:
这是2004浙江省赛最简单的一题,当时训练 水平相对较高的学校基本上10分钟之内解决该 题,这是一个没有算法的简单模拟题目。
参知政事范仲淹等人遭谗离职,欧阳修上书替他们分辩,被贬到滁州做了两年知州。到任以后,他内心抑郁,但还能发挥“宽简而不扰”的作风,取得了某些政绩。《醉翁亭记》就是在这个时期写就的。目标导学二:朗读文章,通文顺字1.初读文章,结合工具书梳理文章字词。2.朗读文章,划分文章节奏,标出节奏划分有疑难的语句。节奏划分示例

杭电题目acm答案

杭电题目acm答案

1001 Sum Problem ............................................. 错误!未定义书签。

1089 A+B for Input-Output Practice (I) ...................... 错误!未定义书签。

1090 A+B for Input-Output Practice (II) ..................... 错误!未定义书签。

1091 A+B for Input-Output Practice (III) .................... 错误!未定义书签。

1092 A+B for Input-Output Practice (IV) ...................... 错误!未定义书签。

1093 A+B for Input-Output Practice (V) ...................... 错误!未定义书签。

1094 A+B for Input-Output Practice (VI) ..................... 错误!未定义书签。

1095 A+B for Input-Output Practice (VII) ..................... 错误!未定义书签。

1096 A+B for Input-Output Practice (VIII) ................... 错误!未定义书签。

2000 ASCII码排序............................................ 错误!未定义书签。

2001计算两点间的距离........................................ 错误!未定义书签。

2002计算球体积.............................................. 错误!未定义书签。

杭电OJ:1089----1096(c++)(ACM入门第一步:所有的输入输出格式)

杭电OJ:1089----1096(c++)(ACM入门第一步:所有的输入输出格式)

杭电OJ:1089----1096(c++)(ACM⼊门第⼀步:所有的输⼊输出格式)1089:输⼊输出练习的A + B(I)问题描述您的任务是计算a + b。

太容易了?!当然!我专门为ACM初学者设计了这个问题。

您⼀定已经发现某些问题与此标题具有相同的名称,是的,所有这些问题都是出于相同的⽬的⽽设计的。

输⼊项输⼊将由⼀系列由空格隔开的整数对a和b组成,每⾏⼀对整数。

输出量对于每对输⼊整数a和b,应该在⼀⾏中输出a和b的总和,并且在输⼊中每⾏输出⼀⾏。

样本输⼊1 5 10 20样本输出6 30题解:#include<cstdio>#include<iostream>using namespace std;int main(){int a, b,sum;while(cin >> a >> b){sum = a+b;cout << sum << endl;}return 0;}1090:投⼊产出练习的A + B(II)问题描述您的任务是计算a + b。

输⼊项输⼊的第⼀⾏包含⼀个整数N,然后是N⾏。

每⾏由⼀对整数a和b组成,每对之间⽤空格隔开,每⾏⼀对整数。

输出量对于每对输⼊整数a和b,应该在⼀⾏中输出a和b的总和,并且在输⼊中每⾏输出⼀⾏。

样本输⼊2 1 5 10 20样本输出6 30题解:#include<cstdio>#include<iostream>using namespace std;int a,b,n,sum;cin >> n;while (n){cin >> a >> b;sum = a + b;cout << sum << endl;n--;}return 0;}1091:投⼊产出练习的A + B(III)问题描述您的任务是计算a + b。

(完整word版)杭电ACM试题答案

(完整word版)杭电ACM试题答案

【杭电ACM1000】A +B ProblemProblem DescriptionCalculate A + B.InputEach line will contain two integers A and B. Process to end of file.OutputFor each case, output A + B in one line.Sample Input1 1Sample Output2# include <stdio.h>int main(){int a, b;while(scanf("%d%d", &a, &b)!=EOF)printf("%d\n", a+b);return 0;}【杭电ACM1001】Sum ProblemProblem DescriptionHey, welcome to HDOJ(Hangzhou Dianzi University Online Judge). In this problem, your task is to calculate SUM(n) = 1 + 2 + 3 + ... + n.InputThe input will consist of a series of integers n, one integer per line.OutputFor each case, output SUM(n) in one line, followed by a blank line. You may assume the result will be in the range of 32-bit signed integer.Sample Input1 100Sample Output1 5050# include <stdio.h>int main(){int n, i, sum = 0;while(scanf("%d", &n)!=EOF){for(i=1; i<=n; ++i)sum = sum + i;printf("%d\n\n", sum);sum = 0;}return 0;}【杭电ACM1002】A +B Problem IIProblem DescriptionI have a very simple problem for you. Given two integers A and B, your job is to calculate the Sum of A + B.InputThe first line of the input contains an integer T(1<=T<=20) which means the number of test cases. Then T lines follow, each line consists of two positive integers, A and B. Notice that the integers are very large, that means you should not process them by using 32-bit integer. You may assume the length of each integer will not exceed 1000.OutputFor each test case, you should output two lines. The first line is "Case #:", # means the number of the test case. The second line is the an equation "A + B = Sum", Sum means the result of A + B. Note there are some spaces int the equation. Output a blank line between two test cases.Sample Input2 1 2 112233445566778899 998877665544332211Sample OutputCase 1: 1 + 2 = 3 Case 2: 112233445566778899 + 998877665544332211 = 1111111111111111110#include<stdio.h>#include<string.h>int shu(char a){return (a-'0');}int main(){char a[1000],b[1000];int num[1001];int n,i,j=1,al,bl,k,t;scanf("%d",&n);while(n--){getchar();if(j!=1)printf("\n");scanf("%s",a);al=strlen(a);scanf("%s",b);bl=strlen(b);k=(al>bl)?al:bl;for(i=0;i<=k;i++)num[i]=0;t=k;for(k;al>0&&bl>0;k--){num[k]+=shu(a[--al])+shu(b[--bl]);if(num[k]/10){num[k-1]++;num[k]%=10;}}while(al>0){num[k--]+=shu(a[--al]);if(num[k+1]/10){num[k]++;num[k+1]%=10;}}while(bl>0){num[k--]+=shu(b[--bl]);if(num[k+1]/10){num[k]++;num[k+1]%=10;}}printf("Case %d:\n",j++);printf("%s + %s = ",a,b);for(i=0;i<=t;i++){if(i==0&&num[i]==0)i++;printf("%d",num[i]);}printf("\n");}return 0;}。

浙江大学acm答案完整版

浙江大学acm答案完整版

浙江大学acm答案完整版求余运算给出S和M,求0*S%M,1*S%M,2*S%M......(M-1)*S%M能否组成一个集合包含0.1.。

M-1;(这个是原题意改造而来);算法:判断两个数是否互质;or 暴力解决其实暴力完全可以解决这个问题(⊙﹏⊙b),只是其中用数学方法更加高效,巧妙;证明如果S和M互质则满足题意:另G=gcd(S,M);则S=A*G,M=B*G;另X=K*S%M=K*S-T*M(T为整数,满足X属于0到M-1);X=K*A*G-T*B*G;因此取余后的整数一定是G的倍数,G只能取1才能满足条件;充分性的证明:(即当S与M互质,则0到M-1的S倍对M取余一定能遍历0到M-1)只需证明的是,该余数中两两之间互不相等;假设k*S和b*S对M取余相等(k和b∈[0,M),并且k和b不等);则k*S=q1*M+r=q2*M+r=b*S <==> (k-b)*S=M*(q1-q2);S与M互质,由上式子可得M|(k-b),与k和b∈[0,M),并且k和b不等矛盾;因此得证;另外,偶然看到一个很牛叉的辗转相除法;int gcd(int a,int b){while(b) b^=a^=b^=a%=b;return a;}此代码,很好很强大;把涉及位运算的交换的程序加入,便到得这段简洁高效的代码;注:A和B;经过A^=B^=A^=B,结果就得到A和B的交换//////////////////////////// 1000#includeint main(){int a,b,i,;scanf("%d",&a);for(i=1;i<=a;i++){ int sum=0;sum=sum+i;printf("%d\n",sum);}return 0;};1001;#include"stdio.h"int main(){unsigned _int64 n;unsigned _int64 temp;while(scanf("%I64u",&n)!=EOF) //是i 非L{temp=(1+n)*n/2;printf("%I64u\n\n",temp);}return 0;}//////////////////HDU ACM 1014 Uniform Generator 三月22nd, /doc/904868734.html,/showproblem.php?pid=1014这个题目是判断给定的步长和mod,判断所产生的随机数已经覆盖0~mod-1中所有的数,如果是,则说明所选的步长和mod是一个Good choice,否则为bad choice.需要懂得的基本内容为线性同余产生随机数,链接:/doc/904868734.html,/zh-cn/%E7%B7%9A%E6%80%A7%E5%90%8C%E9%A4%98%E6%96 %B9%E6%B3%95Problem DescriptionComputer simulations often require random numbers. One way to generate pseudo-random numbers is via a function of the formseed(x+1) = [seed(x) + STEP] % MODwhere '%' is the modulus operator.Such a function will generate pseudo-random numbers (seed) between 0 and MOD-1. One problem with functions of this form is that they will always generate the same pattern over and over. In order to minimize this effect, selecting the STEP and MOD values carefully can result in a uniform distribution of all values between (and including) 0 and MOD-1.For example, if STEP = 3 and MOD = 5, the function will generate the series of pseudo-random numbers 0, 3, 1, 4, 2 in a repeating cycle. In this example, all of the numbers between and including 0 and MOD-1 will be generated every MOD iterations of the function. Note that by the nature of the function to generate the same seed(x+1) every time seed(x) occurs means that if a function will generate all the numbers between 0 and MOD-1, it will generate pseudo-random numbers uniformly with every MOD iterations.If STEP = 15 and MOD = 20, the function generates the series0, 15, 10, 5 (or any other repeating series if the initial seed is other than 0). This is a poor selection of STEP and MOD because no initial seed will generate all of the numbers from 0 and MOD-1.Your program will determine if choices of STEP and MOD will generate a uniform distribution of pseudo-random numbers.InputEach line of input will contain a pair of integers for STEP and MOD in that order (1 <= STEP, MOD <= 100000).OutputFor each line of input, your program should print the STEP value right- justified in columns 1 through 10, the MOD value right-justified in columns 11 through 20 and either "Good Choice" or "Bad Choice" left-justified starting in column 25. The "Good Choice" message should be printed when the selection of STEP and MOD will generate all the numbers between and including 0 and MOD-1 when MOD numbers are generated. Otherwise, your program should print the message "Bad Choice". After each output test set, your program should print exactly one blank line.Sample Input3 515 2063923 99999Sample Output3 5 Good Choice15 20 Bad Choice63923 99999 Good Choice线性同余方法(LCG)是个产生伪随机数的方法。

杭电题目acm答案

杭电题目acm答案

选修课考试作业1001 Sum Problem (2)1089 A+B for Input-Output Practice (I) (4)1090 A+B for Input-Output Practice (II) (6)1091 A+B for Input-Output Practice (III) (8)1092 A+B for Input-Output Practice (IV) (9)1093 A+B for Input-Output Practice (V) (11)1094 A+B for Input-Output Practice (VI) (13)1095 A+B for Input-Output Practice (VII) (14)1096 A+B for Input-Output Practice (VIII) (16)2000 ASCII码排序 (17)2001计算两点间的距离 (19)2002计算球体积 (21)2003求绝对值 (22)2004成绩转换 (23)2005第几天? (25)2006求奇数的乘积 (27)2007平方和与立方和 (29)2008数值统计 (30)2009求数列的和 (32)2010水仙花数 (33)2011多项式求和 (35)2012素数判定 (37)2014青年歌手大奖赛_评委会打分 (38)2015偶数求和 (40)2016数据的交换输出 (43)2017字符串统计 (45)2019数列有序! (46)2020绝对值排序 (48)2021发工资咯:) (50)2033人见人爱A+B (52)2039三角形 (54)2040亲和数 (55)姓名:郑春杰班级:电商1001学号:10105041341001 Sum ProblemProblem DescriptionHey, welcome to HDOJ(Hangzhou Dianzi University Online Judge).In this problem, your task is to calculate SUM(n) = 1 + 2 + 3 + ... + n.?InputThe input will consist of a series of integers n, one integer per line.?OutputFor each case, output SUM(n) in one line, followed by a blank line. You may assume the result will be in the range of 32-bit signed integer.?Sample Input1100?Sample Output15050?AuthorDOOM III解答:#include<stdio.h>main(){int n,i,sum;sum=0;while((scanf("%d",&n)!=-1)){sum=0;for(i=0;i<=n;i++)sum+=i;printf("%d\n\n",sum);}}1089 A+B for Input-Output Practice (I)Problem DescriptionYour task is to Calculate a + b.Too easy?! Of course! I specially designed the problem for acm beginners.You must have found that some problems have the same titles with this one, yes, all these problems were designed for the same aim.?InputThe input will consist of a series of pairs of integers a and b, separated by a space, one pair of integers per line.?OutputFor each pair of input integers a and b you should output the sum of a and b in one line, and with one line of output for each line in input.?Sample Input1 510 20?Sample Output630?Authorlcy?RecommendJGShining解答:#include<stdio.h>main(){int a,b;while(scanf("%d%d",&a,&b)!=EOF) printf("%d\n",a+b);}1090 A+B for Input-Output Practice (II)Problem DescriptionYour task is to Calculate a + b.?InputInput contains an integer N in the first line, and then N lines follow. Each line consists of a pair of integers a and b, separated by a space, one pair of integers per line.?OutputFor each pair of input integers a and b you should output the sum of a and b in one line, and with one line of output for each line in input.?Sample Input21 510 20?Sample Output630?Authorlcy?RecommendJGShining解答:#include<stdio.h>#define M 1000void main(){int a,b,n,j[M],i;//printf("please input n:\n");scanf("%d",&n);for(i=0;i<n;i++){scanf("%d%d",&a,&b);//printf("%d %d",a,b);j[i]=a+b;}i=0;while(i<n){printf("%d",j[i]);i++;printf("\n");}}1091A+B for Input-Output Practice (III)Problem DescriptionYour task is to Calculate a + b.?InputInput contains multiple test cases. Each test case contains a pair of integers a and b, one pair of integers per line. A test case containing 0 0 terminates the input and this test case is not to be processed.?OutputFor each pair of input integers a and b you should output the sum of a and b in one line, and with one line of output for each line in input.?Sample Input1 510 200 0?Sample Output630?Authorlcy?RecommendJGShining解答:#include<stdio.h>main(){int a,b;scanf("%d %d",&a,&b);while(!(a==0&&b==0)){printf("%d\n",a+b);scanf("%d %d",&a,&b);}}1092A+B for Input-Output Practice (IV)Problem DescriptionYour task is to Calculate the sum of some integers.?InputInput contains multiple test cases. Each test case contains a integer N, and then N integers follow in the same line. A test case starting with 0 terminates the input and this test case is not to be processed.?OutputFor each group of input integers you should output their sum in one line, and with one line of output for each line in input.?Sample Input4 1 2 3 45 1 2 3 4 5?Sample Output1015?Authorlcy?RecommendJGShining?解答:#include <stdio.h>int main(){int n,sum,i,t;while(scanf("%d",&n)!=EOF&&n!=0){sum=0;for(i=0;i<n;i++){scanf("%d",&t);sum=sum+t;}printf("%d\n",sum);}}1093 A+B for Input-Output Practice (V)Problem DescriptionYour task is to calculate the sum of some integers.?InputInput contains an integer N in the first line, and then N lines follow. Each line starts with a integer M, and then M integers follow in the same line.?OutputFor each group of input integers you should output their sum in one line, and with one line of output for each line in input.?Sample Input24 1 2 3 45 1 2 3 4 5?Sample Output1015?Authorlcy解答:#include<stdio.h>main(){int n,a,b,i,j,sum;sum=0;while(scanf("%d\n",&n)!=-1){for(i=0;i<n;i++){scanf("%d",&b);for(j=0;j<b;j++){scanf("%d",&a);sum+=a;}printf("%d\n",sum);sum=0;}}}1094 A+B for Input-Output Practice (VI)Problem DescriptionYour task is to calculate the sum of some integers.?InputInput contains multiple test cases, and one case one line. Each case starts with an integer N, and then N integers follow in the same line.?OutputFor each test case you should output the sum of N integers in one line, and with one line of output for each line in input.?Sample Input4 1 2 3 45 1 2 3 4 5?Sample Output1015?Authorlcy?RecommendJGShining解答:#include<stdio.h>main(){int n,a,b,i,j,sum;sum=0;while(scanf("%d\n",&n)!=-1){for(j=0;j<n;j++){scanf("%d",&a);sum+=a;}printf("%d\n",sum);sum=0;}}[ Copy to Clipboard ]????[ Save to File]1095A+B for Input-Output Practice (VII)Problem DescriptionYour task is to Calculate a + b.?InputThe input will consist of a series of pairs of integers a and b, separated by a space, one pair of integers per line.?OutputFor each pair of input integers a and b you should output the sum of a and b, and followed by a blank line.?Sample Input1 510 20?Sample Output630?Authorlcy?RecommendJGShining解答:#include<stdio.h>main(){int a,b;while(scanf("%d%d",&a,&b)!=EOF)printf("%d\n\n",a+b);}1096 A+B for Input-Output Practice(VIII)Problem DescriptionYour task is to calculate the sum of some integers.?InputInput contains an integer N in the first line, and then N lines follow. Each line starts with a integer M, and then M integers follow in the same line.?OutputFor each group of input integers you should output their sum in one line, and you must note that there is a blank line between outputs.?Sample Input34 1 2 3 45 1 2 3 4 53 1 2 3?Sample Output10156?Authorlcy?RecommendJGShining解答:int main(){int a,b,i,j,l[1000],k;scanf("%d",&i);getchar();for(j=1;j<=i;j++)l[j]=0;for(j=1;j<=i;j++){scanf("%d",&a);getchar();for(k=1;k<=a;k++){scanf("%d",&b);getchar();l[j]+=b;}}for(j=1;j<=i-1;j++)printf("%d\n\n",l[j]);printf("%d\n",l[i]);}2000 ASCII码排序Problem Description输入三个字符后,按各字符的ASCII码从小到大的顺序输出这三个字符。

杭州电子科技大学OJ题目分类

杭州电子科技大学OJ题目分类

杭州电子科技大学OJ题目分类1001 整数求和水题1002 C语言实验题——两个数比较水题1003 1、2、3、4、5... 简单题1004 渊子赛马排序+贪心的方法归并1005 Hero In Maze 广度搜索1006 Redraiment猜想数论:容斥定理1007 童年生活二三事递推题1008 University 简单hash1009 目标柏林简单模拟题1010 Rails 模拟题(堆栈)1011 Box of Bricks 简单题1012 u Calculate e 简单数学计算1013 STAMPS 搜索or动态规划1014 Border 模拟题1015 Simple Arithmetics 高精度计算1016 Shoot-out 博弈+状态压缩DP1017 Tour Guide1018 Card Trick 简单题1019 Necklace Decomposition 贪心1020 Crashing Robots 模拟题1021 Electrical Outlets 简单题1022 Watchdog 简单题1023 Taxi Cab Scheme 图论:最小路径覆盖--->最大二分匹配1024 Pseudo-random Numbers 数论1025 Card Game Cheater 简单题1026 Investment 动态规划1027 Pipes1028 SETI 数学:高斯消元法1029 Minimax Triangulation 计算几何1030 Unequalled Consumption 母函数1031 Declaration of Content1032 Laserbox 搜索:DFS1033 Bowlstack1034 Pesky Heroes1035 Reduced ID Numbers 暴力1036 Tantrix1037 Guardian of Decency 图论:匈牙利算法求二分图的最大匹配1038 Up the Stairs 简单数学题1039 Sudoku 搜索:DFS1040 The SetStack Computer1041 Pie 二分法1042 Ticket to Ride 动态规划1043 The Bookcase 动态规划1044 Printer Queue 模拟题1045 Prime Path 搜索:BFS1046 Lineland's Airport1047 Leonardo's Notebook 数学题:群置换1048 简易版最长序列简单题1049 Jesse's problem 搜索:DFS1050 Error Correction 模拟题1051 A ×B problem 高精度计算1052 Redraiment的走法动态规划1053 Word Encoding 动态规划1054 Jesse's Code 组合数学:排列1055 简单密码破解水题1056 英文金曲大赛水题1057 有假币水题1058 寄居蟹与海葵水题1059 天仙配水题1060 鹊桥相会水题1061 杨辉三角水题1062 蟠桃记水题1063 养兔子水题1064 字符统计水题1065 完美数水题1066 亲和数水题1067 成绩评估水题1068 找零钱水题1069 漂亮菱形水题1070 Least Common Multiple 水题1071 第几天水题1072 编辑距离水题1073 支配值数目水题1074 等值数目水题1075 两数组最短距离水题1076 输入入门(1) 水题1077 输入入门(2) 水题1078 输入入门(3) 水题1079 输出入门水题1080 Counterfeit Dollar 组合数学1081 Dividing 动态规划1082 Sorting It All Out 图论:拓扑排序1083 False coin 暴力法1084 File Mapping1085 Color Me Less 简单题1086 Round and Round We Go 简单题1087 Microprocessor Simulation 简单题1088 求奇数的乘积水题1089 平方和与立方和水题1090 绝对值排序水题1091 JudgeOnline 水题1092 More Beautiful 水题1093 猴子分桃水题1094 C语言实验题——一元二次方程水题1095 C语言实验题——保留字母水题1096 C语言实验题——排列水题1097 C语言实验题——矩阵转置水题1098 C语言实验题——素数水题1099 Ambiguous permutations 简单题1100 Home Work 贪心法1101 Redraiment的遭遇数学题:找规律1102 Decorate the wall 搜索or动态规划1103 Economic phone calls 动态规划or贪心1104 Any fool can do it 记忆化搜索1105 Wine trading in Gergovia 贪心法1106 Homogeneous squares 随机算法1107 Automatic Correction of Misspellings 字符串处理:字典序1108 Black and white painting 简单数学题1109 Cylinder 计算几何:公式推导1110 Deli Deli 水题1111 Expressions 数据结构:树的遍历1112 Flavius Josephus Reloaded 数论:Pollard's Rho算法1113 Annoying painting tool 贪心法1114 Frequent values RMQ区间最值问题OR 线段树1115 Anagram Groups 字符串匹配1116 Let it Bead 组合数学->Polya定理1117 Simple Computers 简单题1118 Mondriaan's Dream 动态规划1119 Equidistance 计算几何1120 How many Fibs? 高精度计算1121 Hike on a Graph 搜索:BFS1122 ASCII Art1123 Billing Tables1124 Cellular Automaton 矩阵计算1125 Exchange1126 Fool's Game1127 Java vs C++ 字符串处理1128 Kickdown 字符串处理1129 Copying Books 贪心+二分法1130 Adding Reversed Numbers 简单题1131 Glass Beads 字符串的最小表示1132 The Circumference of the Circle 计算几何题1133 Knight Moves 搜索:BFS1134 Eeny Meeny Moo 变形的约瑟夫问题1135 Lotto 组合数学1136 Humble Numbers 动态规划1137 Average is not Fast Enough! 简单题1138 Etaoin Shrdlu 简单题1139 Hard to Believe, but True! 简单题1140 Code the Tree 简单题1141 Fiber Network 图论:全源最短路径,Floyd-Warshall算法1142 Global Roaming 3D几何题1143 All in All 字符串处理1144 The Sierpinski Fractal 递归1145 Assistance Required 简单题:预处理1146 Drink, on Ice 模拟题1147 All Discs Considered 搜索:BFS1148 In Danger 模拟题1149 Run Length Encoding 字符串处理1150 Bee Maja 模拟题1151 Friends 表达式求值1152 John 博弈论1153 Double Queue 最大堆与最小堆1154 ‘JBC’1155 Loan Scheduling 贪心+堆1156 Showstopper1157 Highway 贪心法1158 Computers 动态规划1159 The Stable Marriage Problem 组合数学1160 Arne Saknussemm 模拟题1161 Sum Problem 水题1162 Fire Net 搜索题1163 统计1到N之间数字1的个数推理题1164 最大公因子水题1165 C语言实验题——三个整数水题1166 C语言实验题——大小写转换水题1167 C语言实验题——分数序列水题1168 C语言实验题——最值水题1169 C语言实验题——保留整数水题1170 C语言实验题——矩阵下三角元素之和水题1171 C语言实验题——字符逆序水题1172 C语言实验题——打印菱形水题1173 C语言实验题——分割整数水题1174 C语言实验题——删除指定字符水题1175 C语言实验题——时间间隔水题1176 C语言实验题——数组逆序水题1177 C语言实验题——打印数字图形水题1178 C语言实验题——单词统计水题1179 C语言实验题——最小公倍数和最大公约数水题1180 Crashing Balloon 搜索题1181 念数字模拟题1182 A+B for Input-Output Practice(1) 水题1183 Anagrams by Stack 搜索:回溯1184 Elevator 数学:找规律1185 Substrings 字符串处理1186 Calling Extraterrestrial Intelligence Again 搜索:枚举法1187 Do the Untwist 简单数学题1188 数字对水题1189 A+B for Input-Output Practice (2) 水题1190 火星A+B 简单题1191 三齿轮问题:三个齿轮啮合简单数学题1192 A + B Problem II 高精度计算1193 The ones to remain 数学题1194 Chinese Chess 博弈论1195 Page Replacement 数据结构:队列or hash1196 RSA Signing 数论:Pollard's Rho算法1197 Number Guessing 搜索:穷举1198 求n的阶乘高精度计算1199 Area 计算几何1200 求两直线的夹角水题1201 三角形面积水题1202 Max Sum 动态规划1203 Number Sequence 大数问题1204 u Calculate e 水题1205 斐波那契数列高精度计算1206 Fibonacci Again 大数问题1207 Let the Balloon Rise 字符串处理1208 还是A+B 水题1209 A + B 水题1210 The area 简单计算几何1211 Ignatius's puzzle 简单数学问题1212 Computer Transformation 高精度计算1213 N! 高精度计算1217 Text Reverse 水题1220 填数字游戏搜索:DFS1221 Tempter of the Bone 搜索:DFS or BFS+剪枝1226 Last non-zero Digit in N! 数论1227 三角形递推求解1228 回文数猜想简单题1229 Factorial 简单题1230 Specialized Four-Digit Numbers 简单数学题1231 Lowest Bit 简单题1232 To and Fro 简单题1233 AC Me 简单题1234 Wolf and Rabbit 数论1235 最大连续子序列动态规划1236 开门人和关门人字符串处理1237 排名排序1238 统计难题字符串处理:字典树1239 Tick and Tick 数学题1240 Quoit Design 分治法1241 钱币兑换问题递推求解1242 求出前m大的数简单题1243 角谷猜想简单题1244 Reverse Number 简单题1245 寻找素数对简单题1246 ZJUTACM 简单题1247 Hat's Fibonacci 高精度计算1248 Encoding 简单题1249 四数相加高精度计算1250 两数相减高精度计算1251 Square Coins 母函数1252 Counting Triangles 递推求解1253 2^x mod n = 1 数论:费尔马小定理1254 Minimum Inversion Number 简单题1255 Surround the Trees 计算几何:凸包1256 Number Steps 简单题1257 Binary Numbers 简单题1258 Knight Moves 搜索:BFS1259 Lotto 组合数学1260 A Simple Task 简单题1261 The Drunk Jailer 数论1262 Hanoi Tower Troubles Again! 递推求解1263 IBM Minus One 水题1264 Definite Values 简单题1265 Box of Bricks 水题1266 Perfection 简单题1267 Reverse Text 水题1268 Inversion 模拟题1269 Prime Cuts 简单题1270 How Many Fibs? 高精度计算1271 Round and Round We Go 简单题1272 Red and Black 搜索:DFS1273 What Day Is It? 简单题1274 String Matching 字符串匹配1275 A Contesting Decision 简单题1276 Doubles 简单题1277 The Snail 简单题1278 Jungle Roads 图论:最小生成树1279 Prime Ring Problem 搜索:DFS1280 Big Number 大数问题1281 Least Common Multiple 简单题1283 简单排序水题1284 Gridland 简单题1285 An Easy Task 简单题1286 Calendar Game 模拟题1287 Human Gene Functions 动态规划1288 计算几何练习题——线段相交计算几何1289 计算几何练习题——线段相交II 计算几何1290 计算几何练习题——直线交点计算几何1291 Trees Made to Order 递归求解1292 排序简单题1293 18岁生日简单题1294 吃糖果递推求解1295 变种汉诺塔递推求解1296 洗牌递推求解1297 大数求余数论1298 圆桌会议递推求解1299 畅通工程并查集1300 还是畅通工程最小生成树1301 统计同成绩学生人数水题1302 简单计算器表达式求值:栈的应用1303 改进版计算器表达式求值:栈的应用1304 FatMouse' Trade 贪心法1305 Digital Roots 大数问题1306 Uniform Generator 数论1307 A Mathematical Curiosity 穷举法1308 Safecracker 穷举法1309 The 3n + 1 problem 简单题1310 分享糖果模拟题1311 宝物收集搜索:BFS1312 Climbing Worm 简单题1313 搬桌子贪心法1314 Humble Numbers 动态规划1315 Dividing 动态规划1316 Rightmost Digit 数学问题1317 Leftmost Digit 数学问题1318 Hangover 简单数学问题1319 Exponentiation 高精度计算1320 I Think I Need a Houseboat 简单题1321 Girls and Boys DFS+二分图1322 Monkey and Banana 动态规划1323 买牛奶简单题1324 Matrix Chain Multiplication 数据结构:栈的应用1325 计算成绩简单题1326 Holding Bin-Laden Captive! 母函数1327 You can Solve a Geometry Problem too 计算几何1328 Super Jumping! Jumping! Jumping! 动态规划1329 a^b 数论1330 计算GPA 水题1331 Give me an offer! 动态规划:0-1背包1332 田忌赛马贪心法1333 Asteroids! 搜索:BFS1334 Oil Deposits 搜索:DFS1335 营救天使搜索:BFS1336 小数化分数高精度计算1337 I Hate It 线段树1338 Strange Billboard 位运算+枚举1339 Frobenius 递推求解1340 奇怪的公式数学题1341 Fibonacci again and again 博弈论1342 A New Tetris Game 博弈论1343 Sum It Up 搜索:DFS1344 速算24点搜索1345 推箱子搜索:BFS1346 Pushing Boxes 搜索:BFS1347 The Worm Turns 搜索1348 Alfredo's Pizza Restaurant 简单题1349 Broken Keyboard 字符串处理1350 Convert Kilometers to Miles 简单题1351 单词数水题1352 仙人球的残影简单题1353 Family planning 简单题1354 Rout 66 简单题1355 LC-Display 模拟题1356 A == B ? 高精度计算1357 不容易系列之一递推求解1358 折线分割平面递推求解1359 find the nth digit 二分查找1360 奇数阶魔方(II) 简单题1361 Keep on Truckin' 简单题1362 Factstone Benchmark 简单题1363 Destroy the Well of Life 模拟题1365 Brave Game 博弈论1366 ASCII码排序水题1367 计算两点间的距离水题1368 计算球体积水题1369 求绝对值水题1370 数值统计水题1371 求数列的和水题1372 水仙花数水题1373 多项式求和水题1374 素数判定水题1375 偶数求和水题1376 母牛的故事水题1377 数列有序! 水题1378 发工资咯:)水题1379 C语言合法标识符水题1380 海选女主角水题1381 查找最大元素水题1382 首字母变大写水题1383 统计元音水题1384 Palindromes _easy version 水题1385 汉字统计水题1386 进制转换水题1387 人见人爱A+B 水题1388 人见人爱A-B 水题1389 人见人爱A^B 水题1390 改革春风吹满地计算几何1391 今年暑假不AC 动态规划1392 三角形水题1393 求平均成绩水题1394 不容易系列之二递推求解1395 密码水题1396 一只小蜜蜂... 递推求解1397 不容易系列之(3)——LELE的RPG难题递推求解1398 骨牌铺方格递推求解1399 阿牛的EOF牛肉串递推求解1400 神、上帝以及老天爷递推求解1401 不容易系列之(4)——考新郎递推求解1402 Bitset 简单题1403 Picture 简单模拟题1404 Switch Game 找规律1405 An easy problem 简单模拟题1406 A + B Again 简单题1407 The sum problem 简单数学题1408 龟兔赛跑动态规划1409 Snooker 简单数学题1410 Subset sequence 简单题1411 汉诺塔III 递推求解1412 "红色病毒"问题递推求解1413 小兔的棋盘递推求解1414 RPG的错排错排+排列组合1415 无限的路简单题1416 夹角有多大数学题1417 汉诺塔IV 递推求解1418 复习时间简单题1419 选课时间暴力求解1420 手机短号字符串处理1421 找单词母函数1422 简易版之最短距离数学题1423 数塔动态规划1424 核反应堆简单题1425 A1 = ? 公式推导1426 剪花布条字符串处理1427 不要62 数学题1428 空心三角形字符串处理1429 小明A+B 简单题1430 Sky数进制转换1431 整除的尾数简单题1432 分拆素数和数论1433 正整数解数学题1434 挂盐水模拟题1435 {A} + {B} 简单题1436 小数A+B 高精度计算1437 Zigzag 简单题1438 螺旋形简单题1439 行李寄存简单题1440 判断多边形凹凸计算几何1441 The centre of polygon 计算几何1442 最小正整数简单题1443 Elevator Stopping Plan 二分+贪心法1444 TOYS 计算几何1445 The Doors 计算几何1446 Polygon And Segment 计算几何1447 Fence 计算几何1448 两圆相交面积计算几何1449 Area of Circles 计算几何1450 Pipe 计算几何1451 zero sum 搜索:DFS1452 C语言实验题——Hello World 水题1453 C语言实验题——数日子水题1454 C语言实验题——三个数排序水题1455 C语言实验题——数字串求和水题1456 C语言实验题——拍皮球水题1457 C语言实验题——求一个3*3矩阵对角线元素之和水题1458 C语言实验题——数组逆序水题1459 C实验题——求最大值水题1460 C实验题——求绝对值最大值水题1461 C语言实验题——求平均值水题1462 C语言实验题——打印直角三角形水题1463 C语言实验题——相加和最大值水题1464 C语言实验题——简单编码水题1465 C语言实验题——某年某月的天数水题1466 C语言实验题——各位数字之和排序水题1467 C语言实验题——两个数最大水题1468 C语言实验题——求级数值水题1469 Pipe II 计算几何1470 Transmitters 计算几何1471 Wall 计算几何1472 C语言实验题——逆置正整数水题1473 C语言实验题——找中间数水题1474 C语言实验题——整数位水题1475 C语言实验题——一元二次方程II 水题1476 C语言实验题——圆周率水题1477 C语言实验题——余弦水题1478 C语言实验题——打印金字塔水题1479 C语言实验题——排序水题1480 C语言实验题——约瑟夫问题水题1481 C语言实验题——鞍点水题1482 C语言实验题——计算表达式水题1483 C语言实验题——汉诺塔水题1484 C语言实验题——字符串排序水题1485 C语言实验题——整除水题1486 Solitaire 搜索:(双向)BFS1487 Abbreviation 水题1488 C语言实验题——买糖果水题1489 C语言实验题——字符编码水题1490 C语言实验题——合法的C标识符水题1491 C语言实验题——三角形面积水题1492 C语言实验题——大小写转换水题1493 C语言实验题——圆柱体计算水题1494 C语言实验题——温度转换水题1495 C语言实验题——统计字串水题1496 C语言实验题——字符过滤水题1497 Coin Change 暴力求解1498 Beautiful Meadow 搜索题1499 C语言实验题——鸡兔同笼水题1500 Coins of Luck 数学题:数学期望1501 Friends 搜索:DFS1502 Find All M^N Please 数学题1503 Incredible Cows 搜索:二分+DFS1504 计算直线的交点数递推求解1505 Number Game 动态规划1506 Sort ZOJ7 字符串处理1507 Find 7 Faster Than John Von Neumann 高精度计算1508 免费馅饼动态规划1509 Worm 动态规划1510 Common Subsequence 动态规划1511 搬寝室动态规划1512 Daydream 字符串处理1513 Ballroom Lights1514 Drop the Triples1515 Finding Seats1516 He is offside!1517 Justice League1518 星星点点搜索1519 逆波兰表达式表达式求解:栈的应用1520 十六进制高精度计算1521 Palindromic sequence1522 Hotel 模拟题1523 Intersecting Lines 计算几何1524 Heap Construction 最短路径1525 Pizza Anyone?1526 Adam's Genes1527 Risk1528 Just the Facts 数论1529 Horse Shoe Scoring 计算几何1530 哥德巴赫猜想数论1531 爱的伟大意义简单题1532 校门外的树模拟题1533 最多约数问题数论1534 Quicksum 数学题1535 找规律填数字数学题1536 Accepted Necklace 搜索:DFS1537 除法表达式数论1538 A Walk Through the Forest 图论:最短路径1539 Accurately Say "CocaCola"! 简单题1540 Build The Electric System 图论:最小生成树1541 Colorful Rainbows 计算几何1542 Easy Task 数学题1543 Faster, Higher, Stronger 简单题1544 Give Me the Number 模拟题1545 Hurdles of 110m 动态规划1546 Just Pour the Water 矩阵计算1547 Kinds of Fuwas 穷举法1548 复数运算简单题1549 元素个数排序简单题1550 Fiber Communications1551 Power Hungry Cows 搜索:BFS1552 Cow Cycling 动态规划1553 Rebuilding Roads 树型DP1554 Triangular Pastures 动态规划1555 Chores 动态规划1556 Extra Krunch1557 BUY LOW, BUY LOWER 动态规划1558 Hypnotic Milk Improvement1559 Happy Cows1560 Unary Cow Counting1561 Dairy Route1562 Calf Numbers1563 Hide and Seek1564 Mountain Majesties1565 Secret Milk Pipes1566 Circus Tickets1567 Life Cycle1568 Wiggle Numbers1569 Superwords1570 Cow Brainiacs1571 Pasture Fences1572 New Years Party1573 Strolling Cows1574 Grazing Sets1575 Factorial Power1576 Friday the Thirteenth1577 Beef McNuggets1578 Calf Flac1579 Light Bulbs1580 Cow Math 图论1581 Cow Imposters 动态规划1582 Traffic Lights 递推求解1583 Farm Tour 图论:最短路径1584 Vertical Histogram 简单题1585 Cowties 动态规划1586 Travel Games 搜索:DFS1587 Best Cow Fences 二分法1588 Cornfields RMQ问题1589 Six Degrees of Cowvin Bacon 简单题1590 Herd Sums 简单题1591 Message Decoding 简单题1592 Mountain Walking 二分+flood fill1593 Millenium Leapcow 动态规划1594 Optimal Milking 最大流+二分法1595 Bale Figures 模拟+二分法1596 Jumping Cows 动态规划1597 Lost Cows SBT树1598 Bovine Math Geniuses 简单题1599 Dividing the Path 动态规划1600 Fence Obstacle Course 动态规划1601 Cow Ski Area 图论:flood fill1602 Cleaning Shifts 贪心法1603 Bad Cowtractors 最大生成树1604 Tree Cutting 树状动态规划1605 Navigation Nightmare 并查集1606 Cow Marathon 树状动态规划1607 Distance Queries LCA,tarjan算法1608 Distance Statistics 楼天成大牛“男人八题”中的一道1609 Moo University - Team Tryouts 排序+穷举法1610 Moo University - Emergency Pizza Order1611 Moo University - Financial Aid 最大堆、最小堆1612 Cube Stacking 并查集1613 The Cow Lineup 穷举法1614 MooFest 线段树1615 Turning in Homework 动态规划1616 Alignment of the Planets1617 Finding Bovine Roots1618 Cow Bowling1619 Cow Patterns 字符串匹配的扩展1620 Barn Expansion 二分查找1621 Layout 差分约束系统1622 Knights of Ni 搜索:BFS1623 Cleaning Shifts DP+Heap1624 Scales 搜索+剪枝1625 Secret Milking Machine 二分+网络流1626 Aggressive cows 二分法1627 Rigging the Bovine Election 穷举法1628 Feed Accounting 简单模拟题1629 Muddy Fields 穷举法1630 The Wedding Juicer 堆+flood fill1631 Naptime 动态规划1632 Sumsets 动态规划1633 Moo Volume 简单题1634 Ombrophobic Bovines Floyd-Warshall 1635 Space Elevator 动态规划1636 Yogurt factory 动态规划1637 Checking an Alibi 最短路径1638 Out of Hay1639 Satellite Photographs 搜索:BFS or DFS 1640 Asteroids 最大网络流1641 Grazing on the Run 动态规划1642 Walk the Talk 动态规划1643 City Skyline 栈的应用1644 Cow Acrobats 贪心法1645 Ant Counting 动态规划1646 Hopscotch 搜索:DFS1647 Securing the Barn 穷举法1648 Bovine Birthday 递推求解1649 Max Factor 简单题1650 Flying Right1651 Close Encounter1652 Allowance1653 Lazy Cows1654 Expedition1655 Around the world1656 Landscaping1657 Waves1658 Navigating the City1659 Disease Management1660 Muddy roads1661 Wormholes 最短路径1662 The Fewest Coins 动态规划1663 Milk Patterns 二分法or后缀树1664 Cow Picnic 搜索:BFS or DFS1665 Cow Roller Coaster 动态规划1666 River Hopscotch 二分法+贪心1667 The Moronic Cowmpouter 进制转换1668 DNA Assembly 穷举法1669 Cow Phrasebook 二分法1670 Cellphones 穷举法1671 Steady Cow Assignment 网络流1672 Treats for the Cows 动态规划1673 Backward Digit Sums 穷举法1674 Stump Removal 简单题1675 Finicky Grazers 动态规划1676 The Water Bowls 枚举二进制位1677 Redundant Paths 图论1678 Roping the Field 动态规划1679 Corral the Cows 二分法1680 The Cow Prom 图论1681 Dollar Dayz 动态规划1682 The Grove 最短路径1683 Fence Repair Huffman编码1684 Corn Fields 状态压缩DP1685 Roadblocks 图论:最短路径1686 Bad Hair Day 搜索1687 Big Square 穷举法1688 Round Numbers 枚举二进制位1689 Building A New Barn1690 Cow Sorting 置换群1691 Lilypad Pond 最短路径1692 The Cow Lexicon 动态规划1693 Silver Cow Party 最短路径1694 Problem Solving 动态规划1695 Cow School1696 Protecting the Flowers 贪心法1697 Tallest Cow 区间统计1698 Balanced Lineup RMQ问题1699 Gold Balanced Lineup RMQ问题1700 Ranking the Cows 搜索:DFS1701 Face The Right Way 穷举法1702 Cow Traffic 动态规划1703 Monthly Expense 贪心法1704 Cheapest Palindrome 动态规划1705 Dining 贪心+网络流1706 City Horizon 离散化+ 扫描1707 Catch That Cow 最短路径1708 Fliptile 枚举+位压缩1709 2-Dimensional Rubik's Cube 搜索:BFS 1710 Ball 计算几何1711 3D Camera 三维计算几何1712 Cipher 模拟题1713 Five in a Row 简单题1714 Pinhole Imaging 简单计算几何1715 URL 模拟题1716 Battle of Submarines 集合DP1717 WOJ 动态规划1718 钥匙计数之二递推求解1719 BrokenLED 模拟题1722 A+B again and again! 模拟题1723 Just calculate it! 数论1724 Guess how much I love you? 简单题1725 NBA Finals1726 Find Out an “E”1727 Judging ACM/ICPC1728 Cryptography of Alex1729 Rings of square grid1730 Fermat's Theorem1731 Cup 二分法1732 Find the Path DP+二分法1733 Five in a Row, Again 动态规划1734 Minimum Heap 递推求解1735 Name PK 模拟题1736 Pendant 动态规划1737 Radar 计算几何+搜索1738 Ring 多串模式匹配1739 Run 计算几何1740 Toxophily 简单题1741 通讯录编排简单题1742 超缘分ACM队伍简单题1743 集合运算简单题1744 矩阵计算简单题1745 Arbitrage 动态规划1746 The Tower of Babylon 动态规划1747 Binomial Showdown 组合数学1748 Dungeon Master 搜索:BFS1749 Equation Solver 表达式求值应用1750 Frogger 最短路径1751 Globetrotter 计算几何1752 Tree Recovery 数据结构:二叉树1753 Artificial Intelligence?1754 The Settlers of Catan 搜索1755 France '98 概率问题1756 Goldbach's Conjecture 数论1757 Heavy Cargo 最小生成树1758 Quadtree1759 From Dusk till Dawn or: Vladimir the Vampire 最短路径1760 Euro Cup 20001761 Quadtree II or: Florida Jones strikes back1762 HTML 简单题1763 Paths on a Grid 组合数学:T路问题1764 Balanced Food 动态规划1765 California Jones and the Gate to Freedom 组合数学1766 Diplomatic License 简单计算几何题1767 Polygon Programming with Ease 数学题1768 Hall of Fountains 搜索:BFS or DP1769 The Bottom of a Graph 图论:强连通分量1770 Edge1771 Fold1772 Largest Rectangle in a Histogram 动态规划1773 Boolean Logic1774 Code1775 In Danger 模拟题1776 Fractran1777 Huffman's Greed1778 Bullshit Bingo 字符串处理1779 A Song contest1780 Message1781 The skatepark's new ramps1782 Road1783 Warfare1784 Blackjack1785 Robintron1786 Diamond Dealer 计算几何:凸包1787 Best Compression Ever1788 Code Theft1789 Dinner1790 Event Planning1791 Getting Gold1792 Introspective Caching1793 Just A Few More Triangles!1794 Knights of the Round Table 图论:无向图的块判断奇圈1795 The Cow Doctor 穷举法1796 Wild West 线段树1797 Find the Clones1798 The Warehouse1799 Widget Factory 数论:同余方程组1800 Martian Mining 动态规划3301 字符串;AC自动机,动态规划;状态压缩3302 计算几何3303 数学;代数运算;高斯消元3304 图论;强连通分量;2-SAT3305 动态规划;凸单调性优化3306 枚举3307 贪心3308 数学;代数运算3309 最短路;佛洛伊德3310 动态规划3311 贪心3312 计数问题;递推,数状数组,二分查找3313 数论;欧拉定理,快速幂取模3314 计数问题,数状数组3315 博弈;Surreal数;Farey数列;3316 计数问题;递推,高精度3317 计数问题;容斥原理3318 递推;矩阵乘法3319 数学;概率3320 背包3321 动态规划3322 字符串;AC自动机3323 动态规划3324 博弈3325 搜索3326 贪心3327 最短路3328 数据结构(实现一种数据结构,支持要求的操作),数状数组3329 图论;二分图最大权匹配3330 数学;数论3331 递推;矩阵乘法3332 数学;数论,二分查找3333 计算几何3334 动态规划3335 字符串,后缀数组或拉宾卡普;动态规划3336 数据结构;并查集3337 计数问题,递推3338 二分查找,贪心3339 数学3340 计算几何;凸包,图论;佛洛伊德;最小环3341 动态规划3342 广搜3343 动态规划3344 计算几何3345 二分图最大匹配3346 树型DP3347 动态规划3348 数学;数论;进制3349 计数问题3350 贪心3351 数学;数论;进制3352 动态规划,数论,组合数学3353 数学;数论3354 计数;递推3355 图论;佛洛伊德3356 博弈3357 动态规划3358 数据结构;线段树,数状数组3359 计算几何,动态规划3360 博弈;SG函数3361 图论;最近公共祖先3362 图论;强连通分量;2-SAT 3363 计算几何3364 字符串;AC自动机,动态规划3365 搜索,舞蹈链3366 数学;数论3367 数学;代数运算;高斯消元3368 动态规划3369 计数问题;递推3370 网络流(错题)3371 树型DP3372 数学;高精度3373 数学;3374 RMQ3376 数学;进制3377 字符串;后缀数组3378 动态规划3379 计算几何3380 线段树3381 图论;欧拉路3382 简单题3383 字符串;AC自动机3384 广搜3385 计算几何,矩阵3386 语言处理3387 动态规划;状态压缩3388 图论;全局最小割3389 简单题3390 广搜3391 数学;Pell方程3392 背包3393 计算几何3394 广搜3395 搜索;迭代加深3396 数学;计数问题3397 数学;解方程3398 分析3399 模拟3400 数学;计数问题,数论6 热度。

杭州电子科技大学acm题目分类

杭州电子科技大学acm题目分类

杭州电子科技大学acm题目分类1002 简单的大数1003 DP经典问题,最大连续子段和1004 简单题1005 找规律(循环点)1006 感觉有点BT的题,我到现在还没过1007 经典问题,最近点对问题,用分治1008 简单题1009 贪心1010 搜索题,剪枝很关键10111012 简单题1013 简单题(有个小陷阱)1014 简单题1015 可以看作搜索题吧1016 经典的搜索1017 简单数学题1018 简单数学题1019 简单数学题1020 简单的字符串处理1021 找规律的数学题1022 数据结构的题(栈的应用)1023 特殊的数(Catalan Number)1024 经典DP,最大M子段和1025 经典DP,最长递增子序列(要用NLogN的方法过)1026 搜索1027 数学题(或用STL)1028 经典问题,整数拆分,用母函数做1029 简单题(一般方法容易超时)1030 简单题,可用模拟过1031 简单题1032 简单题1033 模拟题1034 Candy Sharing Game1035 模拟题1036 简单题1037 简单题,不是一般的简单1038 简单题1039 字符串处理1040 简单题,排序1041 简单题,用大数1042 大数1043 经典搜索题,八数码问题1044 稍微有点麻烦的搜索题1045 搜索题,可用匹配做1046 简单题1047 简单的大数1048 简单字符串处理1049 简单题1050 贪心1051 经典贪心,也可以用DP1052 贪心1053 贪心,关于Huffman编码1054 二分匹配1055 二分匹配1056 简单题1057 模拟题1058 经典问题,丑数,DP1059 经典问题,可以用母函数或DP(不针对题目优化都会超时)1060 数学题1061 数学题1062 简单字符串处理1063 模拟大数1064 简单题1065 简单题1066 数学题,找规律10671068 经典二分匹配1069 经典DP1070 简单题1071 简单数学题1072 搜索1073 字符串处理1074 DP1075 字典树1076 简单题10771078 DP1079 博弈(DP)1080 DP1081 经典DP1082 简单题1083 二分匹配1084 简单题1085 母函数1086 简单几何题1087 简单DP1088 字符串处理1089~1096 (练习输入输出的8个题目)1097 简单数学题1098 数学题,注意找规律1099 数学题模拟题, 枚举1002 1004 1013 1015 1017 1020 1022 1029 1031 1033 1034 1035 1036 1037 1039 1042 1047 1048 1049 1050 1057 1062 1063 1064 1070 1073 1075 1082 1083 1084 1088 1106 1107 1113 1117 1119 1128 1129 1144 1148 1157 1161 1170 1172 1177 1197 1200 1201 1202 1205 1209 1212(大数取模) 1216(链表)1218 1219 1225 1228 1229 1230 1234 1235 1236 1237 1239 12501256 1259 1262 1263 1265 1266 1276 1279 1282 1283 1287 1296 13021303 1304 1305 1306 1309 1311 1314复杂模拟搜索,递归求解1010 1016 1026 1043(双广) 1044 (BFS+DFS) 1045 1067 1072 1104 1175 1180 1195 1208 1226 1238 1240 1241 1242 1258 1271 1312 1317 博奕1079动态规划1003 1024 1025 1028 1051 1058 1059 1069 1074 1078 1080 1081 1085 1087 1114 1158 1159 1160 1171 1176 1181 1203 1224 1227 1231 1244 1248 1253 1254 1283 1300数学,递推,规律1005 1006 1012 1014 1018 1019 1021 1023 1027 1030 1032 1038 1041 1046 1059 1060 1061 1065 1066 1071(微积分) 1097 1098 1099 1100 1108 1110 1112 1124 1130 1131 1132 1134 1141 1143 1152 1155(物理题) 1163 1165 1178 1194 1196(lowbit) 1210 1214 1200 1221 1223 1249 1261 1267 1273 1290 1291 1292 1294 1297 1313 1316数论1164 1211 1215 1222 1286 1299计算几何1086 1115 1147贪心1009 1052 1055 1257并查集1198 1213 1232 1272线段树,离散化1199 1255图论最短路相关的问题1142 1162 1217 1301二分图问题1054 1068 1150 1151 1281其他1053 (huffman) 1102(MST) 1116(欧拉回路)1233(MST) 1269(强连通)数据结构1103(堆+模拟)1166(数状树组)1247 1251 1285(Topol)1298汉诺塔系列1207最近顶点对10071500 DP1501 DP1502 DP or 记忆化1503 DP1504 模拟1505 DP1506 DP1507 2分匹配1508 记忆化容易点1509 模拟1510 DP1511 搜索可以过1512 左偏树1513 DP1514 DP1515 DFS1516 DP1517 博奕1518 搜索1519 DP(不确定)1520 树状DP1521 数学题,母函数什么的。

  1. 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
  2. 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
  3. 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。

ACM入门(杭电oj)Hdu 1000#include<stdio.h>#include<stdlib.h>int main(){int a,b;while(scanf("%d%d",&a,&b)!=EOF){printf("%d\n",a+b);}}Hdu 1001#include<stdio.h>#include<stdlib.h>int main(){int n;while(scanf("%d",&n)!=EOF){printf("%I64d\n\n",(__int64)(1+n)*n/2); }}Hdu 1002#include<stdio.h>#include<string.h>#include<stdlib.h>char str1[1005],str2[10005];int main(){int ca,count=0;scanf("%d",&ca);while(ca--){scanf("%s%s",str1,str2);int a[1005],i,j;memset(a,0,sizeof(a));for(i=strlen(str1)-1,j=0;i>=0;i--,j++)a[j]=str1[i]-'0';for(i=strlen(str2)-1,j=0;i>=0;i--,j++){a[j]=a[j]+str2[i]-'0';a[j+1]=a[j+1]+a[j]/10;a[j]=a[j]%10;}count++;printf("Case %d:\n",count);printf("%s + %s = ",str1,str2); int flag=0;for(i=1004;i>=0;i--)if(flag||a[i]){printf("%d",a[i]);flag=1;}printf("\n");if(ca!=0) printf("\n");}}Hdu 1003#include<stdio.h>#include<stdlib.h>int a[100005],sum[100005];int main(){int ca,count=0;scanf("%d",&ca);while(ca--){int n,i;scanf("%d",&n);for(i=1;i<=n;i++)scanf("%d",&a[i]);sum[1]=a[1];int r=1,max=a[1];for(i=2;i<=n;i++){if(sum[i-1]>0){sum[i]=sum[i-1]+a[i];if(sum[i]>max){max=sum[i];r=i;}}else{sum[i]=a[i];if(sum[i]>max){max=sum[i];r=i;}}}count++;for(i=r-1;i>0;i--)if(sum[i]<0) break;printf("Case %d:\n",count);printf("%d %d %d\n",max,i+1,r); if(ca!=0) printf("\n");}}Hdu 1004#include<iostream>#include<algorithm>using namespace std;struct point{char c[50];}p[1005];int cmp(point p1,point p2){return strcmp(p1.c,p2.c)<0;}int main(){int n,i;while(scanf("%d",&n)!=EOF&&n) {for(i=0;i<n;i++)scanf("%s",p[i].c);sort(p,p+n,cmp);char res[100];strcpy(res,p[0].c);int num=1,ct=1;for(i=1;i<n;i++){if(strcmp(p[i].c,p[i-1].c)==0) num++; else num=1;if(num>ct){strcpy(res,p[i].c);ct=num;}}printf("%s\n",res);}}Hdu 1005#include<stdio.h>#include<stdlib.h>#include<string.h>int s[10][10],c[1000];int main(){c[1]=1;c[2]=1;int a,b,n;while(scanf("%d%d%d",&a,&b,&n)!=EOF){if(a==0&&b==0&&n==0) break;memset(s,0,sizeof(s));s[1][1]=1;int i;for(i=3;;i++){c[i]=(a*c[i-1]+ b*c[i-2])%7;if(s[c[i-1]][c[i]]!=0) break;s[c[i-1]][c[i]]=i-1;}/*for(int j=1;j<=i;j++)printf("%d ",c[j]);*/int m=s[c[i-1]][c[i]]-1;int len=i-1-s[c[i-1]][c[i]];//printf("%d %d\n",m,len);if(n<=m){printf("%d\n",c[n]);continue;}n=n-m;printf("%d\n",c[m+(n%len? n%len:len)]); }}Hdu 1008#include<stdio.h>#include<stdlib.h>int main(){int n;while(scanf("%d",&n)!=EOF&&n){int a,sum=0,st=0,m=n;while(n--){scanf("%d",&a);sum=sum+(a-st>0?(a-st)*6:(st-a)*4); st=a;}printf("%d\n",m*5+sum);}}Hdu 1012#include<stdio.h>int main(){printf("n e\n");printf("- -----------\n");printf("0 1\n");printf("1 2\n");printf("2 2.5\n");printf("3 2.666666667\n");printf("4 2.708333333\n");printf("5 2.716666667\n");printf("6 2.718055556\n");printf("7 2.718253968\n");printf("8 2.718278770\n");printf("9 2.718281526\n");}#include<stdlib.h>#include<string.h>#include<stdio.h>int main(){char s[1000];while(scanf("%s",s)!=EOF){if(strcmp(s,"0")==0) break;int i,t=0;for(i=0;i<strlen(s);i++)t=t+s[i]-'0';printf("%d\n",(t+8)%9+1);}}Hdu 1016#include<stdio.h>#include<string.h>inta[25]={2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61, 67,71,73};int num[25],flag[25],pri[100],n;void dsf(int x,int y){int i;if(y==n){if(pri[x+1]==1){for(i=1;i<n;i++)printf("%d ",num[i]);printf("%d\n",num[i]);}return;}for(i=2;i<=n;i++)if(flag[i]==0&&pri[x+i]==1){flag[i]=1;num[y+1]=i;dsf(i,y+1);flag[i]=0;}int main(){int ct=0,i;memset(pri,0,sizeof(pri));for(i=0;i<15;i++)pri[a[i]]=1;while(scanf("%d",&n)!=EOF){memset(flag,0,sizeof(flag)); printf("Case %d:\n",++ct);flag[1]=1;num[1]=1;dsf(1,1);printf("\n");}}。

相关文档
最新文档