ACM大赛原题目
acm数学竞赛试题
acm数学竞赛试题
ACM数学竞赛试题通常涉及各种数学领域,包括但不限于代数、几何、概率统计和组合数学等。
以下是一些经典的ACM数学竞赛试题:
1. 平面上n个点的k距离和最小值问题:给定平面上n个点,对于每个点,计算它到其他所有点的距离,然后求出这些距离中的k个最小值。
问题是:如何有效地计算这k个最小值?
2.最长公共子序列问题:给定两个序列,找出它们的最长公共子序列。
例如,对于序列
A = [1, 2, 3, 4] 和
B = [2, 3, 4, 5],最长公共子序列是[2, 3, 4]。
3. 凸包问题:给定平面上的一组点,找到一个最小的凸多边形,使得这个多边形能够包含这组点中的所有点。
4. 最短路问题:给定一个有向图,其中每条边都有一个非负的权重,找出图中任意两点之间的最短路径。
5. 子集和问题:给定一个正整数数组和一个目标值,判断数组中是否存在和为目标值的两个非空子集。
例如,给定数组[1, 2, 3, 4] 和目标值7,判断是否存在两个子集,它们的和分别为7。
以上只是ACM数学竞赛试题的一部分,实际上还有更多涉及数学各个领域的题目。
要提高解决这类问题的能力,需要不断练习和研究。
计算机acm试题及答案
计算机acm试题及答案一、选择题1. 在计算机科学中,ACM代表什么?A. 人工智能与机器学习B. 计算机辅助制造C. 计算机辅助设计D. 国际计算机学会答案:D2. 下列哪个不是计算机程序设计语言?A. PythonB. JavaC. C++D. HTML答案:D3. 在计算机系统中,CPU代表什么?A. 中央处理单元B. 计算机辅助设计C. 计算机辅助制造D. 计算机辅助教学答案:A二、填空题1. 计算机的内存分为__________和__________。
答案:RAM;ROM2. 在编程中,__________是一种用于存储和操作数据的数据结构。
答案:数组3. 计算机病毒是一种__________,它能够自我复制并传播到其他计算机系统。
答案:恶意软件三、简答题1. 请简述计算机操作系统的主要功能。
答案:计算机操作系统的主要功能包括管理计算机硬件资源,提供用户界面,运行应用程序,以及控制其他系统软件和应用软件的运行。
2. 什么是云计算,它与传统的本地计算有何不同?答案:云计算是一种通过互联网提供计算资源(如服务器、存储、数据库、网络、软件等)的服务模式。
与传统的本地计算相比,云计算允许用户按需获取资源,无需购买和维护物理硬件,具有更高的灵活性和可扩展性。
四、编程题1. 编写一个程序,计算并输出从1到100(包括1和100)之间所有偶数的和。
答案:```pythonsum = 0for i in range(1, 101):if i % 2 == 0:sum += iprint(sum)```2. 给定一个字符串,编写一个函数,将字符串中的所有字符按ASCII 码值排序并返回。
答案:```pythondef sort_string(s):return ''.join(sorted(s))```五、论述题1. 论述计算机硬件和软件之间的关系及其对计算机系统性能的影响。
答案:计算机硬件是计算机系统的物质基础,包括CPU、内存、硬盘等,而软件则是运行在硬件上的程序和数据。
acm程序设计大赛试题
acm程序设计大赛试题ACM(Association for Computing Machinery)程序设计大赛是一项面向大学生的编程竞赛,旨在提高参赛者在算法和数据结构方面的能力。
每年都会举办多个级别的比赛,包括区域赛、国家赛和世界总决赛。
ACM程序设计大赛试题通常涵盖广泛的计算机科学和编程知识,包括但不限于以下几个方面:1. 算法和数据结构,试题可能涉及各种经典算法和数据结构的应用,如排序、查找、图论、动态规划、贪心算法等。
参赛者需要能够理解这些算法的原理和实现方法,并能够根据问题的要求选择合适的算法进行解题。
2. 编程语言和编程技巧,参赛者需要熟练掌握至少一种编程语言,通常是C++、Java或Python。
他们需要能够使用该语言进行编程,实现算法和数据结构的代码,并能够处理输入输出、异常处理等编程任务。
此外,熟练掌握一些编程技巧,如优化算法、调试代码等也是非常重要的。
3. 数学和逻辑思维,ACM程序设计大赛试题可能涉及一些数学和逻辑问题,如数论、组合数学、概率统计等。
参赛者需要具备基本的数学知识,并能够将其应用到解题过程中。
4. 实际问题的建模和解决,ACM程序设计大赛试题通常基于实际问题,参赛者需要能够将问题抽象为计算机可解决的形式,并设计出高效的算法和数据结构进行求解。
这需要参赛者具备一定的问题建模和解决能力。
5. 时间和空间复杂度分析,参赛者在解决问题时需要考虑算法的时间和空间复杂度。
他们需要能够分析算法的运行时间和所需内存,并根据比赛规则和问题要求选择合适的算法以保证程序的效率。
总的来说,ACM程序设计大赛试题要求参赛者具备扎实的计算机科学和编程基础,能够独立思考和解决复杂的问题。
参赛者需要在规定的时间内完成试题,并保证程序的正确性和效率。
通过参加ACM程序设计大赛,参赛者能够提升自己的编程能力和解决问题的能力,同时也能够与其他优秀的程序员交流和学习。
河南省第四届ACM程序设计大赛原题
所有题目时间限制:1秒【T1】序号互换Dr.Kong 设计了一个聪明的机器人卡多,卡多会对电子表格中的单元格坐标快速计算出来。
单元格的行坐标是由数字编号的数字序号,而列坐标使用字符序号。
观察字母序号,发现第1列到第26列的字母序号分别为A,B,……,Z,接着,第27列序号为AA,第28列为AB,以此类推。
若给Dr.Kong的机器人卡多一个数字序号(比如32),它能很快算出等价的字母序号(即AF),若给机器人一个字母序号(比如AA),它也能很快算出等价的数字序号(27),你能不能与卡多比试比试,看谁能算得更快更准。
【标准输入】第一行:N 表示有多少组测试数据。
接下来N行,每行或者是一个正整数,或者是一个仅由大写字母组成的字符串。
【标准输出】对于每一行测试数据,输出一行。
如果输入为一个正整数序号,则输出等价的字母序号;如果输入为字符串,则输出等价的数字序号。
【约束条件】输入保证,所有数字序号和字母序号对应的数字序号均<=2*10^9【样例】【T2】节能Dr.kong 设计的机器人卡多越来越聪明。
最近市政府公司交给卡多一项任务,每天早晨5:00开始,它负责关掉ZK大道右侧上的所有路灯。
卡多每到早晨5:00准会在ZK大道上某盏灯的旁边,然后他开始关灯。
每盏灯都有一定的功率,机器人卡多有自觉的节能意识,它希望在关灯期间,ZK大道右侧上所有的路灯的耗电总量数是最少的。
机器人卡多以1m/s的速度行走。
假设关灯动作不需要花费额外的时间,因为当它通过某盏路灯时就顺手将灯关掉。
请编写程序,计算在给定路灯设置,灯泡功率以及机器人卡多的起始位置的情况下,卡多关灯期间,Zk大道上所有灯耗费的最小能量。
【标准输入】第一行N 表示ZK大道右侧路灯的数量(2<=N<=1000)第二行V 表示机器人卡多开始关灯的路灯号。
(1<=V<=N)接下来的N行中,每行包含两个空格隔开的整数D和W,用来描述每盏灯的参数D表示该路灯与ZK大道起点的距离(用米为单位来表示)W表示灯泡的功率,即每秒该灯泡所消耗的能量数。
acm程序设计大赛试题
acm程序设计大赛试题题目:旅游管理系统一、问题描述随着信息技术的飞速发展,旅游业作为全球经济的重要组成部分,其管理和服务水平也在不断提升。
为了更好地服务游客,提高工作效率,我们计划开发一个旅游管理系统。
该系统旨在帮助旅游公司管理客户信息、行程安排、预订情况以及费用结算等业务。
本文将详细介绍该系统的设计要求和功能特点。
二、功能需求1. 客户信息管理系统应能够记录客户的基本信息,包括姓名、联系方式、身份证号码等。
同时,应支持对客户信息的增加、修改和查询功能。
此外,系统还应具备客户信息的分类和统计功能,便于旅游公司对客户群体进行分析。
2. 行程安排旅游公司需要根据客户需求和旅游资源情况,为客户制定合适的旅游行程。
系统应提供行程规划功能,包括景点选择、活动安排、住宿和交通预订等。
同时,系统应能够根据实际情况调整行程,并及时更新相关信息。
3. 预订管理系统应能够处理客户的旅游预订,包括景点门票、酒店房间、交通工具等。
预订管理功能应包括预订的创建、修改、取消和确认等操作,并能够实时更新预订状态,确保信息的准确性。
4. 费用结算旅游费用的结算是旅游管理系统的核心功能之一。
系统应能够根据客户的预订情况和实际消费,自动计算应付费用。
同时,系统还应支持多种支付方式,如信用卡、支付宝、微信支付等,并能够生成详细的费用清单和发票。
5. 数据安全与备份鉴于旅游管理系统中涉及大量敏感信息,系统必须具备严格的数据安全措施。
包括但不限于用户权限管理、数据加密、防止SQL注入等。
此外,系统还应定期进行数据备份,以防数据丢失或损坏。
三、系统架构设计1. 前端设计系统的前端设计应注重用户体验,界面友好、操作简便。
可以使用HTML5、CSS3和JavaScript等技术开发响应式网页,以适应不同设备和屏幕尺寸。
同时,前端应提供丰富的交互功能,如日历选择、地图展示、图片上传等。
2. 后端设计后端设计主要负责处理业务逻辑、数据存储和安全保障。
acm竞赛试题及答案
acm竞赛试题及答案ACM(Association for Computing Machinery)竞赛是一项全球性计算机科学竞赛,旨在锻炼参赛者的问题解决能力和编程技巧。
每年都有数千名来自不同学校的学生参加这一挑战。
本文将提供一些最近的ACM竞赛试题以及相应的答案,帮助读者了解和学习竞赛题目的类型和解题思路。
1. 问题描述给定一个由N个整数组成的数组A,请编写一个程序,找出数组中两个不同元素的差的最小值。
2. 输入格式- 第一行包含一个整数N,表示数组A的长度。
- 第二行包含N个以空格分隔的整数,表示数组A中的元素。
3. 输出格式输出一个整数,表示数组中两个不同元素的差的最小值。
4. 示例输入:51 52 9 12输出:15. 解题思路该问题可以通过对数组进行排序,并比较相邻两个数的差值来求解。
首先,将数组A进行升序排序。
然后,遍历排序后的数组,依次计算相邻两个数的差值,并记录其中的最小值。
最后,返回这个最小差值即可。
6. 代码实现```pythondef min_difference(nums):nums.sort() # 对数组进行升序排序min_diff = float('inf') # 初始化最小差值为正无穷大for i in range(len(nums)-1):diff = abs(nums[i] - nums[i+1]) # 计算相邻两个数的差值min_diff = min(min_diff, diff) # 更新最小差值return min_diff# 输入处理N = int(input())A = list(map(int, input().split()))# 调用函数并输出结果result = min_difference(A)print(result)```7. 答案解析对给定的数组进行排序后,遍历数组计算相邻两个数的差值,并记录其中的最小值。
上述代码中,首先将数组A进行升序排序,然后使用一个变量`min_diff`来记录最小差值。
acm大赛历年程序题
acm大赛历年程序题
ACM大赛是一项计算机竞赛,每年都会发布一系列的程序题供
参赛者解答。
这些题目涵盖了各个计算机科学领域的知识,包括数
据结构、算法、图论、动态规划、数学等等。
以下是一些历年ACM
大赛的程序题的例子:
1. 最短路径问题,给定一个有向带权图,求两个节点之间的最
短路径。
可以使用Dijkstra算法或者Floyd-Warshall算法来解决。
2. 字符串处理问题,给定一个字符串,要求对其进行特定的处理,比如反转、删除重复字符等。
可以使用字符串操作和遍历来解决。
3. 数组操作问题,给定一个数组,要求对其进行特定的操作,
比如排序、查找最大/最小值、计算数组的平均值等。
可以使用排序
算法、查找算法和遍历来解决。
4. 动态规划问题,给定一个问题和一组限制条件,要求找到满
足条件的最优解。
可以使用动态规划的思想,将问题拆分成子问题
并逐步求解。
5. 图论问题,给定一个图,要求对其进行特定的操作,比如查找连通分量、判断是否存在环等。
可以使用图的遍历和深度优先搜索或广度优先搜索来解决。
6. 数学问题,给定一个数学问题,要求求解或验证某个数学定理或公式。
可以使用数学运算和推导来解决。
这些只是一小部分例子,ACM大赛的题目类型非常多样化,每年都会有新的题目发布。
参赛者需要具备扎实的计算机科学基础知识和良好的编程能力,才能在规定时间内解决这些问题。
acm大学生程序设计试题
acm大学生程序设计试题题目一:最大公约数(GCD)题目描述:给定两个正整数,求它们的最大公约数(GCD)。
输入两个正整数a和b(1 <= a, b <= 10^9),求它们的最大公约数。
输入格式:两个正整数,以空格分隔。
输出格式:输出一个整数,表示输入两个正整数的最大公约数。
示例:输入:14 21输出:7思路和分析:最大公约数(GCD)可以使用欧几里得算法来求解,即辗转相除法。
具体的步骤如下:1. 用较大的数除以较小的数,将得到的余数作为新的较大数。
2. 再用新的较大数除以较小数,将得到的余数作为新的较大数。
3. 如此重复,直到两个数可以整除,此时较小的数就是最大公约数。
代码实现:```cpp#include <iostream>using namespace std;int gcd(int a, int b) {if (b == 0)return a;return gcd(b, a % b);}int main() {int a, b;cin >> a >> b;int result = gcd(a, b);cout << result << endl;return 0;}```题目二:字符串反转题目描述:给定一个字符串,要求将其反转并输出。
输入一个字符串s(1 <= |s| <= 1000),输出该字符串的反转结果。
输入格式:一个字符串s,只包含大小写字母和数字。
输出格式:一个字符串,表示输入字符串的反转结果。
示例:输入:HelloWorld123输出:321dlroWolleH思路和分析:字符串反转可以使用双指针的方法来实现。
初始时,左指针指向字符串的开头,右指针指向字符串的末尾,然后交换左右指针所指向的字符,并向中间移动,直到左指针不小于右指针。
代码实现:```cpp#include <iostream>using namespace std;string reverseString(string s) {int left = 0, right = s.length() - 1; while (left < right) {swap(s[left], s[right]);left++;right--;}return s;}int main() {string s;cin >> s;string result = reverseString(s); cout << result << endl;return 0;}```题目三:字符串匹配题目描述:给定一个字符串s和一个模式串p,判断s中是否存在与p相匹配的子串。
大一acm竞赛试题及答案
大一acm竞赛试题及答案一、选择题(每题5分,共20分)1. 下列哪个算法的时间复杂度为O(n^2)?A. 快速排序B. 归并排序C. 插入排序D. 冒泡排序答案:C2. 在C++中,下列哪个关键字用于定义类?A. structB. classC. unionD. enum答案:B3. 下列哪个数据结构适合用于实现稀疏矩阵?A. 顺序存储B. 链式存储C. 压缩存储D. 散列存储答案:C4. 在图论中,下列哪个算法用于寻找最短路径?A. 深度优先搜索B. 广度优先搜索C. 迪杰斯特拉算法D. 弗洛伊德算法二、填空题(每题5分,共20分)1. 在二叉树的遍历算法中,______遍历会先访问根节点。
答案:前序2. 哈希表的冲突解决方法之一是______。
答案:链地址法3. 在数据库中,用于实现一对多关系的表结构是______。
答案:外键4. 动态规划算法的核心是______。
答案:状态转移方程三、编程题(每题30分,共60分)1. 编写一个函数,实现对一个整数数组进行排序,并返回排序后的数组。
答案:```pythondef sort_array(arr):arr.sort()return arr```2. 编写一个函数,实现计算给定整数n的阶乘。
答案:```pythondef factorial(n):if n == 0:return 1return n * factorial(n - 1)```四、算法题(每题30分,共30分)1. 给定一个整数数组,请设计一个算法找出数组中第二大的数。
答案:```pythondef find_second_max(nums):first_max = second_max = float('-inf')for num in nums:if num > first_max:second_max = first_maxfirst_max = numelif num > second_max and num != first_max:second_max = numreturn second_max```。
acm数学竞赛试题及答案
acm数学竞赛试题及答案# 题目一:数列问题问题描述:给定一个数列 \( a_1, a_2, a_3, \ldots, a_n \),数列中每个元素都是正整数,且满足 \( a_i = a_{i-1} + a_{i-2} \) 对于所有\( i \geq 3 \)。
如果 \( a_1 = 1 \) 且 \( a_2 = 1 \),请找出数列的第 \( n \) 项。
解答:根据题意,这是一个斐波那契数列。
第 \( n \) 项的值可以通过递归关系计算得出。
对于 \( n \) 的值,可以使用以下递归公式:\[ a_n = a_{n-1} + a_{n-2} \]其中,\( a_1 = 1 \) 和 \( a_2 = 1 \)。
因此,数列的前几项为 1, 1, 2, 3, 5, 8, 13, 21, ...。
对于任意的 \( n \),可以通过递归或动态规划方法计算出 \( a_n \)。
# 题目二:组合问题问题描述:从 \( n \) 个不同的元素中选择 \( k \) 个元素的所有可能组合的个数是多少?解答:这个问题可以通过组合数学中的二项式系数来解决。
从 \( n \) 个不同元素中选择 \( k \) 个元素的组合数 \( C(n, k) \) 可以用以下公式计算:\[ C(n, k) = \frac{n!}{k!(n-k)!} \]其中,\( n! \) 表示 \( n \) 的阶乘。
# 题目三:几何问题问题描述:在一个直角坐标系中,给定三个点 \( A(x_1, y_1) \),\( B(x_2, y_2) \) 和 \( C(x_3, y_3) \)。
如果 \( \overrightarrow{AB} \) 和 \( \overrightarrow{AC} \) 是垂直的,求证 \( A \) 是直角三角形 \( ABC \) 的直角顶点。
解答:如果 \( \overrightarrow{AB} \) 和 \( \overrightarrow{AC} \) 垂直,那么它们的数量积(点积)应该为零。
河南acm试题及答案
河南acm试题及答案河南ACM试题及答案1. 问题描述编写一个程序,计算给定整数序列中,满足条件的子序列数量。
条件为:子序列中任意两个相邻元素的差的绝对值不超过1。
2. 输入格式第一行包含一个整数N,表示序列的长度,1 <= N <= 100000。
第二行包含N个整数,表示序列中的元素,-1000000 <= 数字 <= 1000000。
3. 输出格式输出满足条件的子序列数量。
4. 样例输入```51 2 3 2 1```5. 样例输出```5```6. 问题分析本题需要对给定的整数序列进行遍历,使用动态规划的方法来计算满足条件的子序列数量。
设dp[i]表示以第i个元素结尾的满足条件的子序列数量,那么dp[i]的值可以通过dp[i-1](当前元素与前一个元素相等或相邻)和dp[i-2](当前元素与前两个元素相邻)计算得出。
7. 算法实现```pythondef countSubsequences(nums):dp = [0] * (len(nums) + 1)dp[0] = 1for i in range(1, len(nums) + 1):for j in range(i):if abs(nums[i-1] - nums[j-1]) <= 1:dp[i] += dp[j]return sum(dp)```8. 测试用例对于样例输入,程序应输出5,表示有5个满足条件的子序列。
9. 注意事项- 确保输入数据的格式正确。
- 考虑边界条件,如序列长度为1时的情况。
- 动态规划数组的大小应根据序列长度动态调整。
Acm试题及答案
Acm试题及答案1001 Sum Problem (2)1089 A+B for In put-Output Practice (I) (3)1090 A+B for In put-Output Practice (II) (4)1091 A+B for In put-Output Practice (III) (6)1092 A+B for Input-Output Practice (IV) (7)1093 A+B for In put-Output Practice (V) 9 1094 A+B for In put-Output Practice (VI) (11)1095 A+B for Input-Output Practice (VII) (12)1096 A+B for In put-Output Practice (VIII) (14)2000 ASCII 码排序 (15)2001计算两点间的距离 (16)2002计算球体积 (17)2003求绝对值 (18)2004成绩转换 (19)2005第几天? (20)2006求奇数的乘积 (22)2007平方和与立方和 (23)2008数值统计 (24)2009求数列的和 (25)2010水仙花数 (27)2011多项式求和 (28)2012素数判定 (29)2014青年歌手大奖赛—评委会打分 (31)2015偶数求和 (32)2016数据的交换输出 (34)2017字符串统计 (35)2019数列有序! (37)2020绝对值排序 (38)2021发工资咯:) (40)2033人见人爱A+B (41)2039三角形 (43)2040亲和数 (44)1001 Sum ProblemProblem Descripti onHey, welcome to HDOJ(Ha ngzhou Dianzi Uni versity On li ne Judge).In this problem, your task is to calculate SUM( n) = 1 + 2 + 3 + ... + n.In putThe in put will con sist of a series of in tegers n, one in teger 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 sig ned in teger.Sample In put1100Sample Output15050AuthorDOOM III解答:#i nclude<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 In put-O utput Practice(I)Problem Descripti onYour task is to Calculate a + b.Too easy?! Of course! I specially desig ned the problem for acm beg inn ers.You must have found that some problems have the same titles with this one, yes, all these problems were desig ned for the same aim.In putThe in put will con sist of a series of pairs of in tegers a and b, separated by a space, one pair of in tegers per line.OutputFor each pair of in put in tegers 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 in put.Sample In put1 510 20Sample Output630AuthorlcyRecomme ndJGShi ning解答:#i nclude<stdio.h>main (){int while printf a , b;(scanf ("%d%d",& a,& b)!= EOF) ("%d\n" , a+b);1090 A+B for In put-Output Practice(II)Problem Descripti onYour task is to Calculate a + b.In putIn put contains an in teger N in the first line, and the n N lines follow. Each line con sists of a pair of in tegers a and b, separated by a space, one pair of in tegers per line.OutputFor each pair of in put in tegers 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 in put.Sample In put21 510 20Sample Output630AuthorlcyRecomme ndJGShi ning解答:#i nclude<stdio.h>#defi ne M 1000void mai n (){int a , b, n, j [ M], i ;//prin tf("please in put n:\n");scanf ("%d",& n);for (i =0; i <n; i ++){scanf ("%d%d",& a,& b);//prin tf("%d %d",a,b);j [ i ]= a+b;}i =0;while{ printf iprintf }}(i <n)("%d" , j [ i ]); ++;("\n");1091 A+B for In put-Output Practice (III)Problem Descripti onYour task is to Calculate a + b.In putIn put contains multiple test cases. Each test case contains a pair of in tegers a and b, one pair of in tegers per line. A test case containing 0 0 term in ates the in put and this test case is not to be processed.OutputFor each pair of in put in tegers 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 in put.Sample In put1 510 200 0Sample Output630AuthorlcyRecomme ndJGShi ning解答:#i nclude<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);}}1092 A+B for Input-Output Practice (IV)Problem Descripti onYour task is to Calculate the sum of some in tegers.In putIn put contains multiple test cases. Each test case contains a in teger N, and the n N in tegers follow in the same line. A test case start ing with 0 term in ates the in put and this test case is not to be processed.OutputFor each group of in put in tegers you should output their sum in one line, and with one line of output for each line in in put.Sample In put4 1 2 3 45 1 2 3 4 5Sample Output1015AuthorlcyRecomme ndJGShi ning解答:#i nclude <stdio.h>int mai n (){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 ;("%d\n" , sum);} printf}1093 A+B for In put-Output Practice (V)Problem Descripti onYour task is to calculate the sum of some in tegers.In putIn put contains an in teger N in the first line, and the n N lines follow. Each line starts with a in teger M, and then M integers follow in the same line.OutputFor each group of in put in tegers you should output their sum in one line, and with one line of output for each line in in put.Sample In put24 1 2 3 45 1 2 3 4 5Sample Output1015Authorlcy解答:#i nclude<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 Descripti onYour task is to calculate the sum of some in tegers.In putIn put contains multiple test cases, and one case one line. Each case starts with an in teger N, and then N integers follow in the same line.OutputFor each test case you should output the sum of N in tegers in one line, and with one line of output for each line in in put.Sample In put4 1 2 3 45 1 2 3 4 5Sample Output1015AuthorlcyRecomme ndJGShi ning解答:#i nclude<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;}}1095 A+B for Input-Output Practice (VII)Problem Descripti onYour task is to Calculate a + b.In putThe in put will con sist of a series of pairs of in tegers a and b, separated by a space, one pair of in tegers per line.OutputFor each pair of in put in tegers a and b you should output the sum of a and b, and followed by a bla nk line.Sample In put1 510 20Sample Output630AuthorlcyRecomme ndJGShi ning解答:#i nclude<stdio.h>main (){int a , b;while (scanf ("%d%d",& a,& b)!= EOF)printf ("%d\n\n" , a+b);}1096 A+B for In put-Output Practice(VIII)Problem Descripti onYour task is to calculate the sum of some in tegers.In putIn put contains an in teger N in the first line, and the n N lines follow. Each line starts with a in teger M, and then M integers follow in the same line.OutputFor each group of in put in tegers you should output their sum in one line, and you must note that there is a bla nk line betwee n outputs.Sample In put34 1 2 3 4Sample Output10156AuthorlcyRecomme ndJGShi ning 解答:int mai n (){a , b, i , j , l [ 1000], k;intscanf ("%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 Descripti on输入三个字符后,按各字符的ASCII码从小到大的顺序输出这三个字符。
ACM软件大赛之编程大赛题目(附部分答案)
ACM软件大赛之编程大赛比赛注意事项:比赛时间为3小时(180分钟);比赛分两个阶段:第一阶段限时30分钟,完成公示的3题,第二阶段限时150分钟(事先完成第一阶段题目的小组可提前进入第二阶段);比赛第一阶段的3道题目将在前期宣传中告知参赛选手,比赛第二阶段的题目将由赛事主席当场公布竞赛题目;前两阶段题目分为三个分值(5分、10分、15分),第一阶段3道公示题都为5分;第二阶段总共15道题,根据不同的难度分值不同,分别为5道5分题,5道10分题,5道15分题;第一阶段参赛队员不可参考任何相关资料;第二阶段参赛队员可以携带诸如书,手册,程序清单等参考资料。
比赛过程中队员不得携带任何电子媒质的资料;参赛者可以选择自己擅长的语言(C,C++,JAVA等等)进行编写考虑到大一和大二学生的知识掌握程度,大一参加选手一开始就会有10分的分数,最后总分是由所做题目及初始的10分相加得到。
每组队员根据安排使用电脑,小组人数为两人的使用一台电脑,超过两人的使用两台电脑,每台的电脑配置完全相同;各小组每做完一题或几题,必须交予评委老师运行,评委老师当场给分;如在比赛中发现作弊等行为,将取消比赛资格。
第一阶段公示题目:题目一:(5分)打印以下图形,纵遵从字母顺序,行字符数遵从斐波那契数列ABCCDDDEEEEEFFFFFFFFGGGGGGGGGGGGG#in clude<iostream> int f(int x){int a = 1 , b = 0; int max_ = x;int sum = 0;for(int i = 0; i < max_ ; i++){ sum = a + b; a = b; b = sum;}return sum;}void loop_print(int num,char chr){for(int i = 0; i < num ;i++) std::cout<<chr;std::cout<<"\n";}int main(){int line_max = 7;char chr = 'A';for(int line = 0; line < line_max; line++){ loop_print(f(line+1),chr); chr++;}return 0;}题目二:(5 分)有个电子钟,12 点显示为12:00(即12 小时制),那么请问一天24 时间内,出现连续相同数字的钟点有几个?#include<iostream>using namespace std;bool check(int time){int h=time/100;int m=time-100*h;return h<=12&&m<=59&&h>0?true:false;//12 小时制}int main(){int time=0;int j(0);// 总计数器while(time<1270){//max 12:59int t=time;int n[4];for(int i=0;i<4;i++){n[i]=t%10;t /= 10;} if(n[1]==n[2]&&(n[0]==n[1]||n[3]==n[1])&&check(time)){//cout<<n[3]<<n[2]<<":"<<n[1]<<n[0]<<"\n";//test j++;} time++;}cout<<"total: "<<j*2 <<endl;}题目三:(5 分)10 进制的四位数中有几个符合如下特征:将其分别表示为16 进制、10 进制、12 进制,在每种状态下,分别将各个位上的数相加,能得到 3 个相等10 进制数。
acm大学生程序试题及答案
acm大学生程序试题及答案1. 题目:字符串反转描述:给定一个字符串,编写一个函数来将字符串中的字符按相反的顺序重新排列。
输入:一个字符串输出:反转后的字符串答案:```pythondef reverse_string(s):return s[::-1]```2. 题目:寻找最大数描述:给定一个整数数组,找出数组中的最大数。
输入:一个整数数组输出:数组中的最大数答案:```pythondef find_max(nums):return max(nums)```3. 题目:两数之和描述:给定一个整数数组和一个目标值,找出数组中和为目标值的两个数的索引(从1开始计数)。
输入:一个整数数组和一个目标值输出:两个数的索引,如果没有则返回空数组答案:```pythondef two_sum(nums, target):num_to_index = {}for i, num in enumerate(nums):complement = target - numif complement in num_to_index:return [num_to_index[complement] + 1, i + 1] num_to_index[num] = ireturn []```4. 题目:无重复字符的最长子串描述:给定一个字符串,请你找出其中不含有重复字符的最长子串的长度。
输入:一个字符串输出:最长子串的长度答案:```pythondef length_of_longest_substring(s):char_map = {}start = max_length = 0for end in range(len(s)):if s[end] in char_map:start = max(start, char_map[s[end]] + 1)char_map[s[end]] = endmax_length = max(max_length, end - start + 1)return max_length```5. 题目:整数转罗马数字描述:将一个整数转换为罗马数字。
ACM题库完整版
if(str[i]>='a'&&str[i]<='z') { str[i]=str[i]-32; } i++;
} puts(str); return 0; }
日历问题
1.题目描述 在我们现在使用的日历中, 闰年被定义为能被4整除的年份,但是能被100整除而不能被400整除的年 是例外,它们不是闰年。例如:1700, 1800, 1900 和 2100 不是闰年,而 1600, 2000 和 2400是闰年。 给定从公元2000年1月1日开始逝去的天数,你的任务是给出这一天是哪年哪月哪日星期几。 2.输入 输入包含若干行,每行包含一个正整数,表示从2000年1月1日开始逝去的天数。输入最后一行是?1, 不必处理。可以假设结果的年份不会超过9999。 3.输出 对每个测试样例,输出一行,该行包含对应的日期和星期几。格式为“YYYY-MM-DD DayOfWeek”, 其中 “DayOfWeek” 必须是下面中的一个: "Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday" 或 "Saturday“。 4.样例输入 1730 1740 1750 1751 -1 5.样例输出 2004-09-26 Sunday 2004-10-06 Wednesday 2004-10-16 Saturday 2004-10-17 Sunday 6.提示 2000.1.1. 是星期六
第六题 acm大赛原题 c、c++语言题目
病毒侵袭持续中Problem Description小 t非常感谢大家帮忙解决了他的上一个问题。
然而病毒侵袭持续中。
在小t 的不懈努力下,他发现了网路中的“万恶之源”。
这是一个庞大的病毒网站,他有着好多好多的病毒,但是这个网站包含的病毒很奇怪,这些病毒的特征码很短,而且只包含“英文大写字符”。
当然小t好想好想为民除害,但是小t从来不打没有准备的战争。
知己知彼,百战不殆,小t首先要做的是知道这个病毒网站特征:包含多少不同的病毒,每种病毒出现了多少次。
大家能再帮帮他吗?Input第一行,一个整数N(1<=N<=1000),表示病毒特征码的个数。
接下来N行,每行表示一个病毒特征码,特征码字符串长度在1—50之间,并且只包含“英文大写字符”。
任意两个病毒特征码,不会完全相同。
在这之后一行,表示“万恶之源”网站源码,源码字符串长度在2000000之内。
字符串中字符都是ASCII码可见字符(不包括回车)。
Output按以下格式每行一个,输出每个病毒出现次数。
未出现的病毒不需要输出。
病毒特征码: 出现次数冒号后有一个空格,按病毒特征码的输入顺序进行输出。
Sample Input3AABBCCooxxCC%dAAAoen....ENDSample OutputAA: 2CC: 1HintHit:题目描述中没有被提及的所有情况都应该进行考虑。
比如两个病毒特征码可能有相互包含或者有重叠的特征码段。
计数策略也可一定程度上从Sample中推测。
acm大赛历年程序题
acm大赛历年程序题ACM国际大学生程序设计竞赛(The ACM International Collegiate Programming Contest)是全球范围内最具声誉的大学生程序设计竞赛之一。
每年都有来自世界各地的顶尖大学参加这一比赛,他们将在规定的时间内解决一系列编程问题,以展示他们的算法和编程技巧。
历年来,ACM大赛的程序题目一直是各个大学的计算机科学学生学习和训练的重要素材。
ACM大赛历年程序题的设计旨在考察参赛者的算法设计与实现能力。
这些问题通常具有一定的难度,涵盖了多种算法和数据结构。
在ACM大赛中,选手需要在规定的时间内,根据给定的输入数据,编写程序解决问题,并输出正确的结果。
ACM大赛历年程序题通常分为多个分类,下面将列举几个常见的分类及其特点:1. 图论问题:图论是ACM大赛中常见的题目类型之一。
这类问题涉及到对图的建模和算法设计。
参赛者需要熟悉常见的图观念和算法,如图的遍历、最短路径、最小生成树等。
2. 动态规划问题:动态规划是ACM大赛中常用的解决问题的方法之一。
动态规划问题通常需要设计状态转移方程,并根据之前已经计算过的结果来推导最优解。
这类问题要求选手具备良好的逻辑思维和数学推导能力。
3. 贪心算法问题:贪心算法是一种简单而高效的算法思想。
贪心算法问题一般需要选手根据问题的特性,每次都选择当前情况下最优的解决方案。
这类问题在实际应用中非常常见,选手需要能够灵活地运用贪心策略解决问题。
4. 字符串处理问题:字符串处理问题涉及到对字符串进行各种操作,如匹配、查找、替换等。
选手需要熟练掌握字符串的各种操作和常见算法,如KMP算法、Boyer-Moore算法等。
5. 数学问题:数学问题在ACM大赛中也是常见的题目类型。
这类问题通常涉及到各种数学公式和算法,如排列组合、素数判定、快速幂等。
选手需要具备扎实的数学知识和计算能力。
ACM大赛历年程序题的学习对于计算机科学学生来说是非常重要的。
国际大学生程序设计大赛(ACMICPC)简介及竞赛样题
附件二国际大学生程序设计大赛(ACM/ICPC)简介相关情况简介一>、历届ACM-ICPC亚洲预选赛中国内地部分赛区参赛情况二>、历届ACM-ICPC全球总决赛中国内地高校获奖情况注:***金牌,**银牌,*铜牌;--表示未参加上一年的地区预赛, / 表示上一年的地区预赛未能出线。
ACM/ICPC大赛简介ACM/ICPC (ACM International Collegiate Programming Contest, 国际大学生程序设计竞赛)是由国际计算机界历史悠久、颇具权威性的组织ACM(Association for Computing Machinery,国际计算机协会)主办的,是世界上公认的规模最大、水平最高的国际大学生程序设计竞赛,是一项旨在展示大学生创新能力、团队精神和在压力下编写程序、分析和解决问题能力的年度竞赛。
其目的旨在使大学生运用计算机来充分展示自己分析问题和解决问题的能力。
该项竞赛从1970年至今已举办了34届,受到国际各知名大学的普遍重视,并受到全世界各著名计算机公司的高度关注,是信息企业与世界顶尖计算机人才对话的最好机会。
ACM国际大学生程序设计竞赛已成为世界各国大学生最具影响力的国际计算机类的赛事,是广大爱好计算机编程的大学生展示才华的舞台,是各个大学计算机教育成果的直接体现。
在过去十几年中,世界著名信息企业APPLE、AT&T、MICROSOFT和IBM分别担任了竞赛的赞助商。
中国大陆高校从1996年开始参加ACM/ICPC亚洲预赛,主要是各个重点院校。
该项竞赛分为区域预赛和国际决赛两个阶段进行,各预赛区第一名自动获得参加世界决赛的资格,世界决赛安排在每年的3~4月举行,而区域预赛安排在上一年的9~12月在各大洲举行。
ACM/ICPC的区域预赛是规模很大、范围很广的赛事,但历届河南省各高校却极少组队参加,为了提升和检验河南省计算机教育水平,河南省计算机学会从2008年开始,在河南省推广开展ACM国际大学生程序设计竞赛,为广大的爱好计算机编程的大学生提供展示才华的舞台,为河南省各高校组队参加ACM/ICPC的区域预赛的提供实战的场地,并以此为契机推动河南省计算机教育水平的提高。
acm试题及答案
acm试题及答案ACM试题及答案试题 1: 给定一个整数数组,请找出数组中第二大的数。
答案:1. 对数组进行排序。
2. 数组排序后,倒数第二个元素即为第二大的数。
试题 2: 编写一个函数,计算给定字符串中字符出现的次数。
答案:```pythondef count_characters(s):count_dict = {}for char in s:if char in count_dict:count_dict[char] += 1else:count_dict[char] = 1return count_dict```试题 3: 判断一个数是否为素数。
答案:1. 如果数小于2,则不是素数。
2. 从2开始到该数的平方根,检查是否有因数。
3. 如果没有因数,则该数是素数。
试题 4: 实现一个算法,将一个整数数组按照奇数在前,偶数在后的顺序重新排列。
答案:```pythondef rearrange_array(arr):odd = []even = []for num in arr:if num % 2 == 0:even.append(num)else:odd.append(num)return odd + even```试题 5: 给定一个链表,删除链表的倒数第n个节点。
答案:1. 遍历链表,找到链表的长度。
2. 再次遍历链表,找到倒数第n个节点的前一个节点。
3. 将前一个节点的next指针指向当前节点的下一个节点。
4. 如果当前节点是头节点,则更新头节点。
试题 6: 编写一个函数,实现字符串反转。
答案:```pythondef reverse_string(s):return s[::-1]```试题 7: 给定一个整数数组,找出数组中没有出现的最小正整数。
答案:1. 遍历数组,使用哈希表记录出现的数字。
2. 从1开始,检查每个数字是否在哈希表中。
3. 第一个不在哈希表中的数字即为答案。
试题 8: 实现一个算法,计算斐波那契数列的第n项。
- 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
- 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
- 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。
一Network of SchoolsTime Limit: 1000MS Memory Limit: 10000KTotal Submissions: 4526 Accepted: 1776 DescriptionA number of schools are connected to a computer network. Agreements have been developed among those schools: each school maintains a list of schools to which it distributes software (the “receiving schools”). Note that ifB is in the distribution list of school A, then A does not necessarily appear in the list of school BYou are to write a program that computes the minimal number of schools that must receive a copy of the new software in order for the software to reach all schools in the network according to the agreement (Subtask A). As a further task, we want to ensure that by sending the copy of new software to an arbitrary school, this software will reach all schools in the network. To achieve this goal we may have to extend the lists of receivers by new members. Compute the minimal number of extensions that have to be made so that whatever school we send the new software to, it will reach all other schools (Subtask B). One extension means introducing one new member into the list of receivers of one school.InputThe first line contains an integer N: the number of schools in the network (2 <= N <= 100). The schools are identified by the first N positive integers. Each of the next N lines describes a list of receivers. The line i+1 contains the identifiers of the receivers of school i. Each list ends with a 0. An empty list contains a 0 alone in the line.OutputYour program should write two lines to the standard output. The first line should contain one positive integer: the solution of subtask A. The second line should contain the solution of subtask B.Sample Input52 43 04 5 01 0Sample Output12二Remmarguts' DateTime Limit: 4000MS Memory Limit: 65536KTotal Submissions: 10811 Accepted: 2944 Description"Good man never makes girls wait or breaks an appointment!" said the mandarin duck father. Softly touching his little ducks' head, he told them a story."Prince Remmarguts lives in his kingdom UDF – United Delta of Freedom. One day their neighboring country sent them Princess Uyuw on a diplomatic mission.""Erenow, the princess sent Remmarguts a letter, informing him that she would come to the hall and hold commercial talks with UDF if and only if the prince go and meet her via the K-th shortest path. (in fact, Uyuw does not want to come at all)"Being interested in the trade development and such a lovely girl, Prince Remmarguts really became enamored. He needs you - the prime minister's help!DETAILS: UDF's capital consists of N stations. The hall is numbered S, while the station numbered T denotes prince' current place. M muddy directed sideways connect some of the stations. Remmarguts' path to welcome the princess might include the same station twice or more than twice, even it is the station with number S or T. Different paths with same length will be considered disparate.InputThe first line contains two integer numbers N and M (1 <= N <= 1000, 0 <= M <= 100000). Stations are numbered from 1 to N. Each of the following M lines contains three integer numbers A, B and T (1 <= A, B <= N, 1 <= T <= 100). It shows that there is a directed sideway from A-th station to B-th station with time T.The last line consists of three integer numbers S, T and K (1 <= S, T <= N, 1 <= K <= 1000).OutputA single line consisting of a single integer number: the length (time required) to welcome Princess Uyuw using the K-th shortest path. If K-th shortest path does not exist, you should output "-1" (without quotes) instead.Sample Input2 21 2 52 1 41 2 2Sample Output14三ChessboardTime Limit: 2000MS Memory Limit: 65536KTotal Submissions: 7406 Accepted: 2306 DescriptionAlice and Bob often play games on chessboard. One day, Alice draws a board with size M * N. She wants Bob to use a lot of cards with size 1 * 2 to cover the board. However, she thinks it too easy to bob, so she makes some holes on the board (as shown in the figure below).We call a grid, which doesn’t contain a hole, a normal grid. Bob has to follow the rules below:1. Any normal grid should be covered with exactly one card.2. One card should cover exactly 2 normal adjacent grids.Some examples are given in the figures below:A VALID solution.An invalid solution, because the hole of red color is covered with a card.An invalid solution, because there exists a grid, which is not covered.Your task is to help Bob to decide whether or not the chessboard can be covered according to the rules above.InputThere are 3 integers in the first line: m, n, k (0 < m, n <= 32, 0 <= K < m * n), the number of rows, column and holes. In the next k lines, there is a pair of integers (x, y) in each line, which represents a hole in the y-th row, the x-th column.OutputIf the board can be covered, output "YES". Otherwise, output "NO".Sample Input4 3 22 13 3Sample OutputYES四RSATime Limit: 3000MS Memory Limit: 65536KTotal Submissions: 2583 Accepted: 490DescriptionRSA is the best-known public key encryption algorithm. In this algorithm each participant has a private key that is shared with no one else and a public key which is published so everyone knows it. To send a secure message to this participant, you encrypt the message using the widely known public key; the participant then decrypts the messages using his or her private key. Here is the procedure of RSA:First, choose two different large prime numbers P and Q, and multiply them to get N (= P * Q).Second, select a positive integer E (0 < E < N) as the encryption key such that E and T= (P - 1) * (Q - 1) are relatively prime.Third, compute the decryption key D such that 0 <= D < T and (E * D) mod T = 1. Here D is a multiplicative inverse of E, modulo T.Now the public key is constructed by the pair {E, N}, and the private key is {D, N}. P and Q can be discarded.Encryption is defined by C = (M ^ E) mod N, and decryption is defined by M = (C ^ D) mod N, here M, which is a non-negative integer and smaller than N, is the plaintext message and C is the resulting ciphertext.To illustrate this idea, let’s see the following example:We choose P = 37, Q = 23, So N = P * Q = 851, and T = 792. If we choose E = 5, D will be 317 ((5 * 317) mod 792 = 1). So the public key is {5, 851}, and the privatekey is {317, 851}. For a given plaintext M = 7, we can get the ciphertext C = (7 ^ 5) mod 851 = 638.As we have known,for properly choosen very large P and Q, it will take thousands of years to break a key, but for small ones, it is another matter.Now you are given the ciphertext C and public key {E, N}, can you find the plaintext M?InputThe input will contain several test cases. Each test case contains three positive integers C, E, N (0 < C < N, 0 < E < N, 0 < N < 2 ^ 62).OutputOutput the plaintext M in a single line.Sample Input638 5 851Sample Output7五A New Operating SystemTime Limit: 20000MS Memory Limit: 65536KTotal Submissions: 669 Accepted: 49Case Time Limit: 5000MSDescriptionMay is a lovely girl. Due to her filial piety, she wants to give a present on hermother's birthday. Because both her parents are the top programmer in the world, she decided to design a new program, a special program that is an Operating System! With the help of her excellent programming skill, May has already finished the kernel of the new OS. And the birthday is coming, she is afraid that time is not enough to finish the entire project in time. As her best net-pal, it's your duty to help her.This is a multitask OS, processes run at the same time. There are following command in the OS:CreateProcess(PID,Memory,Priority)A new process is created with the process identification PID and memory size, and a priority. The priority in this command is called outer priority of a process.AddMessage(PID,Priority)That means, add a new message to the message queue of process PID, with the priority of Priority. The message with higher Priority will run earlier that lower ones. The Priority is called inner priority.RunFind out the message with biggest HP. HP is defined as the product of the inner priority of a message and the corresponding process priority. If two or more messages have the same HP, the one with smallest PID will run first. Print the information "Run: HP" to the output file, HP will be replaced by the message HP you found, or print "Empty" instead if the message queue is empty. Finally remove this message if exist.ChangePriority(PID,NewValue)Change the outer priority of process PID to NewValue.GetMemory(PID,Memory)Process PID memory increases the amount of Memory.FreeMemory(PID,Memory)Process PID memory decreases the amount of Memory.RunProcess(PID)Similar with Run command. Find out the message in the process PID message queue, print the information "Run Process: Priority" to the output file, Priority will be replaced by the message priority you found, or print "Empty" instead if the messagequeue is empty. Finally remove this message if exist.CloseMaxMemoryFind out the process that used the largest number of memory and close it if exists (if tie, the one with smallest PID should be release first), or print "Empty" instead.CloseProcess(PID)Close the process with the identification of PID.Whenever a process' memory is less than or equal to 0, it will be close automatically. In any of the above commands except the first one, if the PID doesn't exist, please print an "Error" to the output. For the first command, if the PID is already exist, print an "Error" and ignore this command.InputFirst line in the input is an integer number N (1 <= N <= 100000), which represents the number of commands. The next N lines, each gives a command described above. Any number given in the input file will be non-negative integer and will not be more than 1000000000.OutputThe output format has been described above.Sample Input11CloseMaxMemoryCreateProcess(1,100,1)CreateProcess(2,200,1)CreateProcess(3,300,1)AddMessage(1,9)AddMessage(2,19)AddMessage(1,10)GetMemory(2,999)CloseMaxMemoryRunRunProcess(1)Sample OutputEmptyRun: 10Run Process: 9六A New Kind of ChessTime Limit: 3000MS Memory Limit: 65536KTotal Submissions: 245 Accepted: 42DescriptionPrince Remmarguts met Uyuw successfully in our previous story, and after that Princess Uyuw introduced a new kind of chess to Remmarguts named Nixgnauhc. The only chessman allowed in it was a special type of Knight.The chessboard is of (N + 1) * (M + 1). Each of the rows and columns are numbered as the following graph:Here N + 1 = 5 + 1 is the number of rows and M + 1 = 4 + 1 is the number of columns. We are also given two integer numbers P and Q, and told that at the beginning of the game, the blocks of (x, y) - (row number, column number) - where x <= P and y <= Q are already taken up by Knight.During the game, we can choose a single Knight to move, and the only allowed movements for Knight at (x, y) is to (x + a, y + b) or to (x + c, y + d). But during the movement, the position it goes must be on the chessboard and NOT be taken up by another Knight. Our purpose is to move that chessman to the final end (N, M). (The description above means that once you choose a chessman, you can only move that chessman in the following steps)Meanwhile, we suppose 3 <= N, M <= 100000, 0 <= P < N, 0 <= Q < M, 1<= a, b, c, d. Princess Uyuw wanted to know the number of essentially different games. Two games are called “different” if and only if we choose the different chessman at the beginning or perform a different movement at some time.WARNING: Even if a = c, b = d, we also call (+a, +b) and (+c, +d) DIFFERENT movements!InputYou should read the number of test cases Z in the first line – Z <= 100.Each of the following lines denotes a single test case, consisting of 8 integers N, M, P, Q, a, b, c, and d. The meanings of such integers are described above.OutputOutput one line per test case, showing the total possibilities of games. We guarantee this number is less than 10^500.Sample Input23 3 0 0 1 1 1 15 4 2 1 1 1 2 1Sample Output87七An Easy ProblemTime Limit: 1000MS Memory Limit: 65536KTotal Submissions: 6197 Accepted: 3631 DescriptionAs we known, data stored in the computers is in binary form. The problem we discuss now is about the positive integers and its binary form.Given a positive integer I, you task is to find out an integer J, which is the minimum integer greater than I, and the number of '1's in whose binary form is the same as that in the binary form of I.For example, if "78" is given, we can write out its binary form, "1001110". This binary form has 4 '1's. The minimum integer, which is greater than "1001110" and also contains 4 '1's, is "1010011", i.e. "83", so you should output "83".InputOne integer per line, which is I (1 <= I <= 1000000).A line containing a number "0" terminates input, and this line need not be processed. OutputOne integer per line, which is J.Sample Input123478Sample Output245883八Uyuw's ConcertTime Limit: 6000MS Memory Limit: 65536KTotal Submissions: 3177 Accepted: 1240 DescriptionPrince Remmarguts solved the CHESS puzzle successfully. As an award, Uyuw planned to hold a concert in a huge piazza named after its great designer Ihsnayish.The piazza in UDF - United Delta of Freedom’s downtown was a square of [0, 10000] * [0, 10000]. Some basket chairs had been standing there for years, but in a terrible mess. Look at the following graph.In this case we have three chairs, and the audiences face the direction as what arrows have pointed out. The chairs were old-aged and too heavy to be moved. Princess Remmarguts told the piazza's current owner Mr. UW, to build a large stage inside it. The stage must be as large as possible, but he should also make sure the audience in every position of every chair would be able to see the stage without turning aside (that means the stage is in the forward direction of their own).To make it simple, the stage could be set highly enough to make sure even thousands of chairs were in front of you, as long as you were facing the stage, you would be able to see the singer / pianist – Uyuw.Being a mad idolater, can you tell them the maximal size of the stage?InputIn the first line, there's a single non-negative integer N (N <= 20000), denoting the number of basket chairs. Each of the following lines contains four floating numbers x1, y1, x2, y2, which means there’s a basket chair on the line segment of (x1, y1) –(x2, y2), and facing to its LEFT (That a point (x, y) is at the LEFT side of this segment means that (x – x1) * (y – y2) – (x – x2) * (y – y1) >= 0).OutputOutput a single floating number, rounded to 1 digit after the decimal point. This is the maximal area of the stage.Sample Input310000 10000 0 500010000 5000 5000 100000 5000 5000 0Sample Output54166666.7九Knight MovesTime Limit: 1000MS Memory Limit: 30000KTotal Submissions: 15129 Accepted: 6765 DescriptionBackgroundMr Somurolov, fabulous chess-gamer indeed, asserts that no one else but him can move knights from one position to another so fast. Can you beat him?The ProblemYour task is to write a program to calculate the minimum number of moves needed for a knight to reach one point from another, so that you have the chance to be faster than Somurolov.For people not familiar with chess, the possible knight moves are shown in Figure 1.InputThe input begins with the number n of scenarios on a single line by itself.Next follow n scenarios. Each scenario consists of three lines containing integer numbers. The first line specifies the length l of a side of the chess board (4 <= l <= 300). The entire board has size l * l. The second and third line contain pair of integers {0, ..., l-1}*{0, ..., l-1} specifying the starting and ending position of the knight on the board. The integers are separated by a single blank. You can assume that the positions are valid positions on the chess board of that scenario.OutputFor each scenario of the input you have to calculate the minimal amount of knight moves which are necessary to move from the starting point to the ending point. If starting point and ending point are equal,distance is zero. The distance must be written on a single line.Sample Input380 07 01000 030 50101 11 1十Equal Sum PartitionsTime Limit: 1000MS Memory Limit: 65536KTotal Submissions: 297 Accepted: 214DescriptionAn equal sum partition of a sequence of numbers is a grouping of the numbers (in the same order as the original sequence) in such a way that each group has the same sum. For example, the sequence:2 5 13 3 7may be grouped as:(2 5) (1 3 3) (7)to yield an equal sum of 7.Note: The partition that puts all the numbers in a single group is an equal sum partition with the sum equal to the sum of all the numbers in the sequence.For this problem, you will write a program that takes as input a sequence of positive integers and returns the smallest sum for an equal sum partition of the sequence.InputThe first line of input contains a sin gle integer P, (1 ≤ P ≤ 1000), which is the number of data sets that follow. The first line of each data set contains the data set number, followed by a space, followed bya decimal integer M, (1 ≤ M ≤ 10000), giving the total number of integers in the sequence. The remaining line(s) in the dataset consist of the values, 10 per line,separated by a single space. The last line in the dataset may contain less than 10 values.OutputFor each data set, generate one line of output with the following values: The data set number as a decimal integer, a space, and the smallest sum for an equal sum partition of the sequence.Sample Input31 62 5 13 3 72 61 2 3 4 5 63 201 12 1 1 2 1 1 2 11 2 1 1 2 1 1 2 1 1Sample Output1 72 213 2如果有想要答案的朋友,请给我留言!。