- 博客(114)
- 资源 (1)
- 收藏
- 关注
原创 航电acm--2186
灾后的救援需要很多的人员,现在又刚刚到达一批志愿者,他们一共有n(10为了保证救援工作的顺利进行,指挥部决定为每个小分队指派若干当地的向导,原则是为每十个志愿者指派一个向导(如有不足10人的情况,也指派一个),现在请问:需要为这批志愿者指派多少个向导呢? Input输入数据首先包含一个正整数C,表示有C组测试用例,然后是C行数据,每行包含一个正整数n(10
2016-01-01 16:54:08
815
原创 航电acm--2107
Input输入包含多组测试数据,每组数据占2行,首先一行是一个整数n(nOutput对于每个测试实例,请输出老总的AC战斗力,每个实例的输出占一行。#include#include#includevoid main(){ int arr[100]; int n; while (std::cin >> n && n != 0) { for (
2016-01-01 14:49:03
503
原创 航电acm--2101
InputEach line will contain two integers A and B. Process to end of file. OutputFor each case, if(A+B)%86=0,output yes in one line,else output no in one line.#include#include#inclu
2016-01-01 14:47:08
616
原创 航电acm--2123
InputThe first line of input is an integer C which indicate the number of test cases.Then C test cases follow.Each test case contains an integer N (1OutputFor each test case, print out the
2016-01-01 14:44:50
732
原创 欧几里得算法
#includeusing namespace std;int Eucld(int a, int b){ if (a < b) { int t = a; a = b; b = t; } if (b == 0) return a; else { int t = b; b = a%t; a = t; return Eucld(a, b); }
2015-12-03 22:50:00
365
原创 桶排序
#include#include#include#define BASE 10using namespace std;//桶中元素链表typedef struct entry{ int element; struct entry *next;}ENTRY;//维护每个桶中元素数目,并且指向第一个元素typedef struct buc{ int size; ENT
2015-11-28 16:18:00
247
原创 基数排序
#include#include#include#define BASE 10using namespace std;void base_sort(int arr[], int n, int num_length){ int i = 1; int flag = 1; while (i <= num_length) { int length = 1; int A = s
2015-11-19 22:28:10
261
原创 堆排序
示意图如下: 代码如下: #include#includeusing namespace std;void keep_heap(int arr[], int i,int heap_size){ int Left = i * 2; int Right = 2 * i +1 ; int
2015-11-18 22:38:30
307
原创 杭电acm--2187
汶川地震救灾物资现在假设下拨了一定数量的救灾经费要去市场采购大米(散装)。如果市场有m种大米,各种大米的单价和重量已知,请问,为了满足更多灾民的需求,最多能采购多少重量的大米呢?Input输入数据首先包含一个正整数C,表示有C组测试用例,每组测试用例的第一行是两个整数n和m(0 Output对于每组测试数据,请输出能够购买大米的最多重量(你可以假设经费买不光所有的大
2015-11-13 16:41:02
770
原创 杭电acm--2111
话说上回讲到海东集团面临内外交困,公司的元老也只剩下XHD夫妇二人了。显然,作为多年拼搏的商人,XHD不会坐以待毙的。 一天,当他正在苦思冥想解困良策的时候,突然想到了自己的传家宝,那是公司成立的时候,父亲作为贺礼送来的一个锦囊,徐父当时交代,不到万不得已的时候,不要打开它。“现在不正是最需要的时候吗?”,一边想,XHD一边找到了这个精心保管的锦囊,打开一看,里面只有一句话“杭城北麓千人洞有
2015-11-13 15:51:27
422
原创 归并排序
示意图如下: 代码如下: #includeusing namespace std;void merge(int A[], int B[], int arr[], int lengthA, int lengthB){ int i = 0, j = 0,count=0; while (count<lengthA+lengthB) { if (A[i]
2015-11-10 22:15:55
279
原创 希尔排序
代码如下: #includeusing namespace std;void shell_sort(int arr[], int n){ int flag,i,j,length = n; while (length > 1) { length = length / 2; do{ flag = 0; for (i = 0; i < n - length;
2015-11-10 21:26:27
238
原创 选择排序
代码如下: #includeusing namespace std;void select_sort(int *arr, int n){ int i, j; int max; for (i = 0; i < n - 1; i++) { max = i; for (j = max + 1; j < n; j++) { if (arr[max] > arr[
2015-11-08 20:43:53
278
原创 快速排序
示意图如下:下标0暂存i,不参与排序代码如下:#include//#includeusing namespace std;int partition(int arr[], int begin_index, int end_index){ int key = arr[end_index]; int i = begin_index-1; for
2015-11-01 16:35:12
308
原创 计数排序
示意图如下:代码如下:#include//#includeusing namespace std;void counting_sort(int arr1[], int arr2[], int temp_arr[], const int arr_num, const int bigest_num){ for (int i = 0; i <= bige
2015-11-01 14:15:51
252
原创 插入排序
示意图如下: 代码如下:#include//#includeusing namespace std;void insert_sort(int arr[],int length){ for (int i = 1; i < length; i++) { int key
2015-10-31 22:29:58
250
原创 杭电acm--1008
The highest building in our city has only one elevator. A request list is made up with N positive numbers. The numbers denote at which floors the elevator will stop, in specified order. It costs 6 sec
2015-10-19 22:22:35
466
原创 杭电acm--1076
Ignatius was born in a leap year, so he want to know when he could hold his birthday party. Can you tell him?Given a positive integers Y which indicate the start year, and a positive integer N, yo
2015-10-19 21:22:26
621
原创 杭电acm--1064
Problem DescriptionLarry graduated this year and finally has a job. He’s making a lot of money, but somehow never seems to have enough. Larry has decided that he needs to grab hold of his financial
2015-10-13 22:33:33
524
原创 杭电acm--1049
An inch worm is at the bottom of a well n inches deep. It has enough energy to climb u inches every minute, but then has to rest a minute before climbing again. During the rest, it slips down d inches
2015-10-13 21:07:57
307
原创 杭电acm--1046
For years, computer scientists have been trying to find efficient solutions to different computing problems. For some of them efficient algorithms are already available, these are the “easy” problems
2015-10-13 20:40:30
328
原创 杭电acm--1040
Input contains multiple test cases. The first line of the input is a single integer T which is the number of test cases. T test cases follow. Each test case contains an integer N (1<=N<=1000 the numbe
2015-10-13 19:38:27
2112
原创 杭电acm--1037
InputInput to this problem will consist of a single data set. The data set will be formatted according to the following description.The data set will consist of a single line containing 3 number
2015-10-13 19:20:14
377
原创 杭电acm--1021
There are another kind of Fibonacci numbers: F(0) = 7, F(1) = 11, F(n) = F(n-1) + F(n-2) (n>=2). InputInput consists of a sequence of lines, each containing an integer n. (n Output
2015-10-12 22:07:33
465
原创 杭电acm--1019
The least common multiple (LCM) of a set of positive integers is the smallest positive integer which is divisible by all the numbers in the set. For example, the LCM of 5, 7 and 15 is 105.Inpu
2015-10-12 21:28:55
439
原创 杭电acm--1017
Given two integers n and m, count the number of pairs of integers (a,b) such that 0 This problem contains multiple test cases!The first line of a multiple input is an integer N, then a blank l
2015-10-12 20:01:01
404
原创 杭电acm--2013
The digital root of a positive integer is found by summing the digits of the integer. If the resulting value is a single digit then that digit is the digital root. If the resulting value contains two
2015-10-11 22:42:38
365
原创 杭电acm--1012
A simple mathematical formula for e iswhere n is allowed to go to infinity. This can actually yield very accurate approximations of e using relatively small values of n. Ou
2015-10-09 22:04:13
847
转载 杭电acm--1005
A number sequence is defined as follows:f(1) = 1, f(2) = 1, f(n) = (A * f(n - 1) + B * f(n - 2)) mod 7.Given A, B, and n, you are to calculate the value of f(n). InpuThe inpu
2015-10-09 21:17:39
364
原创 杭电acm--2080
Problem Description这次xhd面临的问题是这样的:在一个平面内有两个点,求两个点分别和原点的连线的夹角的大小。注:夹角的范围[0,180],两个点不会在圆心出现。 Input输入数据的第一行是一个数据T,表示有T组数据。每组数据有四个实数x1,y1,x2,y2分别表示两个点的坐标,这些实数的范围是[-10000,10000]。
2015-10-08 20:44:11
475
原创 杭电acm--2032
还记得中学时候学过的杨辉三角吗?具体的定义这里不再描述,你可以参考以下的图形:11 11 2 11 3 3 11 4 6 4 11 5 10 10 5 1 Input输入数据包含多个测试实例,每个测试实例的输入只包含一个正整数n(1 Output对应于每一个输入,请输出相应层数的杨辉三角,每一层的整数之间用一个空格隔开,每一个杨辉三角后面
2015-09-26 22:11:11
326
原创 杭电acm--2024
输入一个字符串,判断其是否是C的合法标识符。 Input输入数据包含多个测试实例,数据的第一行是一个整数n,表示测试实例的个数,然后是n行输入数据,每行是一个长度不超过50的字符串。 Output对于每组输入数据,输出一行。如果输入数据是C的合法标识符,则输出"yes",否则,输出“no”。 #include#include#incl
2015-09-26 21:03:17
559
原创 杭电acm--2015
有一个长度为n(n Input输入数据有多组,每组占一行,包含两个正整数n和m,n和m的含义如上所述。 Output对于每组输入数据,输出一个平均值序列,每组输出占一行。#include#include#include//#include//#define P 3.141592653void main(){ int n,
2015-09-26 20:16:42
290
原创 杭电acm--2070
Your objective for this question is to develop a program which will generate a fibbonacci number. The fibbonacci function is defined as such:f(0) = 0f(1) = 1f(n) = f(n-1) + f(n-2)Your prog
2015-09-26 18:32:56
570
原创 杭电acm--2071
Problem DescriptionThere are some students in a class, Can you help teacher find the highest student . InputThere are some cases. The first line contains an integer t, indicate the cases; Ea
2015-09-26 18:21:09
972
原创 杭电acm--2087
Problem Description一块花布条,里面有些图案,另有一块直接可用的小饰条,里面也有一些图案。对于给定的花布条和小饰条,计算一下能从花布条中尽可能剪出几块小饰条来呢? Input输入中含有一些数据,分别是成对出现的花布条和小饰条,其布条都是用可见ASCII字符表示的,可见的ASCII字符有多少个,布条的花纹也有多少种花样。花纹条和小饰条不会超过1000个字符长
2015-09-26 17:42:15
1094
原创 杭电acm--2075
正整数A是否能被正整数B整除,不知道为什么xhd会研究这个问题,来帮帮他吧。 Input输入数据的第一行是一个数据T,表示有T组数据。每组数据有两个正整数A和B(A,B Output对于每组输入数据,输出"YES"表示可以被整除,"NO"表示不能被整除。 #include#include#include//#include//
2015-09-24 22:45:22
453
原创 杭电acm--2055
Problem Descriptionwe define f(A) = 1, f(a) = -1, f(B) = 2, f(b) = -2, ... f(Z) = 26, f(z) = -26;Give you a letter x and a number y , you should output the result of y+f(x). InputOn the fi
2015-09-24 21:42:06
1322
原创 杭电acm--2052
Give you the width and height of the rectangle,darw it. InputInput contains a number of test cases.For each case ,there are two numbers n and m (0 OutputFor each case,you should draw
2015-09-24 20:36:20
1439
原创 杭电acm--2050
我们看到过很多直线分割平面的题目,今天的这个题目稍微有些变化,我们要求的是n条折线分割平面的最大数目。比如,一条折线可以将平面分成两部分,两条折线最多可以将平面分成7部分,具体如下所示。 Input输入数据的第一行是一个整数C,表示测试实例的个数,然后是C 行数据,每行包含一个整数n(0Output对于每个测试实例,请输出平面的最大分割数,每个实例的输出占一
2015-09-24 20:13:18
397
通讯簿管理系统
2015-09-20
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人