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

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

Problem Description

Calculate A + B.

Input

Each line will contain two integers A and B. Process to end of file.

Output

For each case, output A + B in one line.

Sample Input

1 1

Sample Output

2

#include

void main()

{

int a,b;

while(scanf("%d %d",&a,&b)!=EOF)

{

printf("%d\n",a+b);

}

}

Problem Description

Hey, welcome to HDOJ(Hangzhou Dianzi University Online Judge).

In this problem, your task is to calculate SUM(n) = 1 + 2 + 3 + ... + n.

Input

The input will consist of a series of integers n, one integer per line.

Output

For each case, output SUM(n) in one line, followed by a blank line. You may assume the result will be in the range of 32-bit signed integer.

Sample Input

1

100

Sample Output

1

5050

#include

void main()

{

int n,sum,i;

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

{

sum=0;

for( i=0;i<=n;i++)

sum+=i;

printf("%d\n\n",sum);

}

}

Problem Description

I have a very simple problem for you. Given two integers A and B, your job is to calculate the Sum of A + B.

Input

The first line of the input contains an integer T(1<=T<=20) which means the number of test cases. Then T lines follow, each line consists of two positive integers, A and B. Notice that the integers are very large, that means you should not process them by using 32-bit integer. You may assume the length of each integer will not exceed 1000.

Output

For each test case, you should output two lines. The first line is "Case #:", # means the number of the test case. The second line is the an equation "A + B = Sum", Sum means the result of A + B. Note there are some spaces int the equation. Output a blank line between two test cases.

Sample Input

2

1 2

112233445566778899 998877665544332211

Sample Output

Case 1:

1 +

2 = 3

Case 2:

112233445566778899 + 998877665544332211 = 1111111111111111110 #include

#include

int main(){

char str1[1001], str2[1001];

int t, i, len_str1, len_str2, len_max, num = 1, k;

scanf("%d", &t);

getchar();

while(t--){

int a[1001] = {0}, b[1001] = {0}, c[1001] = {0};

scanf("%s", str1);

len_str1 = strlen(str1);

for(i = 0; i <= len_str1 - 1; ++i)

a[i] = str1[len_str1 - 1 - i] - '0';

scanf("%s",str2);

len_str2 = strlen(str2);

for(i = 0; i <= len_str2 - 1; ++i)

b[i] = str2[len_str2 - 1 - i] - '0';

if(len_str1 > len_str2)

len_max = len_str1;

else

len_max = len_str2;

k = 0;

for(i = 0; i <= len_max - 1; ++i){

c[i] = (a[i] + b[i] + k) % 10;

k = (a[i] + b[i] + k) / 10;

}

if(k != 0)

c[len_max] = 1;

printf("Case %d:\n", num);

num++;

printf("%s + %s = ", str1, str2);

if(c[len_max] == 1)

printf("1");

for(i = len_max - 1; i >= 0; --i){

printf("%d", c[i]);

}

printf("\n");

if(t >= 1)

printf("\n");

}

return 0;

}

Problem Description

Given a sequence a[1],a[2],a[3]......a[n], your job is to calculate the max sum of a sub-sequence. For example, given (6,-1,5,4,-7), the max sum in this sequence is 6 + (-1) + 5 + 4 = 14.

Input

The first line of the input contains an integer T(1<=T<=20) which means the number of test cases. Then T lines follow, each line starts with a number N(1<=N<=100000), then N integers followed(all the integers are between -1000 and 1000).

Output

For each test case, you should output two lines. The first line is "Case #:", # means the number of the test case. The second line contains three integers, the Max Sum in the sequence, the start position of the sub-sequence, the end position of the sub-sequence. If there are more than one result, output the first one. Output a blank line between two cases.

Sample Input

2

5 6 -1 5 4 -7

7 0 6 -1 1 -6 7 -5

Sample Output

Case 1:

14 1 4

Case 2:

7 1 6

注:最大子序列是要找出由数组成的一维数组中和最大的连续子序列。比如{5,-3,4,2}的最大子序列就是{5,-3,4,2},它的和是8,达到最大;而{5,-6,4,2}的最大子序列是{4,2},它的和是6。你已经看出来了,找最大子序列的方法很简单,只要前i项的和还没有小于0那么子序列就一直向后扩展,否则丢弃之前的子序列开始新的子序列,同时我们要记下各个子序列的和,最后找到和最大的子序列

#include

int a[100005],str[100005],start[100005];

int main()

{

int t,n,i,num=1,end,max,k;

scanf("%d",&t);

while(t--)

{

scanf("%d",&n);

for(i=1;i<=n;i++)

{

scanf("%d",&a[i]);

}

str[1]=a[1];start[1]=1;

for(i=2;i<=n;i++)

{

if(str[i-1]>=0)

{

str[i]=str[i-1]+a[i];

start[i]=start[i-1];

}

else

{

str[i]=a[i];

start[i]=i;

}

}

max=str[1];end=1;

for(k=2;k<=n;k++)

{

if(str[k]>max)

{

max=str[k];

end=k;

}

}

printf("Case %d:\n",num);

num++;

printf("%d %d %d\n",max,start[end],end);

if(t)

printf("\n");

}

return 0;

}

Problem Description

Contest time again! How excited it is to see balloons floating around. But to tell you a secret, the judges' favorite time is guessing the most popular problem. When the contest is over, they will count the balloons of each color and find the result.

This year, they decide to leave this lovely job to you.

Input

Input contains multiple test cases. Each test case starts with a number N (0 < N <= 1000) -- the total number of balloons distributed. The next N lines contain one color each. The color of a balloon is a string of up to 15 lower-case letters.

A test case with N = 0 terminates the input and this test case is not to be processed.

Output

For each case, print the color of balloon for the most popular problem on a single line. It is guaranteed that there is a unique solution for each test case.

Sample Input

5

green

red

blue

red

red

3

pink

orange

pink

Sample Output

red

pink

#include

#include

char a[1000][15];

int b[1000];

int main()

{

int n,i,j,max,k;

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

{

if(n==0)

break;

for(i=1;i<=n;i++)

{

b[i]=0;

scanf("%s",a[i]);//二维数组的神奇用法

}

for(i=1;i<=n;i++)

{

for(j=1;j<=n;j++)

if(strcmp(a[i],a[j])==0)

{

b[i]++;

}

}

max=b[1];

k=1;

for(i=2;i<=n;i++)

{

if(b[i]>max)

{

max=b[i];

k=i;

}

}

printf("%s\n",a[k]);

}

return 0;

}

Problem Description

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). Input

The input consists of multiple test cases. Each test case contains 3 integers A, B and n on a single line (1 <= A, B <= 1000, 1 <= n <= 100,000,000). Three zeros signal the end of input and this test case is not to be processed.

Output

For each test case, print the value of f(n) on a single line.

Sample Input

1 1 3

1 2 10

0 0 0

Sample Output

2

5

方法1:注函数介绍

void *memset(void *s, int ch, size_t n);

函数解释:将s中前n个字节替换为ch并返回s;

memset:作用是在一段内存块中填充某个给定的值,它是对较大的结构体或数组进行清零操作的一种最快方法。

#include

#include

int main(){

int b[7][7];

int a[100];

int n;

int x, y, m, st, len;

while (scanf("%d %d %d", &x, &y, &m) == 3){

if (x==0 && y==0 && m==0){

break;

}

a[1] = 1;

a[2] = 1;

memset(b, 0, sizeof(b));

b[1][1] = 1;

n = 3;

for (;;){

a[n] = (a[n-1]*x+a[n-2]*y)%7;

if (b[a[n-1]][a[n]] != 0){

break;

}

b[a[n-1]][a[n]] = n-1;

++n;

}//计算周期

st = b[a[n-1]][a[n]];

len = n-1-st;//len为周期

if (m < st){

printf("%d\n", a[m]);

}

else{

printf("%d\n", a[st+(m-st)%len]);

}

}

return 0;

}

方法二

简单递归应为模运算中(a+b)%p=(a%p+b%p)%p;所以循环周期为7*7=49;#include

int a,b;

int f(int n){

if(n==2||n==1) return 1;

else return (a*f(n-1)+b*f(n-2))%7;

}

main()

{

while(scanf("%d%d",&a,&b)!=EOF&&a&&b)

{

__int64 n;

int m;

scanf("%I64d",&n);

m=n%49;

printf("%d\n",f(m));

}

}

Problem Description

The three hands of the clock are rotating every second and meeting each other many times everyday. Finally, they get bored of this and each of them would like to stay away from the other two. A hand is happy if it is at least D degrees from any of the rest. You are to calculate how much time in a day that all the hands are happy.

Input

The input contains many test cases. Each of them has a single line with a real number D between 0 and 120, inclusively. The input is terminated with a D of -1.

Output

For each D, print in a single line the percentage of time in a day that all of the hands are happy, accurate up to 3 decimal places.

Sample Input

120

90

-1

Sample Output

100.000

0.000

6.251

这个钟是个物理的钟,也就是说秒针每一秒走6度之后,分针就走了10分之1度,然后时针又走了120分之1度,当然钟表盘一圈是360度了~或者还可以继续拆,秒针每千分之一秒走千分之6度,然后分针就走万分之1度,时针就走十二万分之1度,就这样……

只要知道他是一个连续的钟,那就什么都好解决了

首先我们有一个东西是必然可以知道的,在0点的时候三根针是重合的,然后在12点的时

候三跟针就又重合了(操,我最开始的时候居然想的是24的时候三根针才再次重复),也就是说一天被分为两个周期,每个周期12个小时。所以,只要我们求出在一个周期中三根针满足条件的总时间,我们就可以知道一天中三根针满足条件的总时间。所占百分比也自然就出来了……

好了,这东西肯定不能暴力,如果你按一秒为梯度来暴力解出每一秒的时候三根针之间的间距,然后把总时间求和,精度肯定不够,甚至可能是错误的解,当然,如果你以万分之一秒为梯度来暴力求解的话,那有可能就达到题目的精度了,但是,多半也就超时了

所以,就只有解方程了……

好,最开始我想的是用三个方程,分别表示三根针随时间的变化的角度的变化,就是说第0秒秒针的角度是0度,第1秒是6度,第30秒是180度,第59秒时60-6度……

然后把两跟针的度数相减,就得到了他们之间相距的角度……不过,我发现这个好麻烦……而且整个方程和给定的角度D完全没有关系,也很难根据那个D来解出我们想要的结果……

所以,换了,将方程改为随时间变化的针之间相距的角度的方程,也是三个。

首先,我们知道每根针的角速度:

Vs = 6度每秒(60秒走一圈360度 360/60=6)

Vm = 1/10度每秒(3600秒,一个小时走一圈, 360/3600=0.1)

Vh = 1/120度每秒(12小时走一圈,360/(3600*12)= 1/120)

然后,就可以得到每两根之间的速度差了:

Vsm = Vs - Vm = 6 - 1/10 = 59/10

Vsh = Vs - Vh = 6 - 1/120 = 719/120

Vmh = Vm - Vh = 1/10 - 1/120 = 11/120

然后,时间乘以速度等于距离。

然后我们可以算出来:

秒针和分针之间的夹角在时间t = 0的时候是0度,在t = 1800/59(59分之1800秒)的时候达到最大值180度,然后从59分之1800秒开始就开始减少,当时间t到达59分之3600秒的时候,秒针和分针之间的夹角就又是0度了。(算法:Vsm * t = 180 ,所以 t = 180/Vsm = 180 /(59/10) = (180 * 10)/ 59

时针和秒的0度-180度-0度这三个点的时间t分别是 0, 120*180/719,

120*180*2/719

时针和分针:0, 180*120/11, 180*120*2/11

所以:

Dsm = (59/10) * t 或者 360 - (59/10) * t

Dsh = (719/120) * t 或者 360 - (719/120) * t

Dmh = (11/120) * t 或者 360 - (11/120) * t

#include

double max(double a,double b,double c)

{

a=a>b?a:b;

a=a>c?a:c;

return a;

}

double min(double a,double b,double c) {

a=a

a=a

return a;

}

void main()

{

double s=60;

double m=60*60;

double h=12*60*60;

double ws=360/s;

double wm=360/m;

double wh=360/h;

double wsm=ws-wm;

double wsh=ws-wh;

double wmh=wm-wh;

double tsm=360/(ws-wm);

double tsh=360/(ws-wh);

double tmh=360/(wm-wh);

double dsm[1444];

double dsh[1444];

double dmh[26];

double D;

while(scanf("%lf",&D)!=EOF&&D!=-1) {

int i,j;

int sp[2],mp[2],hp[2];

double sum=0;

double x=0,y=0;

dsm[0]=(D*10)/59;

dsh[0]=(D*120)/719;

dmh[0]=(D*120)/11;

dsm[1]=tsm-dsm[0];

dsh[1]=tsh-dsh[0];

dmh[1]=tmh-dmh[0];

for(i=2,j=3;;i+=2,j+=2)

{

dsm[i]=dsm[i-2]+tsm;

dsm[j]=dsm[j-2]+tsm;

if(dsm[i]>43200&&dsm[j]>43200)

break;

}

for(i=2,j=3;;i+=2,j+=2)

{

dsh[i]=dsh[i-2]+tsh;

dsh[j]=dsh[j-2]+tsh;

if(dsh[i]>43200&&dsh[j]>43200)

break;

}

for(i=2,j=3;;i+=2,j+=2)

{

dmh[i]=dmh[i-2]+tmh;

dmh[j]=dmh[j-2]+tmh;

if(dmh[i]>43200&&dmh[j]>43200)

break;

}

sp[0]=mp[0]=hp[0]=0;

sp[1]=mp[1]=hp[1]=1;

while(y<=43200 && x<=43200)

{

x=max(dsm[sp[0]],dsh[mp[0]],dmh[hp[0]]); y=min(dsm[sp[1]],dsh[mp[1]],dmh[hp[1]]);

if(x

sum+=y-x;

if(y==dsm[sp[1]]) {sp[0]+=2;sp[1]+=2;}

if(y==dsh[mp[1]]) {mp[0]+=2;mp[1]+=2;}

if(y==dmh[hp[1]]) {hp[0]+=2;hp[1]+=2;} }

printf("%.3lf\n",sum/432);

}

}

(不会)Problem Description

Have you ever played quoit in a playground? Quoit is a game in which flat rings are pitched at some toys, with all the toys encircled awarded.

In the field of Cyberground, the position of each toy is fixed, and the ring is carefully designed so it can only encircle one toy at a time. On the other hand, to make the game look more attractive, the ring is designed to have the largest radius. Given a configuration of the field, you are supposed to find the radius of such a ring.

Assume that all the toys are points on a plane. A point is encircled by the ring if the distance between the point and the center of the ring is strictly less than the radius of the ring. If two toys are placed at the same point, the radius of the ring is considered to be 0.

Input

The input consists of several test cases. For each case, the first line contains an integer N (2 <= N <= 100,000), the total number of toys in the field. Then N lines follow, each contains a pair of (x, y) which are the coordinates of a toy. The input is terminated by N = 0.

Output

For each test case, print in one line the radius of the ring required by the Cyberground manager, accurate up to 2 decimal places.

Sample Input

2

0 0

1 1

2

1 1

1 1

3

-1.5 0

0 0

0 1.5

Sample Output

0.71

0.00

0.75

#include

#include

#include

#include

#include

using namespace std;

const int maxn=100011;

int n;

int q[maxn];

double x[maxn],y[maxn];

inline double dis( double x1, double y1, double x2, double y2 )

{

return sqrt( (x1-x2)*(x1-x2)+(y1-y2)*(y1-y2) );

}

void qsortX( int l, int r )//对?数oy组á¨|进?行D排?序¨°(ê?§横¨¢坐á?标à¨o从?¨?小?到ì?大?¨?)ê?

{

int i=l,

j=r;

double mid=x[(l+r)/2];

do

{

while ( x[i]

while ( x[j]>mid ) j--;

if ( i<=j )

{

swap( x[i], x[j] );

swap( y[i], y[j] );

i++;

j--;

}

}

while ( i<=j );

if ( i

if ( l

}

void qsortY( int l, int r )

{

int i=l,

j=r;

double mid=y[q[(l+r)/2]];

do

{

while ( y[q[i]]

while ( y[q[j]]>mid ) j--;

if ( i<=j )

{

swap( q[i], q[j] );

i++;

j--;

}

}

while ( i<=j );

if ( i

if ( l

}

double findMin( int l, int r )

{

if ( l==r ) return 99999999;

if ( l+1==r ) return dis( x[l], y[l], x[r], y[r] );

double t1=findMin( l, (l+r)/2 ),//递ìY归¨|,ê?分¤?治?思?想?,ê?把??大?¨?问¨o题?a看??若¨?干¨|个?小?问¨o题?a

t2=findMin( (l+r)/2+1, r ),

mid=(x[l]+x[r])/2,

min;

if ( t1

else min=t2;//最á?小?距¨¤离¤?在¨2A或¨°B里¤?情¨|况?下?

int tot=0;

for ( int i=l; i<=r; i++ )

if ( fabs( x[i]-mid )

qsortY( 1, tot );

for ( int i=1; i<=tot; i++ )

for ( int j=i+1; j<=i+7; j++ )

{

if ( j>tot ) break;

double t=dis( x[q[i]], y[q[i]], x[q[j]], y[q[j]] );

if ( t

}

return min;

}

void readdata()

{

for ( int i=1; i<=n; i++ ) scanf( "%lf%lf", &x[i], &y[i] );

}

int main()

{

while ( scanf( "%d", &n ) )

{

if ( n==0 ) break;

readdata();

qsortX( 1, n );

double ans=findMin( 1, n );

printf( "%.2f\n", ans/2 );

}

return 0;

}

Problem Description

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 seconds to move the elevator up one floor, and 4 seconds to move down one floor. The elevator will stay for 5 seconds at each stop.

For a given request list, you are to compute the total time spent to fulfill the requests on the list. The elevator is on the 0th floor at the beginning and does not have to return to the ground floor when the requests are fulfilled.

Input

There are multiple test cases. Each case contains a positive integer N, followed by N positive numbers. All the numbers in the input are less than 100. A test case with N = 0 denotes the end of input. This test case is not to be processed.

Output

Print the total time on a single line for each test case. Sample Input

1 2

3 2 3 1

Sample Output

17

41

#include

#include

void main()

{

int n,i,time;

int length[101]={0};

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

{

time=0;

if(n==0)

break;

for(i=1;i<=n;i++)

scanf("%d",&length[i]);

for(i=0;i

{

if(length[i+1]-length[i]>=0)

time+=6*(length[i+1]-length[i])+5;

else

time+=4*(abs(length[i+1]-length[i]))+5;

}

printf("%d\n",time);

}

}

Problem Description

FatMouse prepared M pounds of cat food, ready to trade with the cats guarding the warehouse containing his favorite food, JavaBean.

The warehouse has N rooms. The i-th room contains J[i] pounds of JavaBeans and requires F[i] pounds of cat food. FatMouse does not have to trade for all the JavaBeans in the room, instead, he may get J[i]* a% pounds of JavaBeans if he pays F[i]* a% pounds of cat food. Here a is a real number. Now he is assigning this homework to you: tell him the maximum amount of JavaBeans he can obtain.

Input

The input consists of multiple test cases. Each test case begins with a line containing two

non-negative integers M and N. Then N lines follow, each contains two non-negative integers J[i] and F[i] respectively. The last test case is followed by two -1's. All integers are not greater than 1000.

Output

For each test case, print in a single line a real number accurate up to 3 decimal places, which is the maximum amount of JavaBeans that FatMouse can obtain.

Sample Input

5 3

7 2

4 3

5 2

20 3

25 18

24 15

15 10

-1 -1

Sample Output

13.333

31.500

#include

int main()

{

int m,n,i,j,s;

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

int k[1001],f[1001];

double g[1001];

double sum=0;

double min;

if(m==-1&&n==-1)

break;

for(i=1;i<=n;i++)

{

scanf("%d %d",&k[i],&f[i]);

}

for(i=1;i<=n;i++)

{

if(f[i]!=0)

g[i]=(double)k[i]/f[i];

else

{

sum+=k[i];

g[i]=0;

}

}

for(j=0;j

{

min=g[1];

s=f[1];

for(i=2;i<=n-j;i++)

{

if(g[i]

{

min=g[i];

s=f[i];

}

else

{

g[i-1]=g[i];

g[i]=min;

f[i-1]=f[i];

f[i]=s;

}

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

Problem Description Calculate A + B. Input Each line will contain two integers A and B. Process to end of file. Output For each case, output A + B in one line. Sample Input 1 1 Sample Output 2 #include void main() { int a,b; while(scanf("%d %d",&a,&b)!=EOF) { printf("%d\n",a+b); } } Problem Description Hey, welcome to HDOJ(Hangzhou Dianzi University Online Judge). In this problem, your task is to calculate SUM(n) = 1 + 2 + 3 + ... + n. Input The input will consist of a series of integers n, one integer per line. Output For each case, output SUM(n) in one line, followed by a blank line. You may assume the result will be in the range of 32-bit signed integer. Sample Input 1 100 Sample Output

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

杭州电子科技大学OJ题目分类 1001 整数求和水题 1002 C语言实验题——两个数比较水题 1003 1、2、3、4、5... 简单题 1004 渊子赛马排序+贪心的方法归并 1005 Hero In Maze 广度搜索 1006 Redraiment猜想数论:容斥定理 1007 童年生活二三事递推题 1008 University 简单hash 1009 目标柏林简单模拟题 1010 Rails 模拟题(堆栈) 1011 Box of Bricks 简单题 1012 u Calculate e 简单数学计算 1013 STAMPS 搜索or动态规划 1014 Border 模拟题 1015 Simple Arithmetics 高精度计算 1016 Shoot-out 博弈+状态压缩DP 1017 Tour Guide 1018 Card Trick 简单题 1019 Necklace Decomposition 贪心 1020 Crashing Robots 模拟题 1021 Electrical Outlets 简单题 1022 Watchdog 简单题 1023 Taxi Cab Scheme 图论:最小路径覆盖--->最大二分匹配1024 Pseudo-random Numbers 数论 1025 Card Game Cheater 简单题 1026 Investment 动态规划 1027 Pipes 1028 SETI 数学:高斯消元法 1029 Minimax Triangulation 计算几何 1030 Unequalled Consumption 母函数 1031 Declaration of Content 1032 Laserbox 搜索:DFS 1033 Bowlstack 1034 Pesky Heroes 1035 Reduced ID Numbers 暴力 1036 Tantrix 1037 Guardian of Decency 图论:匈牙利算法求二分图的最大匹配1038 Up the Stairs 简单数学题 1039 Sudoku 搜索:DFS 1040 The SetStack Computer 1041 Pie 二分法 1042 Ticket to Ride 动态规划 1043 The Bookcase 动态规划

杭电ACM水题题目及代码

1001 #include int main() { int i,a,j;double sum; while(scanf("%d",&a)!=EOF) { sum=0; for(j=1;j<=a;j++) { sum+=j; } printf("%.0lf\n\n",sum); } return 0; } 1002 A + B Problem II Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 69615 Accepted Submission(s): 12678 Problem Description I have a very simple problem for you. Given two integers A and B, your job is to calculate the Sum of A + B.

Input The first line of the input contains an integer T(1<=T<=20) which means the number of test cases. Then T lines follow, each line consists of two positive integers, A and B. Notice that the integers are very large, that means you should not process them by using 32-bit integer. You may assume the length of each integer will not exceed 1000. Output For each test case, you should output two lines. The first line is "Case #:", # means the number of the test case. The second line is the an equation "A + B = Sum", Sum means the result of A + B. Note there are some spaces int the equation. Output a blank line between two test cases. Sample Input 2 1 2 112233445566778899 998877665544332211 Sample Output Case 1: 1 + 2 = 3 Case 2: 112233445566778899 + 998877665544332211 = 1111111111111111110 Author Ignatius.L #include #include int main(){ char str1[1001], str2[1001]; int t, i, len_str1, len_str2, len_max, num = 1, k; scanf("%d", &t); getchar(); while(t--){ int a[1001] = {0}, b[1001] = {0}, c[1001] = {0}; scanf("%s", str1); len_str1 = strlen(str1);

杭电OJ题目分类

杭州电子科技大学OJ题目分类The Soul with Bone .: 1001 整数求和水题 1002 C语言实验题——两个数比较水题 1003 1、2、3、4、5... 简单题 1004 渊子赛马排序+贪心的方法归并 1005 Hero In Maze 广度搜索 1006 Redraiment猜想数论:容斥定理 1007 童年生活二三事递推题 1008 University 简单hash 1009 目标柏林简单模拟题 1010 Rails 模拟题(堆栈) 1011 Box of Bricks 简单题 1012 IMMEDIATE DECODABILITY Huffman编码 1013 STAMPS 搜索or动态规划 1014 Border 模拟题 1015 Simple Arithmetics 高精度计算 1016 Shoot-out 博弈+状态压缩DP 1017 Tour Guide 1018 Card Trick 简单题 1019 Necklace Decomposition 贪心

1020 Crashing Robots 模拟题 1021 Electrical Outlets 简单题 1022 Watchdog 简单题 1023 Taxi Cab Scheme 图论:最小路径覆盖--->最大二分匹配1024 Pseudo-random Numbers 数论 1025 Card Game Cheater 简单题 1026 Investment 动态规划 1027 Pipes 1028 SETI 数学:高斯消元法 1029 Minimax Triangulation 计算几何 1030 Unequalled Consumption 母函数 1031 Declaration of Content 1032 Laserbox 搜索:DFS 1033 Bowlstack 1034 Pesky Heroes 1035 Reduced ID Numbers 暴力 1036 Tantrix 1037 Guardian of Decency 图论:匈牙利算法求二分图的最大匹配1038 Up the Stairs 简单数学题 1039 Sudoku 搜索:DFS 1040 The SetStack Computer 1041 Pie 二分法

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

自己刷的题 这是我在杭电做题的记录,希望我的分享对你有帮助!!! 1001 Sum Problem***********************************************************1 1089 A+B for Input-Output Practice (I)********************************2 1090 A+B for Input-Output Practice (II)********************************5 1091A+B for Input-Output Practice (III)****************************************7 1092A+B for Input-Output Practice (IV)********************************8 1093 A+B for Input-Output Practice (V)********************************10 1094 A+B for Input-Output Practice (VI)***************************************12 1095A+B for Input-Output Practice (VII)*******************************13 1096 A+B for Input-Output Practice (VIII)******************************15 How to Type***************************************************************16 1001 Sum Problem Problem Description Hey, welcome to HDOJ(Hangzhou Dianzi University Online Judge). In this problem, your task is to calculate SUM(n) = 1 + 2 + 3 + ... + n. Input The input will consist of a series of integers n, one integer per line. Output For each case, output SUM(n) in one line, followed by a blank line. You may assume the result will be in the range of 32-bit signed integer.

整理出ACM所有题目及答案

1111111杭电: 1000 A + B Problem (4) 1001 Sum Problem (5) 1002 A + B Problem II (6) 1005 Number Sequence (8) 1008 Elevator (9) 1009 FatMouse' Trade (11) 1021 Fibonacci Again (13) 1089 A+B for Input-Output Practice (I) (14) 1090 A+B for Input-Output Practice (II) (15) 1091 A+B for Input-Output Practice (III) (16) 1092 A+B for Input-Output Practice (IV) (17) 1093 A+B for Input-Output Practice (V) (18) 1094 A+B for Input-Output Practice (VI) (20) 1095 A+B for Input-Output Practice (VII) (21) 1096 A+B for Input-Output Practice (VIII) (22) 1176 免费馅饼 (23) 1204 糖果大战 (25) 1213 How Many Tables (26) 2000 ASCII码排序 (32) 2001 计算两点间的距离 (34) 2002 计算球体积 (35) 2003 求绝对值 (36) 2004 成绩转换 (37) 2005 第几天? (38) 2006 求奇数的乘积 (40) 2007 平方和与立方和 (41) 2008 数值统计 (42) 2009 求数列的和 (43) 2010 水仙花数 (44) 2011 多项式求和 (46) 2012 素数判定 (47) 2014 青年歌手大奖赛_评委会打分 (49) 2015 偶数求和 (50) 2016 数据的交换输出 (52) 2017 字符串统计 (54) 2019 数列有序! (55) 2020 绝对值排序 (56) 2021 发工资咯:) (58) 2033 人见人爱A+B (59) 2037 今年暑假不AC (61) 2039 三角形 (63) 2040 亲和数 (64)

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

杭电ACM试题分类 枚举 1002 10041013 1015 1017 1020 1022 1029 1031 1033 1034 1035 1036 1037 1039 1042 10471048 1049 1050 1057 1062 1063 1064 1070 1073 1075 1082 1083 1084 1088 11061107 1113 1117 1119 1128 1129 1144 1148 1157 1161 1170 1172 1177 11971200 1201 1202 1205 1209 1212(大数取模)1216 (链表)1218 1219 1225 1228 12291230 1234 1235 1236 1237 1239 1250 1256 1259 1262 1263 1265 1266 1276 1279 1282 1283 1287 1296 1302 1303 1304 1305 1306 1309 1311 1314 搜索,递归求解 1010 1016 1026 1043(双广)1044 (BFS+DFS) 1045 1067 1072 1104 1175 1180 1195 1208 1226 1238 1240 1241 1242 1258 1271 1312 1317 动态规划 1003 1024 1025 1028 1051 1058 1059 1069 1074 1078 1080 1081 1085 1087 1114 1158 1159 1160 1171 1176 1181 1203 1224 1227 1231 1244 1248 1253 1254 1283 1300 数学,递推,规律 1005 1006 1012 1014 1018 1019 1021 1023 1027 1030 1032 1038 1041 1046 1059 1060 1061 1065 1066 1071(微积分)1097 1098 1099 1100 1108 1110 1112 1124 1130 1131 1132 1134 1141 1143 1152 1155(物理题)1163 1165 1178 1194 1196(lowbit) 1210 1214 1200 1221 1223 1249 1261 1267 1273 1290 1291 1292 1294 1297 1313 1316 数论 1164 1211 1215 1222 1286 1299 计算几何 1086 1115 1147

ACM入门十题(杭电oj)

ACM入门(杭电oj) Hdu 1000 #include #include int main() { int a,b; while(scanf("%d%d",&a,&b)!=EOF) { printf("%d\n",a+b); } } Hdu 1001 #include #include int main() { int n; while(scanf("%d",&n)!=EOF) { printf("%I64d\n\n",(__int64)(1+n)*n/2); } } Hdu 1002 #include #include #include char str1[1005],str2[10005]; int main() { int ca,count=0; scanf("%d",&ca); while(ca--) { scanf("%s%s",str1,str2); int a[1005],i,j; memset(a,0,sizeof(a)); for(i=strlen(str1)-1,j=0;i>=0;i--,j++) a[j]=str1[i]-'0'; for(i=strlen(str2)-1,j=0;i>=0;i--,j++) {

a[j]=a[j]+str2[i]-'0'; a[j+1]=a[j+1]+a[j]/10; a[j]=a[j]%10; } count++; printf("Case %d:\n",count); printf("%s + %s = ",str1,str2); int flag=0; for(i=1004;i>=0;i--) if(flag||a[i]) { printf("%d",a[i]); flag=1; } printf("\n"); if(ca!=0) printf("\n"); } } Hdu 1003 #include #include int a[100005],sum[100005]; int main() { int ca,count=0; scanf("%d",&ca); while(ca--) { int n,i; scanf("%d",&n); for(i=1;i<=n;i++) scanf("%d",&a[i]); sum[1]=a[1]; int r=1,max=a[1]; for(i=2;i<=n;i++) { if(sum[i-1]>0) { sum[i]=sum[i-1]+a[i]; if(sum[i]>max) { max=sum[i]; r=i;

杭电题目acm答案

1001 Sum Problem (2) 1089 A+B for Input-Output Practice (I) (4) 1090 A+B for Input-Output Practice (II) (6) 1091 A+B for Input-Output Practice (III) (8) 1092 A+B for Input-Output Practice (IV) (9) 1093 A+B for Input-Output Practice (V) (11) 1094 A+B for Input-Output Practice (VI) (12) 1095 A+B for Input-Output Practice (VII) (13) 1096 A+B for Input-Output Practice (VIII) (14) 2000 ASCII码排序 (16) 2001计算两点间的距离 (17) 2002计算球体积 (19) 2003求绝对值 (20) 2004成绩转换 (21) 2005第几天 (22) 2006求奇数的乘积 (24) 2007平方和与立方和 (26) 2008数值统计 (27) 2009求数列的和 (28) 2010水仙花数 (29) 2011多项式求和 (31) 2012素数判定 (33) 2014青年歌手大奖赛_评委会打分 (34) 2015偶数求和 (36) 2016数据的交换输出 (38) 2017字符串统计 (40) 2019数列有序! (41) 2020绝对值排序 (43) 2021发工资咯:) (45) 2033人见人爱A+B (46) 2039三角形 (48) 2040亲和数 (49) 姓名:郑春杰 班级:电商1001 学号:34

完整word版杭电ACM试题答案

【杭电ACM1000】 A + B Problem Problem Description Calculate A + B. Input Each line will contain two integers A and B. Process to end of file. Output For each case, output A + B in one line. Sample Input 1 1 Sample Output 2 # include int main() { int a, b; while(scanf(%d%d, &a, &b)!=EOF) printf(%d\n, a+b); return 0; } 【杭电ACM1001】 Sum Problem Problem Description Hey, welcome to HDOJ(Hangzhou Dianzi University Online Judge). In this problem, your task is to calculate SUM(n) = 1 + 2 + 3 + ... + n.

Input The input will consist of a series of integers n, one integer per line. Output For each case, output SUM(n) in one line, followed by a blank line. You may assume the result will be in the range of 32-bit signed integer. Sample Input 1 100 Sample Output 1 5050 # include int main() { int n, i, sum = 0; while(scanf(%d, &n)!=EOF) { for(i=1; i<=n; ++i) sum = sum + i; printf(%d\n\n, sum); sum = 0; } return 0; } 【杭电ACM1002】 A + B Problem II Problem Description I have a very simple problem for you. Given two integers A and B, your job is to calculate the Sum of A + B. Input The first line of the input contains an integer T(1<=T<=20) which means the number of test cases. Then T lines follow, each line consists of two positive integers, A and B. Notice that the integers

ACM部分练习题目答案

ACM部分习题答案: A + B Problem Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 100972 Accepted Submission(s): 33404 Problem Description Calculate A + B. Input Each line will contain two integers A and B. Process to end of file. Output For each case, output A + B in one line. Sample Input 1 1 Sample Output 2 # include Int main() {int x,y,s; while(scanf("%d %d",&x,&y)!=EOF) {s=x+y; printf("%d\n",s);} return 0; } Sum Problem Time Limit: 1000/500 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 85964 Accepted Submission(s): 19422 Problem Description Hey, welcome to HDOJ(Hangzhou Dianzi University Online Judge). In this problem, your task is to calculate SUM(n) = 1 + 2 + 3 + ... + n. Input The input will consist of a series of integers n, one integer per line. Output For each case, output SUM(n) in one line, followed by a blank line. You may assume the result will be in the range of 32-bit signed integer. Sample Input 1 100 Sample Output 1 5050 # include int main() {int n; long int s;

杭电ACM部分题答案

1000A + B Problem Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 158161 Accepted Submission(s): 50186 Problem Description Calculate A + B. Input Each line will contain two integers A and B. Process to end of file. Output For each case, output A + B in one line. Sample Input 1 1 Sample Output 2 Author HDOJ Statistic | Submit | Discuss | Note #include int main() { int a,b; while(scanf("%d %d",&a,&b)!=EOF) printf("%d\n",a+b); }

1002A + B Problem II Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 84367 Accepted Submission(s): 15966 Problem Description I have a very simple problem for you. Given two integers A and B, your job is to calculate the Sum of A + B. Input The first line of the input contains an integer T(1<=T<=20) which means the number of test cases. Then T lines follow, each line consists of two positive integers, A and B. Notice that the integers are very large, that means you should not process them by using 32-bit integer. You may assume the length of each integer will not exceed 1000. Output For each test case, you should output two lines. The first line is "Case #:", # means the number of the test case. The second line is the an equation "A + B = Sum", Sum means the result of A + B. Note there are some spaces int the equation. Output a blank line between two test cases. Sample Input 2 1 2 112233445566778899 998877665544332211 Sample Output Case 1: 1 + 2 = 3 Case 2: 112233445566778899 + 998877665544332211 = 1111111111111111110 Author Ignatius.L Statistic | Submit | Discuss | Note

杭电题目acm答案

选修课考试作业 1001 Sum Problem ............................................................................................ 错误!未定义书签。1089 A+B for Input-Output Practice (I) .......................................................... 错误!未定义书签。1090 A+B for Input-Output Practice (II) ......................................................... 错误!未定义书签。1091 A+B for Input-Output Practice (III) ........................................................ 错误!未定义书签。1092 A+B for Input-Output Practice (IV) ........................................................... 错误!未定义书签。1093 A+B for Input-Output Practice (V) ......................................................... 错误!未定义书签。1094 A+B for Input-Output Practice (VI) ........................................................ 错误!未定义书签。1095 A+B for Input-Output Practice (VII) .......................................................... 错误!未定义书签。1096 A+B for Input-Output Practice (VIII) ...................................................... 错误!未定义书签。' 2000 ASCII码排序 ............................................................................................ 错误!未定义书签。2001计算两点间的距离.................................................................................. 错误!未定义书签。2002计算球体积 ............................................................................................. 错误!未定义书签。2003求绝对值 ................................................................................................. 错误!未定义书签。2004成绩转换 ................................................................................................. 错误!未定义书签。2005第几天 ..................................................................................................... 错误!未定义书签。2006求奇数的乘积 ......................................................................................... 错误!未定义书签。2007平方和与立方和...................................................................................... 错误!未定义书签。2008数值统计 ................................................................................................. 错误!未定义书签。2009求数列的和 ............................................................................................. 错误!未定义书签。~ 2010水仙花数 ................................................................................................. 错误!未定义书签。2011多项式求和 ............................................................................................. 错误!未定义书签。2012素数判定 ................................................................................................. 错误!未定义书签。2014青年歌手大奖赛_评委会打分................................................................ 错误!未定义书签。2015偶数求和 ................................................................................................. 错误!未定义书签。2016数据的交换输出...................................................................................... 错误!未定义书签。2017字符串统计 ............................................................................................. 错误!未定义书签。2019数列有序! ................................................................................................ 错误!未定义书签。2020绝对值排序.............................................................................................. 错误!未定义书签。2021发工资咯:)............................................................................................ 错误!未定义书签。: 2033人见人爱A+B .......................................................................................... 错误!未定义书签。2039三角形 ..................................................................................................... 错误!未定义书签。2040亲和数 ..................................................................................................... 错误!未定义书签。 姓名:郑春杰 班级:电商1001

杭电ACM博弈题合集

hdu博弈,这些题都不难。 属于博弈简单题。 hdu1846巴什博弈,n%(m+1)==0先手必败。 #include #include #include #include #include using namespace std; int main() { int n,a,b; scanf("%d",&n); while(n--) { scanf("%d%d",&a,&b); if(a%(b+1)==0) printf("second\n"); else printf("first\n"); } return 0; } hdu1847 只要留下两类都是2的指数幂,就是必输状态,然后找规律,发现这两类的和为3的倍数。即有下面的结论。 #include #include #include using namespace std; int main() { int n; while(scanf("%d",&n)!=EOF) { if(n%3==0) printf("Cici\n"); else printf("Kiki\n"); } return 0; } hdu1848 #include #include

#include #include using namespace std; #define N 1005 int f[N]; int sg[N]; void fun() { int i; f[0]=1; f[1]=1; f[2]=2; for(i=3;;i++) { f[i]=f[i-1]+f[i-2]; if(f[i]>1000) break; } } int dfs(int v) { int i; if(sg[v]!=-1) return sg[v]; bool visit[N]={0}; for(i=1;i<16;i++) { if(v>=f[i]) { int temp=dfs(v-f[i]); visit[temp]=1; } } for(i=0;visit[i];i++); return sg[v]=i; } int main() { fun(); int m,n,p; while(scanf("%d%d%d",&m,&n,&p),m||n||p) { memset(sg,-1,sizeof(sg)); int ans;

相关文档
最新文档