hdu 分类

基础题:1000、1001、1004、1005、1008、1012、1013、1014、1017、1019、1021、1028、1029、1032、1037、1040、1048、1056、1058、1061、1070、1076、1089、1090、1091、1092、1093、1094、1095、1096、1097、1098、1106、1108、1157、1163、1164、1170、1194、1196、1197、1201、1202、1205、1219、1234、1235、1236、1248、1266、1279、1282、1283、1302、1303、1323、1326、1330、1334、1335、1339、1390、1391、1393、1395、1397、1405、1406、1407、1408、1412、1418、1420、1465、1491、1555、1562、1563、1570、1587、1673、1678、1708、1718、1720、1785、1799、1859、1862、1877、1898、1976、1977、1985、1994、2000、2001、2002、2003、2004、2005、2006、2007、2008、2009、2010、2011、2012、2013、2014、2015、2016、2017、2018、2019、2020、2021、2022、2023、2024、2025、2026、2027、2028、2029、2030、2031、2032、2033、2034、2035、2039、2040、2042、2043、2048、2049、2051、2053、2055、2056、2057、2060、2061、2071、2073、2075、2076、2078、2081、2083、2088、2090、2092、2093、2095、2096、2097、2098、2099、2101、2103、2106、2107、2109、2113、2114、2115、2123、2131、2132、2133、2135、2136、2137、2138、2139、2143、2148、2153、2156、2161、2162、2164、2178、2186、2192、2200、2201、2212、2304、2309、2317、2401、2500、2502、2503、2504、2519、2520、2521、2523、2524、2535、2537、2539、2547、2548、2549、2550、2551、2552、2555、2560、2561、2562、2566、2567、2568、2700、2710、


DP:1003、1024、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、

搜索:1010、1015、1016、1026、1072、1075、1175、1180、1181、1238、1239、1240、1241、1242、1253、1254、1312、1372、1548、1597、1671、1677、1728、1800、1983、2102、2141、2553、2563、2605、2612、2614、1616、2717

贪心:1009、1045、1049、1050、1051、1052、1257、1800、2037、2111、2124、2187、2391、2570

数学题:1018、1065、1071、1115、1141、1162、1212、1220、1492、1593、1701、1722、1798、1840、1999、2036、2080、2086、2089、2105、2108、2134、2303、2393、2438、2529、2547、2548、2552、2554、2601、2603、2701、

递推:1133、1143、1207、1249、1267、1284、1290、1297、1396、1992、1995、1996、2013、2014、2044、2045、2046、2047、2050、2064、2065、2067、2068、2070、2077、2085、2151、2154、2160、2190、2501、2512、2563、2569、2709、2716、

字符串:1020、1039、1043、1062、1073、1075、1088、1113、1161、1200、1251、1256、1288、1321、1328、1379、1804、1860、1982、1984、2017、2024、2025、2026、2027、2043、2052、2054、2072、2074、2087、2131、2137、2140、2163、2203、2206、2352、2500、2549、2564、2565、2567、2572、2609、2607、2707、2708、2719、2721、2723、

大数:1002、1042、1133、1250、1297、1715、1753、1865、2100、

胡搞:1022、1027、1030、1035、1128、1165、1209、1210、1215、1222、1228、1229、1230、1237、1259、1276、1286、1337、1342、1361、1370、1506、1577、1597、1702、1716、1727、1868、1870、1896、1981、1986、1987、1988、1997、1998、1999、2058、2062、2089、2090、2094、2104、2116、2117、2135、2175、2183、2184、2197、2303、2368、2370、2374、2511、2522、2527、2600、2615、2703、2711、2714、2715、2725、

博弈:1077、1404、1517、1524、1525、1527、1536、1564、1729、1730、1846、1847、1848、1849、1850、2147、2149、2176、2177、2188

母函数:1085、1171、1398、2079、2082、2110、2152、2189、2566、

hash:1264、1280、1425、1496、1800、2522、2600、

------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

按照ac的代码长度分类(主要参考最短代码和自己写的代码)
短代码:0.01K--0.50K;中短代码:0.51K--1.00K;中等代码量:1.01K--2.00K;长代码:2.01K以上。

短:1147、1163、1922、2211、2215、2229、2232、2234、2242、2245、2262、2301、2309、2313、2334、2346、2348、2350、2352、2381、2405、2406;

中短:1014、1281、1618、1928、1961、2054、2082、2085、2213、2214、2244、2247、2255、2257、2258、2260、2265、2272、2273、2275、2287、2299、2329、2376;

中等:1001、1018、1037、1039、1054、1125、1655、2165、2210、2212、2225、2240、2241、2243、2246、2254、2303、2312、2339;

长:1009、1010、1015、2050。

附注:

短(中短)代码但要有思想(一定难度):1014、1147、1618、1961、2054、2082、2232、2244、2255、2273、2287、2299、2313、2348、2352、2376、2406;

长代码但没有难度:2050。

---------------------------------------------------------------------------------------------------------------------------
动态规划:
1037 A decorative fence、1050 To the Max、1088 滑雪、1125 Stockbroker Grapevine、1141 Brackets Sequence、1159 Palindrome、1160 Post Office、1163 The Triangle、1458 Common Subsequence、1579 Function Run Fun、1887 Testing the CATCHER、1953 World Cup Noise、2386 Lake Counting

简单、模拟题:
1001 Exponentiation 、1002 487-3279、1003 Hangover 、1701 Dissatisfying Lift、2301 Beat the Spread!、2304 Combination Lock、2328 Guessing Game、2403 Hay Points 、2406 Power Strings、2339 Rock, Scissors, Paper、2350 Above Average、2218 Does This Make Me Look Fat?、2260 Error Correction、2262 Goldbach\'s Conjecture、2272 Bullseye、2136 Vertical Histogram、2174 Decoding Task、2183 Bovine Math Geniuses、2000 Gold Coins、2014 Flow Layout、2051 Argus、2081 Calendar、1918 Ranking List、1922 Ride to School、1970 The Game、1972 Dice Stacking、1974 The Happy Worm、1978 Hanafuda Shuffle、1979 Red and Black、1617 Crypto Columns、1666 Candy Sharing Game、1674 Sorting by Swapping、1503 Integer Inquiry、1504 Adding Reversed Numbers、1528 Perfection、1546 Basically Speaking、1547 Clay Bully、1573 Robot Motion、1575 Easier Done Than Said?、1581 A Contesting Decision、1590 Palindromes、1454 Factorial Frequencies、1363 Rails、1218 THE DRUNK JAILER、1281 MANAGER、1132 Border、1028 Web Navigation、
博弈类
1067 取石子游戏、1740 A New Stone Game、2234 Matches Game、1082 Calendar Game 、2348 Euclid\'s Game、2413 How many Fibs?、2419 Forests
初等数学
1003 Hangover、1045 Bode Plot、1254 Hansel and Grethel、1269 Intersecting Lines、1401 Factorial、1410 Intersection、2363 Blocks 、2365 Rope、2242 The Circumference of the Circle、2291 Rotten Ropes、2295 A DP Problem、2126 Factoring a Polynomial、2191 Mersenne Composite Numbers、2196 Specialized Four-Digit Numbers、1914 Cramer\'s Rule、1835 宇航员、1799 Yeehaa!、1607 Deck、1244 Slots of Fun、1269 Intersecting Lines、1299 Polar Explorer、1183 反正切函数的应用、

图论及组合数学
2421 Constructing Roads、2369 Permutations、2234 Matches Game、2243 Knight Moves、2249 Binomial Showdown、2255 Tree Recovery、2084 Game of Connections、1906 Three powers、1833 排列、1850 Code、1562 Oil Deposits、1496 Word Index、1306 Combinations、1125 Stockbroker Grapevine、1129 Channel Allocation、1146 ID Codes、1095 Trees Made to Order、找规律2247 Humble Numbers、2309 BST、2346 Lucky tickets、2370 Democracy in danger、2365 Rope、2101 Honey and Milk Land
2028 When Can We Meet?、2084 Game of Connections、1915 Knight Moves、1922 Ride to School、1941 The Sierpinski Fractal、1953 World Cup Noise、1958 Strange Towers of Hanoi、1969 Count on Canton、1806 Manhattan 2025、1809 Regetni、1844 Sum、1870 Bee Breeding、1702 Eva\'s Balance、1728 A flea on a chessboard、1604 Just the Facts、1642 Stacking Cubes、1656 Counting Black、1657 Distance on Chessboard、1662 CoIns、1663 Number Steps、1313 Booklet Printing、1316 Self Numbers、1320 Street Numbers、1323 Game Prediction、1338 Ugly Numbers、1244 Slots of Fun、1250 Tanning Salon、1102 LC-Display、1147 Binary codes、1013 Counterfeit Dollar、
---------------------------------------------------------------------------------------------------------------------------
题目分类
排序 1002(需要字符处理,排序用快排即可) 1007(稳定的排序) 2159(题意较难懂) 2231 2371(简单排序) 2388(顺序统计算法) 2418(二叉排序树)

回溯搜索:1979(和迷宫类似) 1980(对剪枝要求较高)

数学计算 简单(或不值得做的题):1003 1004 1005 1068 1326 1656 1657 1658 1663 1922 1978 2000 2013 2014 2017 2070 2101 2105 2140 2190 2272 2301 2405 2419
中等:1006(中国剩余定理) 1323 1969 2015(解密码) 2081(预处理) 2085(找规律)
难: 1014 1037 1147 2082 (这些是上课讲的)

高精度计算:1001(高精度乘法) 2413(高精度加法,还有二分查找)

历法:1008 2080 (这种题要小心)

枚举:1054(剪枝要求较高) 1650 (小数的精度问题)

数据结构的典型算法:1125(弗洛伊德算法) 2421(图的最小生成树)

动态规划:1163(经典题)

贪心:1328 1755(或用单纯形方法) 2054

模拟: 1281 1928 2083 2141 2015

递归: 1664
字符串处理:2121 2403

---------------------------------------------------------------------------------------------------------------------------
有标准模型的:
1125 1163 1183 1979 1185 1184 1187
寻找新算法的:
1014 1067 1147 1922 2082
调节情绪用:
1004 950 1218 1281 1928 1978 2000 2027

---------------------------------------------------------------------------------------------------------------------------
主流算法:
1.搜索 //回溯
2.DP(动态规划) 
3.贪心 
4.图论 //Dijkstra、最小生成树、网络流
5.数论 //解模线性方程
6.计算几何 //凸壳、同等安置矩形的并的面积与周长
7.组合数学 //Polya定理
8.模拟 
9.数据结构 //并查集、堆
10.博弈论 
//表示举例

非主流算法:
1.送分题 
2.构造 
3.高精度 
4.几何 
5.排序 
6.日期/时间处理 (这类题目相当多的)
7.数学方法 
8.枚举 
9.递推 
10.递归 
11.分治 


说明:
显然“送分题”不是一种算法。但是ACM竞赛中经常有一些很简单很简单的题目,具体涉及内容繁杂,难以归类,干脆就管他们叫送分题。
几何不同于计算几何,计算几何或者叫S计算几何,以Shamos在1975年发表的一篇论文为诞生标志。其实两者有很大的不同。

部分题目分类统计:

网络流:
最大流:
1087 a plug for UNIX
1149 PIGS
1273 drainage ditches
1274 the perfect stall
1325 machine schedule
1459 power network
2239 selecting courses
最小费用最大流:
2195 going home
?2400 supervisor, supervisee

压缩存储的DP
1038 bugs integrated inc
1185 炮兵阵地
2430 lazy cow

最长公共子串(LCS):
1080 human gene functions
1159 palindrome
1458 common subsequence
2192 zipper

凸包
1113 wall
2187 beauty contest


---------------------------------------------------------------------------------------------------------------------------

说明:递推算动归, 离散化算数据结构, 并查集算数据结构, 博弈算动归, 麻烦题一般都是不错的综合题, 最短路算图论,数据的有序化算排序

麻烦题:
1697, 1712, 1713, 1720, 1729, 1765, 1772, 1858, 1872, 1960, 1963, 2050, 2122, 2162, 2219, 2237,

简单题目:
1000, 1003, 1004, 1005, 1007, 1046, 1207, 1226, 1401, 1504, 1552, 1607, 1657, 1658, 1674, 1799, 1862, 1906, 1922, 1929, 1931, 1969, 1976, 2000, 2005, 2017, 2027, 2070, 2101, 2105, 2109, 2116, 2136, 2160, 2190, 2232, 2234, 2275, 2301, 2350, 2363, 2389, 2393, 2413, 2419,
推荐:
1063, 1064, 1131, 1140, 1715, 2163,

杂题:
1014, 1218, 1316, 1455, 1517, 1547, 1580, 1604, 1663, 1678, 1749, 1804, 2013, 2014, 2056, 2059, 2100, 2188, 2189, 2218, 2229, 2249, 2290, 2302, 2304, 2309, 2313, 2316, 2323, 2326, 2368, 2369, 2371, 2402, 2405, 2407,
推荐:
1146, 1147, 1148, 1171, 1389, 1433, 1468, 1519, 1631, 1646, 1672, 1681, 1700, 1701, 1705, 1728, 1735, 1736, 1752, 1754, 1755, 1769, 1781, 1787, 1796, 1797, 1833, 1844, 1882, 1933, 1941, 1978, 2128, 2166, 2328, 2383, 2420,

高精度:
1001, 1220, 1405, 1503,

排序:
1002, 1318, 1877, 1928, 1971, 1974, 1990, 2001, 2002, 2092, 2379, 2388, 2418,
推荐:
1423, 1694, 1723, 1727, 1763, 1788, 1828, 1838, 1840, 2201, 2376, 2377, 2380,

搜索
容易:
1128, 1166, 1176, 1231, 1256, 1270, 1321, 1543, 1606, 1664, 1731, 1742, 1745, 1847, 1915, 1950, 2038, 2157, 2182, 2183, 2381, 2386, 2426,
不易:
1024, 1054, 1117, 1167, 1708, 1746, 1775, 1878, 1903, 1966, 2046, 2197, 2349,
推荐:
1011, 1190, 1191, 1416, 1579, 1632, 1639, 1659, 1680, 1683, 1691, 1709, 1714, 1753, 1771, 1826, 1855, 1856, 1890, 1924, 1935, 1948, 1979, 1980, 2170, 2288, 2331, 2339, 2340,

数据结构
容易:
1182, 1656, 2021, 2023, 2051, 2153, 2227, 2236, 2247, 2352, 2395,
不易:
1145, 1177, 1195, 1227, 1661, 1834,
推荐:
1330, 1338, 1451, 1470, 1634, 1689, 1693, 1703, 1724, 1988, 2004, 2010, 2119, 2274,

动态规划
容易:
1018, 1050, 1083, 1088, 1125, 1143, 1157, 1163, 1178, 1179, 1189, 1208, 1276, 1322, 1414, 1456, 1458, 1609, 1644, 1664, 1690, 1699, 1740, 1742, 1887, 1926, 1936, 1952, 1953, 1958, 1959, 1962, 1975, 1989, 2018, 2029, 2033, 2063, 2081, 2082, 2181, 2184, 2192, 2231, 2279, 2329, 2336, 2346, 2353, 2355, 2356, 2385, 2392, 2424,
不易:
1019, 1037, 1080, 1112, 1141, 1170, 1192, 1239, 1655, 1695, 1707, 1733, 1737, 1837, 1850, 1920, 1934, 1937, 1964, 2039, 2138, 2151, 2161, 2178,
推荐:
1015, 1635, 1636, 1671, 1682, 1692, 1704, 1717, 1722, 1726, 1732, 1770, 1821, 1853, 1949, 2019, 2127, 2176, 2228, 2287, 2342, 2374, 2378, 2384, 2411,

字符串:
1488, 1598, 1686, 1706, 1747, 1748, 1750, 1760, 1782, 1790, 1866, 1888, 1896, 1951, 2003, 2121, 2141, 2145, 2159, 2337, 2359, 2372, 2406, 2408,

贪心:
1042, 1065, 1230, 1323, 1477, 1716, 1784,

图论
容易:
1161, 1164, 1258, 1175, 1308, 1364, 1776, 1789, 1861, 1939, 1940, 1943, 2075, 2139, 2387, 2394, 2421,
不易:
1041, 1062, 1158, 1172, 1201, 1275, 1718, 1734, 1751, 1904, 1932, 2173, 2175, 2296,
网络流:
1087, 1273, 1698, 1815, 2195,
匹配:
1274, 1422, 1469, 1719, 2060, 2239,
Euler:
1237, 1637, 1394, 2230,
推荐:
2049, 2186,

计算几何
容易:
1319, 1654, 1673, 1675, 1836, 2074, 2137, 2318,
不易:
1685, 1687, 1696, 1873, 1901, 2172, 2333,
凸包:
1113, 1228, 1794, 2007, 2187,

模拟
容易:
1006, 1008, 1013, 1016, 1017, 1169, 1298, 1326, 1350, 1363, 1676, 1786, 1791, 1835, 1970, 2317, 2325, 2390,
不易:
1012, 1082, 1099, 1114, 1642, 1677, 1684, 1886,

数学
容易:
1061, 1091, 1142, 1289, 1305, 1306, 1320, 1565, 1665, 1666, 1730, 1894, 1914, 2006, 2042, 2142, 2158, 2174, 2262, 2305, 2321, 2348,
不易:
1067, 1183, 1430, 1759, 1868, 1942, 2167, 2171, 2327,
推荐:
1423, 1450, 1640, 1702, 1710, 1721, 1761, 1830, 1930, 2140,

ps:同学那转过来的。

posted @ 2012-05-01 20:55 Mr_DaSh 阅读(10) 评论(0) 编辑

最简单的计算机

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 2480    Accepted Submission(s): 1441


Problem Description
一个名叫是PigHeadThree的研究组织设计了一台实验用的计算机,命名为PpMm。PpMm只能执行简单的六种命令A,B,C,D,E,F;只有二个内存M1,M2;三个寄存器R1,R2,R3。六种命令的含义如下:
  命令A:将内存M1的数据装到寄存器R1中;
  命令B:将内存M2的数据装到寄存器R2中;
  命令C:将寄存器R3的数据装到内存M1中;
  命令D:将寄存器R3的数据装到内存M2中;
  命令E:将寄存器R1中的数据和寄存器R2中的数据相加,结果放到寄存器R3中;
  命令F:将寄存器R1中的数据和寄存器R2中的数据相减,结果放到寄存器R3中。
你的任务是:设计一个程序模拟PpMm的运行。
 

 

Input
有若干组,每组有2行,第一行是2个整数,分别表示M1和M2中的初始内容;第二行是一串长度不超过200的由大写字母A到F组成的命令串,命令串的含义如上所述。
 

 

Output
对应每一组的输入,输出只有一行,二个整数,分别表示M1,M2的内容;其中M1和M2之间用逗号隔开。

其他说明:R1,R2,R3的初始值为0,所有中间结果都在-2^31和2^31之间。
 

 

Sample Input
100 288
ABECED
876356 321456
ABECAEDBECAF
 

 

Sample Output
388,388
2717080,1519268
# include <stdio.h>    
int main() 
{
 
    int
 m1,m2,r1,r2,r3; 
    char
 s; 
    while
 (scanf("%d%d",&m1,&m2)!=EOF)
    {
 
        getchar(); 
        r1=r2=r3=0; 
        while
 ((s= getchar())!= '\n')
        {
 
             if
 (s=='A')r1=m1; 
             else
                 if
(s=='B')r2=m2; 
             else
                 if
(s=='C')m1=r3; 
             else
                 if
(s=='D')m2=r3; 
             else
                 if
(s=='E')r3=r1+r2; 
             else
                 if
(s=='F')r3=r1-r2;               
        }
 
        printf("%d,%d\n",m1,m2); 
    } 
}
 
ps:结束水题了。五一假期没了。
posted @ 2012-05-01 17:42 Mr_DaSh 阅读(9) 评论(0) 编辑

回文数猜想

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 2144    Accepted Submission(s): 1310


Problem Description
一个正整数,如果从左向右读(称之为正序数)和从右向左读(称之为倒序数)是一样的,这样的数就叫回文数。任取一个正整数,如果不是回文数,将该数与他的倒序数相加,若其和不是回文数,则重复上述步骤,一直到获得回文数为止。例如:68变成154(68+86),再变成605(154+451),最后变成1111(605+506),而1111是回文数。于是有数学家提出一个猜想:不论开始是什么正整数,在经过有限次正序数和倒序数相加的步骤后,都会得到一个回文数。至今为止还不知道这个猜想是对还是错。现在请你编程序验证之。
 

 

Input
每行一个正整数。
特别说明:输入的数据保证中间结果小于2^31。
 

 

Output
对应每个输入,输出两行,一行是变换的次数,一行是变换的过程。
 

 

Sample Input
27228 37649
 

 

Sample Output
3
27228--->109500--->115401--->219912
2
37649--->132322--->355553
# include <stdio.h>
int fan(int n)
{
   
     int
 b[20];   
     int
 j,k;
     j=k=0;   
     while
(n!=0)   
     {
       
              k++;       
              b[k]=n%10;       
              n/=10;   
     }
          
     for
(int i=1;i<=k;i++)   
     {
       
              j*=10;       
              j+=b[i];   

     }
   
     return
 j;   
}
 
int
 main()
{
   
     int
 n,k;
     int
 a[100];       
     while
(scanf("%d",&n)!=EOF)   
     {
       
          k=0;       
          a[0]=n;       
          while
(n!=fan(n))       
          {
           
               n=n+fan(n);           
               a[++k]=n;       
          }
           
          printf("%d\n",k);       
          for
(int i=0;i<k;i++)         
              printf("%d--->",a[i]);       
          printf("%d\n",a[k]);   
     }       
}
   
ps:水题。
posted @ 2012-05-01 17:28 Mr_DaSh 阅读(7) 评论(0) 编辑
1279 验证角谷猜想

验证角谷猜想

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 3239    Accepted Submission(s): 1643


Problem Description
数论中有许多猜想尚未解决,其中有一个被称为“角谷猜想”的问题,该问题在五、六十年代的美国多个著名高校中曾风行一时,这个问题是这样描述的:任何一个大于一的自然数,如果是奇数,则乘以三再加一;如果是偶数,则除以二;得出的结果继续按照前面的规则进行运算,最后必定得到一。现在请你编写一个程序验证他的正确性。
 

 

Input
本题有多个测试数据组,第一行为测试数据组数N,接着是N行的正整数。
 

 

Output
输出验证“角谷猜想”过程中的奇数,最后得到的1不用输出;每个测试题输出一行;每行中只有两个输出之间才能有一个空格;如果没有这样的输出,则输出:No number can be output !。
 

 

Sample Input
4
5
9
16
11
 

 

Sample Output
5
9 7 11 17 13 5
No number can be output !
11 17 13 5
# include <stdio.h>
int main()
{

    int
 t;
    scanf("%d",&t);
    while
(t--)
    {

        int
 n,m,k=0;
        scanf("%d",&n);
        m=n;
        while
(n!=1)
        {

            if
(n%2)
            {

                if
(k==0)printf("%d",n); else printf(" %d",n);
                n=n*3+1;
                k++;
            }

            else

                n=n/2;
        }

        if
(k==0)
            printf("No number can be output !");
        printf("\n");
    }
}
ps:水题,注意输出格式。
posted @ 2012-05-01 17:04 Mr_DaSh 阅读(7) 评论(0) 编辑
1266 Reverse Number

Reverse Number

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 2829    Accepted Submission(s): 1303


Problem Description
Welcome to 2006'4 computer college programming contest!

Specially, I give my best regards to all freshmen! You are the future of HDU ACM! And now, I must tell you that ACM problems are always not so easy, but, except this one... Ha-Ha!

Give you an integer; your task is to output its reverse number. Here, reverse number is defined as follows:
1. The reverse number of a positive integer ending without 0 is general reverse, for example, reverse (12) = 21;
2. The reverse number of a negative integer is negative, for example, reverse (-12) = -21;
3. The reverse number of an integer ending with 0 is described as example, reverse (1200) = 2100.
 

 

Input
Input file contains multiple test cases. There is a positive integer n (n<100) in the first line, which means the number of test cases, and then n 32-bit integers follow.
 

 

Output
For each test case, you should output its reverse number, one case per line.
 

 

Sample Input
3
12
-12
1200
 

 

Sample Output
21
-21
2100
# include <stdio.h>
# include <string.h>
int main()
{
   
     char
 a[100]; 
     int
 t,j;       
     scanf("%d",&t);   
     while
(t--)   
     {
       
          scanf("%s",&a);       
          int
 len=strlen(a);                
          for
(j=len-1;j>=0;j--)          
          if
(a[j]!='0')break;       
          if
(a[0]=='-')       
          {
          
              printf("-");           
              for
(int i=j;i>=1;i--)             
                  printf("%c",a[i]);           
              for
(int i=j+1;i<len;i++)             
                  printf("0");       
          }
           
          else
       
          {
           
              for
(int i=j;i>=0;i--)             
                  printf("%c",a[i]);           
              for
(int i=j+1;i<len;i++)             
                  printf("0");       
          }
           
          printf("\n");   
     } 
}
  
ps:不能用整型。
posted @ 2012-05-01 16:11 Mr_DaSh 阅读(8) 评论(0) 编辑
1236 排名

排名

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 9516    Accepted Submission(s): 3557


Problem Description
今天的上机考试虽然有实时的Ranklist,但上面的排名只是根据完成的题数排序,没有考虑
每题的分值,所以并不是最后的排名。给定录取分数线,请你写程序找出最后通过分数线的
考生,并将他们的成绩按降序打印。
 

 

Input
测试输入包含若干场考试的信息。每场考试信息的第1行给出考生人数N ( 0 < N
< 1000 )、考题数M ( 0 < M < = 10 )、分数线(正整数)G;第2行排序给出第1题至第M题的正整数分值;以下N行,每行给出一
名考生的准考证号(长度不超过20的字符串)、该生解决的题目总数m、以及这m道题的题号
(题目号由1到M)。
当读入的考生人数为0时,输入结束,该场考试不予处理。
 

 

Output
对每场考试,首先在第1行输出不低于分数线的考生人数n,随后n行按分数从高
到低输出上线考生的考号与分数,其间用1空格分隔。若有多名考生分数相同,则按他们考
号的升序输出。
 

 

Sample Input
4 5 25
10 10 12 13 15
CS004 3 5 1 3
CS003 5 2 4 1 3 5
CS002 2 1 2
CS001 3 2 3 5
1 2 40
10 30
CS001 1 2 2 3 20 10 10 10
CS000000000000000001 0
CS000000000000000002 2 1 2 0
 

 

Sample Output
3
CS003 60
CS001 37
CS004 37
0
1
CS000000000000000002 20
# include <stdlib.h>
# include <stdio.h>
# include <string.h>
struct node
{

    char
 name[30];
    int
 count;
}
t[1005];
int
 cmp(const void * a,const void * b)
{

node *= (node *)a;
node *= (node *)b;
if
(c->count!= d->count) return d->count - c->count;
else
      return
 strcmp(c->name,d->name);
}


int
 main()
{

     int
 m,n,g,num[11],sum,c,x,k;
     while
(scanf("%d",&n),n)
     {

          k= 0;
          scanf("%d%d",&m,&g);
          for
(int i= 0;i<m;i++)
             scanf("%d",&num[i]);
          for
(int i= 0;i<n;i++)
          {

              scanf("%s",t[i].name);
              scanf("%d",&c);
              sum=0;
              for
(int j=0;j<c;j++)
              {

                  scanf("%d",&x);
                  sum += num[x-1];
              }

              if
(sum >= g)
              k++;
              t[i].count=sum;
          }

          qsort(t,n,sizeof(t[0]),cmp);
          printf("%d\n",k);
          for
(int i=0; i<k;i++)
                printf("%s %d\n",t[i].name,t[i].count);
     }
}

ps:结构体排序。
posted @ 2012-05-01 15:45 Mr_DaSh 阅读(4) 评论(0) 编辑
1235 统计同成绩学生人数

统计同成绩学生人数

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 8547    Accepted Submission(s): 5040


Problem Description
读入N名学生的成绩,将获得某一给定分数的学生人数输出。
 

 

Input
测试输入包含若干测试用例,每个测试用例的格式为


第1行:N
第2行:N名学生的成绩,相邻两数字用一个空格间隔。
第3行:给定分数

当读到N=0时输入结束。其中N不超过1000,成绩分数为(包含)0到100之间的一个整数。
 

 

Output
对每个测试用例,将获得给定分数的学生人数输出。
 

 

Sample Input
3
80 60 90
60
2
85 66
0
5
60 75 90 55 75 75
0
 

 

Sample Output
1
0
2
# include <stdio.h>
int a[1005];
int
 main()
{

    int
 n;
    while
(scanf("%d",&n),n)
    {

        int
 m,sum=0;
        for
(int i=0;i<n;i++)
            scanf("%d",&a[i]);
        scanf("%d",&m);
        for
(int i=0;i<n;i++)
            if
(m==a[i])sum++;
        printf("%d\n",sum);
    }
}
ps:不想刷水题了。
 
posted @ 2012-05-01 15:01 Mr_DaSh 阅读(7) 评论(0) 编辑
1219 AC Me

AC Me

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 6844    Accepted Submission(s): 3067


Problem Description
Ignatius is doing his homework now. The teacher gives him some articles and asks him to tell how many times each letter appears.

It's really easy, isn't it? So come on and AC ME.
 

 

Input
Each article consists of just one line, and all the letters are in lowercase. You just have to count the number of each letter, so do not pay attention to other characters. The length of article is at most 100000. Process to the end of file.

Note: the problem has multi-cases, and you may use "while(gets(buf)){...}" to process to the end of file.
 

 

Output
For each article, you have to tell how many times each letter appears. The output format is like "X:N".

Output a blank line after each test case. More details in sample output.
 

 

Sample Input
hello, this is my first acm contest!
work hard for hdu acm.
 

 

Sample Output
a:1
b:0
c:2
d:0
e:2
f:1
g:0
h:2
i:3
j:0
k:0
l:2
m:2
n:1
o:2
p:0
q:0
r:1
s:4
t:4
u:0
v:0
w:0
x:0
y:1
z:0
a:2
b:0
c:1
d:2
e:0
f:1
g:0
h:2
i:0
j:0
k:1
l:0
m:1
n:0
o:2
p:0
q:0
r:3
s:0
t:0
u:1
v:0
w:1
x:0
y:0
z:0
# include <stdio.h>
# include <string.h>
char s[100001];
int
 a[26];
int
 main()
{

    int
 len;
    while
(gets(s))
    {

       memset(a,0,sizeof(a));
       len=strlen(s);
    for
(int i=0;i<len;i++)
         {

          if
(s[i]>='a' && s[i]<='z')
             a[(int)s[i]-'a']++;
         }

    for
(int i=0;i<26;i++)
        printf("%c:%d\n",i+'a',a[i]);
    printf("\n");    
    }
}
ps:水题。
posted @ 2012-05-01 14:53 Mr_DaSh 阅读(7) 评论(0) 编辑
1205 吃糖果

吃糖果

Time Limit: 6000/3000 MS (Java/Others)    Memory Limit: 65535/32768 K (Java/Others)
Total Submission(s): 10206    Accepted Submission(s): 2959


Problem Description
HOHO,终于从Speakless手上赢走了所有的糖果,是Gardon吃糖果时有个特殊的癖好,就是不喜欢将一样的糖果放在一起吃,喜欢先吃一种,下一次吃另一种,这样;可是Gardon不知道是否存在一种吃糖果的顺序使得他能把所有糖果都吃完?请你写个程序帮忙计算一下。
 

 

Input
第一行有一个整数T,接下来T组数据,每组数据占2行,第一行是一个整数N(0<N<=1000000),第二行是N个数,表示N种糖果的数目Mi(0<Mi<=1000000)。
 

 

Output
对于每组数据,输出一行,包含一个"Yes"或者"No"。
 

 

Sample Input
2
 
3
4 1 1
5
5 4 3 2 1
 

 

Sample Output
No
Yes
# include <stdio.h> 
int main() 
{
 
    int
 max,i,j,m,x,n; 
    __int64
 sum;
    scanf("%d",&n); 
    for
(i=0;i<n;i++) 
    {
 
        sum=0; 
        max=0; 
        scanf("%d",&m); 
        for
(j=0;j<m;j++) 
        {
 
            scanf("%d",&x); 
            sum=sum+x; 
            if
(x>max)max=x
        }
 
        sum=sum-max; 
        if
(max<=sum+1) 
            printf("Yes\n");  
        else
 
            printf("No\n"); 
    }  
}
 
ps“水题。
posted @ 2012-05-01 04:24 Mr_DaSh 阅读(10) 评论(0) 编辑
1202 The calculation of GPA

The calculation of GPA

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 11432    Accepted Submission(s): 2643


Problem Description
每学期的期末,大家都会忙于计算自己的平均成绩,这个成绩对于评奖学金是直接有关的。国外大学都是计算GPA(grade point average) 又称GPR(grade point ratio),即成绩点数与学分的加权平均值来代表一个学生的成绩的。那么如何来计算GPA呢?

一般大学采用之计分法

A90 - 100 4 点
B80 - 89 3 点
C70 - 79 2 点
D60 - 69 1 点
E0 - 59 0 点

例如:某位学生修习三门课,其课目、学分及成绩分别为:
英文:三学分、92 分;化学:五学分、80 分;数学:二学分、60分,则GPA的算法如下:

科目 学分 分数 点数 分数×点数 
英文  3    92    4     12
化学  5    80    3     15
数学  2    60    1      2
合计  10   29
29/10=2.9
2.9即为某生的GPA
下面有请你写一个用于计算GPA的程序。
 

 

Input
包含多组数据,每组数据的第一行有一个数N,接下来N行每行表示一门成绩。每行有两个实型的数 s,p,s表示这门课的学分,p表示该学生的成绩(百分制)。如果p=-1则说明该学生这门课缺考,是不应该计算在内的。
 

 

Output
对每组数据输出一行,表示该学生的GPA,保留两位小数。如果GPA不存在,输出-1。
 

 

Sample Input
3
3 92
5 80
2 60
 

 

Sample Output
2.90
# include <stdio.h>
int main()
{

    int
 t;
    while
(scanf("%d",&t)!=EOF)
    {

        double
 sum1=0.0,sum2=0.0;
        while
(t--)
        {

            double
 s,p;
            scanf("%lf%lf",&s,&p);
            if
(p==-1)
               continue
;
            sum1+=s;
            if
(p>=90) sum2+=s*4;
            else if
(p>=80) sum2+=s*3;
            else if
(p>=70) sum2+=s*2;
            else if
(p>=60) sum2+=s*1;
            else
 sum2+=s*0;
        }

        if
(sum2==0) 
            printf("-1\n");
        else

            printf("%.2lf\n",sum2/sum1);
    }
}
ps:水水。
posted @ 2012-05-01 04:15 Mr_DaSh 阅读(11) 评论(0) 编辑
1201 18岁生日

18岁生日

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 9732    Accepted Submission(s): 3079


Problem Description
Gardon的18岁生日就要到了,他当然很开心,可是他突然想到一个问题,是不是每个人从出生开始,到达18岁生日时所经过的天数都是一样的呢?似乎并不全都是这样,所以他想请你帮忙计算一下他和他的几个朋友从出生到达18岁生日所经过的总天数,让他好来比较一下。
 

 

Input
一个数T,后面T行每行有一个日期,格式是YYYY-MM-DD。如我的生日是1988-03-07。
 

 

Output
T行,每行一个数,表示此人从出生到18岁生日所经过的天数。如果这个人没有18岁生日,就输出-1。
 

 

Sample Input
1
1988-03-07
 

 

Sample Output
6574
#include<stdio.h>

int
 judge(int y)
{

    if
(y%4==0&&(y%100!=0||y%400==0))return 1;
    return
 0;
}


int
 main()
{

    int
 t;
    int
 y,m,d;
    int
 date;
    scanf("%d",&t);
    while
(t--)
    {

        date=18*365;
        scanf("%d-%d-%d",&y,&m,&d);
        if
(!judge(y+18)&&m==2&&d==29)
        {

            printf("-1\n"); continue;
        }

        if
(judge(y)&&(m<2||(m==2&&d<=28)))
            date++;
        if
(judge(y+18)&&(m>2||(m==2&&d==29)))
            date++;

        for
(int i=y+1;i<=y+17;i++)
        {

            if
(judge(i))date++;
        }


        printf("%d\n",date);
    }

    return
 0;
}

ps:水题。
posted @ 2012-05-01 04:03 Mr_DaSh 阅读(9) 评论(0) 编辑
1200 To and Fro

To and Fro

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 2725    Accepted Submission(s): 1931


Problem Description
Mo and Larry have devised a way of encrypting messages. They first decide secretly on the number of columns and write the message (letters only) down the columns, padding with extra random letters so as to make a rectangular array of letters. For example, if the message is “There’s no place like home on a snowy night” and there are five columns, Mo would write down

t o i o y
h p k n n
e l e a i
r a h s g
e c o n h
s e m o t
n l e w x


Note that Mo includes only letters and writes them all in lower case. In this example, Mo used the character ‘x’ to pad the message out to make a rectangle, although he could have used any letter.

Mo then sends the message to Larry by writing the letters in each row, alternating left-to-right and right-to-left. So, the above would be encrypted as

toioynnkpheleaigshareconhtomesnlewx

Your job is to recover for Larry the original message (along with any extra padding letters) from the encrypted one.
 

 

Input
There will be multiple input sets. Input for each set will consist of two lines. The first line will contain an integer in the range 2. . . 20 indicating the number of columns used. The next line is a string of up to 200 lower case letters. The last input set is followed by a line containing a single 0, indicating end of input.
 

 

Output
Each input set should generate one line of output, giving the original plaintext message, with no spaces.
 

 

Sample Input
5
toioynnkpheleaigshareconhtomesnlewx
3
ttyohhieneesiaabss
0
 

 

Sample Output
theresnoplacelikehomeonasnowynightx
thisistheeasyoneab
# include <stdio.h>
# include <string.h>
int main()
{

    int
 k,n,len;
    char
 str[10000],s[105][105];
    while
(scanf("%d",&n),n)
    {

         scanf("%s",&str);
         len=strlen(str);
         k=0;
         for
(int i=0;i<len/n;i++)
         {

              if
(i%2==0)
              {
 
                   for
(int j=0;j<n;j++)
                      s[i][j]=str[k++];
              }

              else
 
              {
 
                   for
(int j=n-1;j>=0;j--)
                       s[i][j]=str[k++];
              }
         }

         for
(int j=0;j<n;j++)
         {
 
              for
(int i=0;i<len/n;i++)
                  printf("%c",s[i][j]);
         }

         printf("\n");
    }
}
ps:水题。
posted @ 2012-05-01 03:58 Mr_DaSh 阅读(15) 评论(0) 编辑
1196 Lowest Bit

Lowest Bit

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 4502    Accepted Submission(s): 3253


Problem Description
Given an positive integer A (1 <= A <= 100), output the lowest bit of A.

For example, given A = 26, we can write A in binary form as 11010, so the lowest bit of A is 10, so the output should be 2.

Another example goes like this: given A = 88, we can write A in binary form as 1011000, so the lowest bit of A is 1000, so the output should be 8.
 

 

Input
Each line of input contains only an integer A (1 <= A <= 100). A line containing "0" indicates the end of input, and this line is not a part of the input data.
 

 

Output
For each A in the input, output a line containing only its lowest bit.
 

 

Sample Input
26
88
0
 

 

Sample Output
2
8
# include <stdio.h>
int a[1000005];
int
 main()
{

    int
 n,k,j,m;
    while
(scanf("%d",&n),n)
    {

        m=1;
        int
 i=0;
        while
(n)
        {

           a[i]=n%2;
           n=n/2;
           i++;
        }

        for
(j=0;j<i;j++)
            if
(a[j]==1)break;
        for
(int k=0;k<j;k++)
            m*=2;
        printf("%d\n",m);
    }
}
ps:水题。
posted @ 2012-05-01 03:09 Mr_DaSh 阅读(22) 评论(0) 编辑
1194 Beat the Spread!

Beat the Spread!

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 2444    Accepted Submission(s): 1266


Problem Description
Superbowl Sunday is nearly here. In order to pass the time waiting for the half-time commercials and wardrobe malfunctions, the local hackers have organized a betting pool on the game. Members place their bets on the sum of the two final scores, or on the absolute difference between the two scores.

Given the winning numbers for each type of bet, can you deduce the final scores?
 

 

Input
The first line of input contains n, the number of test cases. n lines follow, each representing a test case. Each test case gives s and d, non-negative integers representing the sum and (absolute) difference between the two final scores.
 

 

Output
For each test case, output a line giving the two final scores, largest first. If there are no such scores, output a line containing "impossible". Recall that football scores are always non-negative integers.
 

 

Sample Input
2
40 20
20 40
 

 

Sample Output
30 10
impossible
# include <stdio.h>    
# include <string.h>  
int main() 
{
 
    int
 n,m,t; 
    scanf("%d",&t); 
    while
(t--) 
    {
 
        scanf("%d%d",&n,&m); 
       if
(n<m||(n+m)%2) 
            printf("impossible\n"); 
        else
 
            printf("%d %d\n",(n+m)/2,(n-m)/2); 
    }   
}
 
ps:当练手了。
posted @ 2012-05-01 02:56 Mr_DaSh 阅读(10) 评论(0) 编辑
1157 Who's in the Middle

Who's in the Middle

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 4424    Accepted Submission(s): 2231


Problem Description
FJ is surveying his herd to find the most average cow. He wants to know how much milk this 'median' cow gives: half of the cows give as much or more than the median; half give as much or less.

Given an odd number of cows N (1 <= N < 10,000) and their milk output (1..1,000,000), find the median amount of milk given such that at least half the cows give the same amount of milk or more and at least half give the same or less.
 

 

Input
* Line 1: A single integer N

* Lines 2..N+1: Each line contains a single integer that is the milk output of one cow.
 

 

Output
* Line 1: A single integer that is the median milk output.
 

 

Sample Input
5
2
4
1
3
5
 

 

Sample Output
3
# include <stdio.h>
# include <stdlib.h>
int s[10005];
int
 cmp(const void *a,const void *b)
{

    return
 *(int *)a-*(int *)b;
}

int
 main()
{

    int
 n;
    while
(scanf("%d",&n)!=EOF)
    {

        for
(int i=0;i<n;i++)
            scanf("%d",&s[i]);
        qsort(s,n,sizeof(s[0]),cmp);
        printf("%d\n",s[n/2]);
    }
}
ps:水水更健康。
posted @ 2012-05-01 02:16 Mr_DaSh 阅读(33) 评论(0) 编辑
1106 排序

排序

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 20257    Accepted Submission(s): 5304


Problem Description
输入一行数字,如果我们把这行数字中的‘5’都看成空格,那么就得到一行用空格分割的若干非负整数(可能有些整数以‘0’开头,这些头部的‘0’应该被忽略掉,除非这个整数就是由若干个‘0’组成的,这时这个整数就是0)。

你的任务是:对这些分割得到的整数,依从小到大的顺序排序输出。

 

 

Input
输入包含多组测试用例,每组输入数据只有一行数字(数字之间没有空格),这行数字的长度不大于1000。  

输入数据保证:分割得到的非负整数不会大于100000000;输入数据不可能全由‘5’组成。
 

 

Output
对于每个测试用例,输出分割得到的整数排序的结果,相邻的两个整数之间用一个空格分开,每组输出占一行。
 

 

Sample Input
0051231232050775
 

 

Sample Output
0 77 12312320
 # include <stdio.h>
# include <string.h>
# include <stdlib.h>
int cmp(const void *,const void *b)
{

    return
 *(int *)- *(int *)b;
}

int
 main()
{

    char
 str[10005];
    char
 s[10005];
    int
 num[10005],j,k,m;
    while
(scanf("%s",str)!=EOF)
    {

        j=k= 0 ;
        m=strlen(str);
        str[m]='5';
        str[++m]='\0';
        for
(int i=0;i<m;i++)
        {

            if
(str[i]!='5')
                s[j++]=str[i];
            else

            {

                s[j]='\0';
                if
(s[j-1]!='\0')
                    num[k++]=atoi(s);
                j=0;
            }
        }

        qsort(num,k,sizeof(num[0]),cmp);
        for
(int i=0;i<k-1;i++)
             printf("%d ",num[i]);
        printf("%d\n",num[k-1]);
    }
}
posted on 2014-10-04 17:22  Unico  阅读(394)  评论(0)    收藏  举报