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:同学那转过来的。
最简单的计算机
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 2480 Accepted Submission(s): 1441
命令A:将内存M1的数据装到寄存器R1中;
命令B:将内存M2的数据装到寄存器R2中;
命令C:将寄存器R3的数据装到内存M1中;
命令D:将寄存器R3的数据装到内存M2中;
命令E:将寄存器R1中的数据和寄存器R2中的数据相加,结果放到寄存器R3中;
命令F:将寄存器R1中的数据和寄存器R2中的数据相减,结果放到寄存器R3中。
你的任务是:设计一个程序模拟PpMm的运行。
其他说明:R1,R2,R3的初始值为0,所有中间结果都在-2^31和2^31之间。
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);
}
}
回文数猜想
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 2144 Accepted Submission(s): 1310
特别说明:输入的数据保证中间结果小于2^31。
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]);
}
}
验证角谷猜想
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 3239 Accepted Submission(s): 1643
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");
}
}
Reverse Number
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 2829 Accepted Submission(s): 1303
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.
# 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");
}
}
排名
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 9516 Accepted Submission(s): 3557
每题的分值,所以并不是最后的排名。给定录取分数线,请你写程序找出最后通过分数线的
考生,并将他们的成绩按降序打印。
< 1000 )、考题数M ( 0 < M < = 10 )、分数线(正整数)G;第2行排序给出第1题至第M题的正整数分值;以下N行,每行给出一
名考生的准考证号(长度不超过20的字符串)、该生解决的题目总数m、以及这m道题的题号
(题目号由1到M)。
当读入的考生人数为0时,输入结束,该场考试不予处理。
到低输出上线考生的考号与分数,其间用1空格分隔。若有多名考生分数相同,则按他们考
号的升序输出。
# include <stdio.h>
# include <string.h>
struct node
{
char name[30];
int count;
}t[1005];
int cmp(const void * a,const void * b)
{
node *c = (node *)a;
node *d = (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:结构体排序。
统计同成绩学生人数
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 8547 Accepted Submission(s): 5040
第1行:N
第2行:N名学生的成绩,相邻两数字用一个空格间隔。
第3行:给定分数
当读到N=0时输入结束。其中N不超过1000,成绩分数为(包含)0到100之间的一个整数。
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);
}
}
AC Me
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 6844 Accepted Submission(s): 3067
It's really easy, isn't it? So come on and AC ME.
Note: the problem has multi-cases, and you may use "while(gets(buf)){...}" to process to the end of file.
Output a blank line after each test case. More details in sample output.
# 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");
}
}
吃糖果
Time Limit: 6000/3000 MS (Java/Others) Memory Limit: 65535/32768 K (Java/Others)
Total Submission(s): 10206 Accepted Submission(s): 2959
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");
}
}
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
一般大学采用之计分法
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的程序。
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);
}
}
18岁生日
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 9732 Accepted Submission(s): 3079
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:水题。
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
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.
# 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");
}
}
Lowest Bit
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 4502 Accepted Submission(s): 3253
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.
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);
}
}
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
Given the winning numbers for each type of bet, can you deduce the final scores?
# 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);
}
}
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
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.
* Lines 2..N+1: Each line contains a single integer that is the milk output of one cow.
# 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]);
}
}
排序
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 20257 Accepted Submission(s): 5304
你的任务是:对这些分割得到的整数,依从小到大的顺序排序输出。
输入数据保证:分割得到的非负整数不会大于100000000;输入数据不可能全由‘5’组成。
# include <string.h>
# include <stdlib.h>
int cmp(const void *a ,const void *b)
{
return *(int *)a - *(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]);
}
}
浙公网安备 33010602011771号