杭电2034人人都爱A-B#include#include#include#define N 102int main()

俄克拉荷马2022-10-04 11:39:541条回答

杭电2034人人都爱A-B
#include
#include
#include
#define N 102
int main()
{
int a,b,c,d;
int arr[N],brr[N],crr[N],drr[N];
while(scanf("%d %d",&a,&b)!=EOF&&a&&b)
{
memset(arr,0,sizeof(arr));
memset(brr,0,sizeof(brr));
memset(crr,0,sizeof(crr));
memset(drr,1,sizeof(drr));
for(int i=0;i scanf("%d",&arr[i]);
for(int i=0;i scanf("%d",&brr[i]);
c=0;
int ok;
for(int i=0;i {
ok=1;
for(int j=0;j if (arr[i] == brr[j])
{
ok = 0;
break;
}
if (ok)
crr[c++] = arr[i];
}
if(c==0)
{
printf("NELL");
}
for(int j=1;j for(int i=0;i if(crr[i]>crr[i+1])
{
int t=crr[i];
crr[i]=crr[i+1];
crr[i+1]=t;
}
for(int i=0;i {
for(int j=i+1;j if(crr[j]==crr[i])
{
drr[i]=0;
}
}
for(int i=0;i if(drr[i])
printf("%d ",crr[i]);
printf("n");
}
return 0;
}
提交就是错误.

已提交,审核后显示!提交回复

共1条回复
敏诺娃 共回答了14个问题 | 采纳率92.9%
#include
#include
#include
#define N 102
int main()
{
int a,b,c,d;
int arr[N],brr[N],crr[N],drr[N];
while(scanf("%d %d",&a,&b)!=EOF&&(a||b))
{
memset(arr,0,sizeof(arr));
memset(brr,0,sizeof(brr));
memset(crr,0,sizeof(crr));
memset(drr,1,sizeof(drr));
for(int i=0;i
1年前

相关推荐

杭电acm 2072 求错在哪里了.输出来时全是1.
杭电acm 2072 求错在哪里了.输出来时全是1.
单词数
Problem Description
lily的好朋友xiaoou333最近很空,他想了一件没有什么意义的事情,就是统计一篇文章里不同单词的总数.下面你的任务是帮助xiaoou333解决这个问题.
Input
有多组数据,每组一行,每组就是一篇小文章.每篇小文章都是由小写字母和空格组成,没有标点符号,遇到#时表示输入结束.
Output
每组只输出一个整数,其单独成行,该整数代表一篇文章里不同单词的总数.
Sample Input
you are my friend
#
Sample Output
4
#include "stdio.h"
#include "string.h"
int main()
{
x05char str[100];
x05int i,word=0,l;
x05while (scanf("%s",str)!=EOF)
x05{
x05x05if (str[0]=='#')
x05x05x05break;
x05x05word=0;
x05x05l=strlen(str);
x05x05if ((str[0]>='a' && str[0]='A' && str[0]
雪茸花儿1年前1
分手后是春天 共回答了27个问题 | 采纳率88.9%
%s 遇到空格就over 所以你每次输入其实都只有一个单词就结束了,当然每次输出都是1
你可以考虑用 while(gets(str)!=NULL) 来试试
另外这道题.即使你改了错误还是A不了的,因为要求的是不同的单词数,而你求的是所有的单词数,这里面是有区别的
你可以开一个二维数组,把每个单词都存进去,每次获得一个新单词时,往前比较,看看是否有出现过,若没有才word++;
AC的代码,我有,但是先不贴出来,acm 的代码自己实现比较好
如果有需要,你可以追问,我把AC的代码给你作参考
希望对你有帮助,加油acmer!
杭电acm 2034wrong answer Problem Description参加过上个月月赛的同学一定还记得其中
杭电acm 2034
wrong answer
Problem Description
参加过上个月月赛的同学一定还记得其中的一个最简单的题目,就是{A}+{B},那个题目求的是两个集合的并集,今天我们这个A-B求的是两个集合的差,就是做集合的减法运算.(当然,大家都知道集合的定义,就是同一个集合中不会有两个相同的元素,这里还是提醒大家一下)
Input
每组输入数据占1行,每行数据的开始是2个整数n(0
stlingg1年前1
今夜青稞 共回答了20个问题 | 采纳率95%
#include
#include
int comp(const void *a,const void *b)
{
return *(int *)a-*(int *)b;
}
int main(void)
{
int i,j,k,flag,m,n,a[100],b[100];
while(scanf("%d%d",&n,&m),n||m)
{
k=0;
flag=1;
for(i=0;i
杭电acm1124题意是什么啊
sansefangzhuo1年前1
鹅鹅鹅鹅 共回答了18个问题 | 采纳率88.9%
是求n!即n的阶乘的未尾有多少个0
比如5!=120
未尾是1个零
A+B for Input-Output Practice (VIII) 为什么 我在 杭电 上 做是 Presenta
A+B for Input-Output Practice (VIII) 为什么 我在 杭电 上 做是 Presentation Error!
Problem Description
Your task is to calculate the sum of some integers.
Input
Input contains an integer N in the first line,and then N lines follow.Each line starts with a integer M,and then M integers follow in the same line.
Output
For each group of input integers you should output their sum in one line,and you must note that there is a blank line between outputs.
Sample Input
3
4 1 2 3 4
5 1 2 3 4 5
3 1 2 3
Sample Output
10
15
6
Author
lcy
Recommend
JGShining
#include
int main( )
{
x05int a,b,i,j,m,n;
while(scanf("%d",&n)!=EOF)
x05{
x05x05for(j=0;j
sadkjhsdfigh1年前1
渔耕之家 共回答了13个问题 | 采纳率84.6%
#include
int main()
{
int N;
scanf("%d",&N);
while(N--)
{
int M,i,a,sum=0;
scanf("%d",&M);
for(i=0;i
杭电ACM FatMouse' Trade算法题
杭电ACM FatMouse' Trade算法题
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 37 24 35 2-1 -1
Sample Output
13.333

我的代码,请问哪里有错啊,谢谢
#include
int main(){
int m,i,j,k;
float rate,sum,ji,fi,t,n;
while(scanf("%f%d",&n,&m)&&n+1||m+1){
k=3*m,sum=0;
float a[k];
for(i=0;i
medivh1年前1
一片云儿 共回答了13个问题 | 采纳率100%
#include
int main(){
int m,i,j,k;
double rate,sum,ji,fi,t,n; // double型数据
while(scanf("%lf%d",&n,&m)!=EOF&&n+1||m+1){// 一直读到文件为用EOF
k=3*m,sum=0;
double a[k];// double型数据
for(i=0;iscanf("%lf%lf",&ji,&fi);
rate=ji/fi;
a[i]=rate,a[i+1]=ji,a[i+2]=fi;
}
for(i=0;ifor(j=i+3;jif(a[i] t=a[i],a[i]=a[j],a[j]=t;
t=a[i+1],a[i+1]=a[j+1],a[j+1]=t;
t=a[i+2],a[i+2]=a[j+2],a[j+2]=t;
}
//for(i=0;i//printf("%.2f ",a[i]);
for(i=0;iif(a[i+2]<=n)sum+=a[i+1],n-=a[i+2];
else{ sum+=n*a[i];break;}
}
printf("%.3fn",sum);
}
}
杭电大一的高数B1和微积分1一样吗
zhiwu831年前1
魔笛呜呜 共回答了14个问题 | 采纳率78.6%
不是的 高数针对是理工科学生 微积分针对的是文科学生,微积分只是高等数学内容中的一部分
杭电ACM 1051 求思路好像要用贪心法,能举例更好
bupthzl1年前1
吴越江春 共回答了21个问题 | 采纳率85.7%
把所有的木头按照长度大的在前面,长度小的在后面,长度一样的重的在前面,轻的在后面进行排序.
然后从第一个开始加工,setup time加1,如果一个被加工了,我们往后面看,把最近的下一个能直接加工的拿去加工,如此类推,直到最后.然后重新加工最前面那个未被加工的木头,setup time加1,如此类推直到所有木头都加工过为止
#include
#include
#include
typedef struct
{
int len;
int weight;
} wood;
int cmp(const void* a, const void* b)
{
wood* wa = (wood*)a;
wood* wb = (wood*)b;
if(wa->len!=wb->len)
return wb->len - wa->len;
return wb->weight - wa->weight;
}
int main()
{
int T,i,N,setup,m,j;
wood w[5000];
int used[5000];
scanf("%d",&T);
while(T--)
{
scanf("%d",&N);
for(i=0;i
杭电 ACM 小弟想知道为什么循环周期是49 呢,A number sequence is defined as fol
杭电 ACM
小弟想知道为什么循环周期是49 呢,
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
疯疯癫癫1234561年前1
pq53530389 共回答了14个问题 | 采纳率100%
首先 这是一个数列,也就是一系列的数,这个是句废话,但是必须得说其次,除了f1 和f2以外,每个数字都由前两个数字决定,这个是公式确定的也就是说,如果对于数列f1 f2 ..fa fb .fc fd 存在fa=fc且fd=fb 那么后续的一定循...
杭电2188题意不理解,做完后发现不对,不理解题意,谁知道请赐教.
喜欢小诺诺1年前1
冰千 共回答了22个问题 | 采纳率95.5%
#include
using namespace std;
int main() //0MS 0K 一道博弈题
{ //思路:面对1
杭电let the ballon rise哪里错了
杭电let the ballon rise哪里错了
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
treeinrain1年前1
carrie610 共回答了15个问题 | 采纳率93.3%
你的t没有赋初值,如果只有一个气球就会出现错误,因为你的内层循环不会执行.在max1=0;后面加上t=0;就可以了
麻烦各位帮我看一下杭电acm2034为什么总是Wrong Answer?
麻烦各位帮我看一下杭电acm2034为什么总是Wrong Answer?
/*
Problem Description
参加过上个月月赛的同学一定还记得其中的一个最简单的题目,就是{A}+{B},
那个题目求的是两个集合的并集,今天我们这个A-B求的是两个集合的差,就是做集合的减法运算.
(当然,大家都知道集合的定义,就是同一个集合中不会有两个相同的元素,这里还是提醒大家一下)
Input
每组输入数据占1行,每行数据的开始是2个整数n(0
cuisine1年前1
盛满水的花瓶鶄 共回答了19个问题 | 采纳率78.9%
太乱了……其实你根本不需要把数组移来移去的,这样会影响自己的思路,只要再开一个数组,里面只存0和1,来表示这个数要不要输出即可.按照你的思路,我改了这一部分for(k1=0;k1{
flag=0;
for(k4=0;k4 {
if(a[k1]==c[k4])
{

for(h=k1;h{
a[h]=a[h+1];
}
i--;
flag=1;
break;
}
}改完的程序会报PE,两个问题,最后输出数据的地方,%d后面跟了两个空格,要删掉一个;然后行末要输出回车.
杭电acm2034 这样写哪里错了、、、急啊···
杭电acm2034 这样写哪里错了、、、急啊···
Problem Description
参加过上个月月赛的同学一定还记得其中的一个最简单的题目,就是{A}+{B},那个题目求的是两个集合的并集,今天我们这个A-B求的是两个集合的差,就是做集合的减法运算.(当然,大家都知道集合的定义,就是同一个集合中不会有两个相同的元素,这里还是提醒大家一下)
Input
每组输入数据占1行,每行数据的开始是2个整数n(0
混不下去1年前1
慎勿作芬芳 共回答了22个问题 | 采纳率86.4%
你没有考虑m等于0的情款 ;比如输入:4 0 1 2 3 4 则输出应该为1 2 3 4
m=0时,你的程序不会执行for(j=n;j
杭电2067,题意要怎么理解?不需要你粘贴代码,只需要问题的理解.
杭电2067,题意要怎么理解?不需要你粘贴代码,只需要问题的理解.
杭电2067,题意要怎么理解,是不是指不过对角线,而到达终点的最短路径数?好像如果终点为(2,2),那么这样的路径数为4个?为什么会是4个,请指教.
如果终点为(3,3),那么对角线下是哪五条路径?一直不理解这个。可是好像还没有人回答出我想要的,你们说的我都懂,可是这道题目你们并没有讲出精髓所在啊,希望有人能够说得明白一点,
omua4u1年前3
boa8813 共回答了12个问题 | 采纳率83.3%
没有最短路径数的要求,只要能从左上角走到右下角即可,但不能超过对角线.不超过对角线 就是只在对角线的上边 或者 只在对角线的下边.所以乘以二.楼主可以随时 Hi 我啊.其这道题其实 就...
杭电ACM 2011 素数判定 输入任意两位数,都输出了"OK"
杭电ACM 2011 素数判定 输入任意两位数,都输出了"OK"
Problem Description
对于表达式n^2+n+41,当n在(x,y)范围内取整数值时(包括x,y)(-39<=x


Input
输入数据有多组,每组占一行,由两个整数x,y组成,当x=0,y=0时,表示输入结束,该行不做处理.



Output
对于每个给定范围内的取值,如果表达式的值都为素数,则输出"OK",否则请输出“Sorry”,每组输出占一行.




Sample Input
0 1
0 0




Sample Output
OK



#include
#include
int main()
{
int m,n,a,num,i,j;
num=0;
while(scanf("%d %d",&m,&n)!=EOF)
{
if(m==0&&n==0)
break;
for(i=m;i<=n;i++)
{
num=i*i+i+41;

for(j=1;j<=num;j++)
{
if(num%j==0)
a++;
else
;
}
}
if(a!=0)
printf("OKn");
else
printf("Sorryn");
}
return 0;
}




我觉得可能是循环出了问题,
sr5421年前1
qx_xu_069_zq1914 共回答了24个问题 | 采纳率87.5%
第一:判断素数时,应该试着整除2到num-1之间的数
循环这样写for(j=2;j
杭电acm1002解题思路.用C++
杭电acm1002解题思路.用C++
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
忧郁的巨蟹座1年前1
liliya924 共回答了13个问题 | 采纳率100%
#include
int main()
{
int a;
__int64 b,c;
scanf("%d",&a);
int i=0;
for(i=1;i
杭电ACM 第1009题 FatMouse' Trade
杭电ACM 第1009题 FatMouse' Trade
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
#define M 100
void main()
{
x05int m,n,i,k,j[M],f[M],t1,t2;
x05double a[M],temp,s;
x05while(scanf("%d%d",&m,&n)&&(m!=-1||n!=-1))
x05{
x05x05i=0;
x05x05k=n;
x05x05s=0;
x05x05while(k--)
x05x05{
x05x05x05scanf("%d%d",&j[i],&f[i]);
x05x05x05a[i]=(double)j[i]/f[i];
x05x05x05i++;
x05x05}
x05x05for(i=0;i
小甜饼ivy1年前1
kkk_ww 共回答了23个问题 | 采纳率87%
#define M 100改为1001
数组开小了
杭电acm题,怎么写input The inputs start with a line containing a si
杭电acm题,怎么写
input
The inputs start with a line containing a single integer n.Each of the n following lines contains one test case.Each test case consists of three integers 1
tramp_isz1年前1
saokangkang 共回答了19个问题 | 采纳率89.5%
AC去吧,如有吴,估计是结尾换行问题
#include
int main()
{
int n,i,a,b,c;
scanf("%d",&n);
for (i=0;i
杭电1097题目:下面是我的编程,求指教,为什么老师说time limited
杭电1097题目:下面是我的编程,求指教,为什么老师说time limited
Problem Description
lcy gives a hard puzzle to feng5166,lwg,JGShining and Ignatius:gave a and b,how to know the a^b.everybody objects to this BT problem,so lcy makes the problem easier than begin.
this puzzle describes that:gave a and b,how to know the a^b's the last digit number.But everybody is too lazy to slove this problem,so they remit to you who is wise.
Input
There are mutiple test cases.Each test cases consists of two numbers a and b(0
讨厌讨厌讨厌ll1年前1
lcdrotna 共回答了14个问题 | 采纳率92.9%
//
#include
int main()
{
int i, n, a, b;
while(scanf("%d%d", &a, &b) != EOF)
{
n = a % 10;
switch(n)
{
case 0:
case 1:
case 5:
case 6:
printf("%d", n); //尾数为0,1,5,6 时, a^b以后还是一样的
break;
case 2: //尾数为2
if(b % 4 == 0)printf("6");
else if(b % 4 == 1)printf("2");
else if(b % 4 == 2)printf("4");
else printf("8");
break;
case 3: //尾数为3
if(b % 4 == 0)printf("1");
else if(b % 4 == 1)printf("3");
else if(b % 4 == 2)printf("9");
else printf("7");
break;
case 4:
if(b % 2)printf("4");
else printf("6");
break;
case 7:
if(b % 4 == 0)printf("1");
else if(b % 4 == 1)printf("7");
else if(b % 4 == 2)printf("9");
else printf("3");
break;
case 8:
if(b % 4 == 0)printf("6");
else if(b % 4 == 1)printf("8");
else if(b % 4 == 2)printf("4");
else printf("2");
break;
case 9:
if(b % 2)printf("9");
else printf("1");
break;
}
printf("n");
}
}
//祝学习进步,更上一层楼 *^_^* !
杭电1222的具体翻译!
FINDNEMO1231年前1
lovemegume 共回答了24个问题 | 采纳率91.7%
问题描述
有一座山,旁边有n个洞,分别标记为0到n-1.
一只兔子必须躲在其中一个洞里面.一只狼以逆时针方向寻找这只兔子.它(狼)钻进去的第一个洞标记为0.然后他会每m个洞进去一个洞.例如,当m=2,n=6的时候,狼进去的洞依次为0,2,4,0.假如兔子躲在标记为1,3或5的洞里面,则她会存活.所以我们称这些洞为安全洞.
输入
输入以一个正整数P开始,表明测试数据的组数.然后接下来的P行,每行有2个正整数m和n.(0
杭电ACM1003题目意思Problem DescriptionGiven a sequence a[1],a[2],a
杭电ACM1003题目意思
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
灞桥区梁家街人1年前1
TT逸子 共回答了21个问题 | 采纳率90.5%
应该说是最大和的子序列,就是一个序列取它连续的一段数,要求和最大.
你没有理解case1输入数据的意思啊~
5 6 -1 5 4 -7
第一个5是表示这个test的序列长度,于是后面就输入了6 -1 5 4 -7这5个数字~
于是最大和是14,从6到4没有错.
最大和子序列用动规求解.很经典的动规
杭电acm2028 哪里错啦Problem Description求n个数的最小公倍数.Input输入包含多个测试实例,
杭电acm2028 哪里错啦
Problem Description
求n个数的最小公倍数.
Input
输入包含多个测试实例,每个测试实例的开始是一个正整数n,然后是n个正整数.
Output
为每组测试数据输出它们的最小公倍数,每个测试实例的输出占一行.你可以假设最后的输出是一个32位的整数.
Sample Input
2 4 6
3 2 5 7
Sample Output
12
70
Author
lcy
#include
long int divisor(long int m,long int n)
x05{
x05long int temp;
x05x05if(m
神之徒1年前1
ddchow 共回答了22个问题 | 采纳率81.8%
#include
#include
using namespace std;
int zhuan(int a,int b)
{
int c,d;
c=a;d=b;
while(a!=b)
{
if(a>b) a=a-b;
if(b>a) b=b-a;
}
return c/a*d;
}
int main()
{
int n,a,b,i;
cin>>n;
vectorv;
while(n--)
{
cin>>a;
for(i=0;i>b;
v.push_back(b);
}
b=v[0];
for(i=1;i
杭电ACM比赛的一道题目,A.Shooshuns and SequenceTime Limit :4000/2000ms
杭电ACM比赛的一道题目,
A.Shooshuns and Sequence
Time Limit :4000/2000ms (Java/Other) Memory Limit :524288/262144K (Java/Other)
Total Submission(s) :130 Accepted Submission(s) :34
Problem Description
One day shooshuns found a sequence of n integers,written on a blackboard.The shooshuns can perform one operation with it,the operation consists of two steps:
1 Find the number that goes k-th in the current sequence and add the same number to the end of the sequence;
2 Delete the first number of the current sequence.
The shooshuns wonder after how many operations all numbers on the board will be the same and whether all numbers will ever be the same.
Input
The first line contains two space-separated integers n and k (1≤k≤n≤105).
The second line contains n space-separated integers:a1,a2,...,an (1≤ai≤105) the sequence that the shooshuns found.
Output
Print the minimum number of operations,required for all numbers on the blackboard to become the same.If it is impossible to achieve,print -1.
Sample Input
3 2
3 1 1
3 1
3 1 1
Sample Output
1
-1
Source
Codeforces
我想知道怎么去确定一个最大的操作次数,若大于这个次数就判断为一直不相等,然后输出-1?
wuxinjian8881年前1
最真的我 共回答了17个问题 | 采纳率100%
经过刚才的讨论,大家都学习到了.希望你在ACM的道路上取得长足进步.
请教杭电ACM1003的题目意思?
请教杭电ACM1003的题目意思?
我看不懂题目的意思
Max Sum
Time Limit:2000/1000 MS (Java/Others) Memory Limit:65536/32768 K (Java/Others)
Total Submission(s):53856 Accepted Submission(s):12109
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
上帝之爱----0011年前1
ronazhao 共回答了12个问题 | 采纳率100%
首先,最上面的2是下面一共会给出几个例子的意思,其次,每行的例子的第一个数字的意思是该例有几个数,比如说5,就是说这个例子由5个数组成,最后,题目要我们输出的三个数分别表示:最大和的子序列,(就是一个序列取它连续的一段数,要求和最大)、最大和的子序列的开始位置、最大和的子序列的最后位置,比如第一个例子:5 6 -1 5 4 -7 最大和的子序列是:6+-1+5+4=14;开始位置是1;最后位置是4;再举个例子:3 -1 2 3 最大和的子序列是:2+3=5;开始位置是2;最后位置是3.
杭电ACM MAX SUM题目看不懂
杭电ACM MAX SUM题目看不懂
Max Sum
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 38673 Accepted Submission(s): 8367
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
就是那个举例怎么得到的搞不懂。跪求思路。好的话加分。(怕分被吞掉就不弄了)
woulf1年前1
SISISZ 共回答了12个问题 | 采纳率91.7%
就是求子序列的和的最大值,子序列必须是连续的,这样举例中就很容易理解了,6,-1,5,4,-7
自然是-7不要,其它都算进去,把-1也算进去是为了把6加进去
杭电ACM 1099题 题意是什么啊?看不懂.
杭电ACM 1099题 题意是什么啊?看不懂.
晕,我说的就是那道题.
但是它的英文描述我看不懂……
fzhen1年前1
AnderSven 共回答了22个问题 | 采纳率90.9%
下次麻烦把题目拷上来,至少拷一个地址.
计算n*(1/1+1/2+.1/n)
杭电OJ的第2007题出错了吗?求高手看看输出结果里面的 4 28 20 152都是怎么出来的?
杭电OJ的第2007题出错了吗?求高手看看输出结果里面的 4 28 20 152都是怎么出来的?
Problem Description给定一段连续的整数,求出他们中所有偶数的平方和以及所有奇数的立方和.Input输入数据包含多组测试实例,每组测试实例包含一行,由两个整数m和n组成.Output对于每组输入数据,输出一行,应包括两个整数x和y,分别表示该段连续的整数中所有偶数的平方和以及所有奇数的立方和.你可以认为32位整数足以保存结果.Sample Input1 3 2 5Sample Output4 28 20 152
sz听海1年前1
最无好息 共回答了22个问题 | 采纳率90.9%
sample1: 2^2=41^3+3^3=28 sample2: 2^2+4^2=20 3^3+5^3=27+125=152
记得采纳啊
初一应用题.请列式解答.应用题1、某商品的进价是500元,标价为725元,杭电要求一下利润不低于16%的售价打折出售,则
初一应用题.请列式解答.应用题
1、某商品的进价是500元,标价为725元,杭电要求一下利润不低于16%的售价打折出售,则售货员最低可以打几折出售此商品?
2、某书店在促销活动中,推出一种优惠卡,每张卡售价20元,凭此卡可享受八折优惠.有一次,他先买卡后付款,结果节省了人民币12元,那么李明同学此次购书的总价值是多少钱?
3.一队旅客乘坐汽车,要求每辆汽车的旅客人数相等,起初每辆汽车乘了22人,结果剩下1人为上车;如果有一辆汽车空着开走,那么所有旅客正好能平均分乘到其他各车上,已知每辆汽车最多只能容纳32人,求起初有多少辆汽车?有多少名旅客?
hongch-pc1年前1
徐大傻子 共回答了18个问题 | 采纳率94.4%
1. 500*16%=80元
即最低卖 580元
(725-580)/725=0.2
所以最低打8折
2 设该书总价值x元
x-x*0.8-20=12
所以 x=160元
3 设有x辆汽车,则旅客为 22x+1
因为少一辆车后,需要把23名旅客平均分配给其他车
所以,剩下只可能有23辆车才能分完
即起初有24辆车
共有22*24+1=525位旅客
杭电1007 题干看不懂 用上面的两组数字 怎么算出下面的两组 请懂的人赐教
杭电1007 题干看不懂 用上面的两组数字 怎么算出下面的两组 请懂的人赐教
Problem Description
给定一段连续的整数,求出他们中所有偶数的平方和以及所有奇数的立方和.
Input
输入数据包含多组测试实例,每组测试实例包含一行,由两个整数m和n组成.
Output
对于每组输入数据,输出一行,应包括两个整数x和y,分别表示该段连续的整数中所有偶数的平方和以及所有奇数的立方和.
你可以认为32位整数足以保存结果.
Sample Input
1 3
2 5
Sample Output
4 28
20 152
a78265711年前1
jqk5241 共回答了24个问题 | 采纳率91.7%
就是m开始的n个数
1 3 -> 1 2 3
2 5 -> 2 3 4 5
2*2=4 1*1*1+3*3*3=28
2*2+4*4=20 3*3*3+5*5*5=152
杭电acm上的2062求解答Problem DescriptionConsider the aggregate An=
杭电acm上的2062求解答
Problem Description
Consider the aggregate An= { 1, 2, …, n }. For example, A1={1}, A3={1,2,3}. A subset sequence is defined as a array of a non-empty subset. Sort all the subset sequece of An in lexicography order. Your task is to find the m-th one.

Input
The input contains several test cases. Each test case consists of two numbers n and m ( 0< n
cnhncgh1年前1
遛马人 共回答了14个问题 | 采纳率100%
给你一个Testcase
Sample Input
11
Sample Output
20 71111
// 最小数远比你想想的复杂
#include
int main()
{
int n,m,bg,i;
while(scanf("%d",&n)==1)
{
m=n;
bg = 1;
while(m!=0)
{
if(m<=7)
{
switch(m)
{
case 2:printf("1"); break;
case 3:printf("7"); break;
case 4:printf("4"); break;
case 5:printf("2"); break;
case 6:if(bg) printf("6"); else printf("0"); break;
case 7:printf("8"); break;
}
m=0;
}
else
{
switch(m%7)
{
case 1:printf("10"); m-=8; break;
case 2:printf("1"); m-=2; break;
case 3:
case 4:
case 5:if(bg) else break;
case 6:if(bg) printf("6"); else printf("0"); m-=6; break;
case 0:printf("8"); m-=7; break;
}
}
bg = 0;
}
printf(" ");
if (n%2==0)
{
for (i=0;iprintf("1");
}
else
{
printf("7");
for (i=0;i<(n-3)/2;i++)
printf("1");
}
printf("n");
}
}
杭电2845题时什么意思啊,我看啦好多片就是看不懂,哪位英语好的帮帮忙
djcontinue1年前1
诺尼 共回答了22个问题 | 采纳率86.4%
有一个M×N的矩阵,每一格上放着不同数量的豆,你可以吃这些豆,但是如果你吃了一个格子上的豆,那么你就不能吃这个格子左边那个格子里面的豆和右边那个格子里面的豆,而且你不能吃上面一整行的豆,和下面一整行的豆
1 2 3 4 5 6
7 8 9 0 1 2
2 3 4 5 6 7
1 1 1 1 1 1
+表示你吃的,#表示你吃了那颗之后就不能吃的
# # # # # #
7 # + # 1 2
# # # # # #
1 1 1 1 1 1
求最多能吃几颗
杭电2+2的高数难不难,高数是不是有A,B,C三种,杭电是怎样的啊
moshang1年前1
bimengjushou 共回答了16个问题 | 采纳率93.8%
杭电分高数一,高数甲乙丙类型,一般理学院或是电子计算机方面的学高数一,其他大部分 学高数甲,就算你是文课专业的也得学高数甲,因为杭电偏理!
当然有些 是在是不行的专业会可能学高数乙,但是我没见过.
杭电acm 1097T 这个代码为什么错误?
杭电acm 1097T 这个代码为什么错误?
Input
There are mutiple test cases. Each test cases consists of two numbers a and b(0
何忘川1年前1
cheter 共回答了19个问题 | 采纳率89.5%
如果我输入a的是2^30 ,b是9,那会出现什么结果?
2^30*9>2^31~~溢出,那LZ明白了把?
那会改了把?
请问杭电ACM1024题根据那个状态转移方程怎么确定初始值,以及好像根据那个转移方程每个数都要用上……为啥
请问杭电ACM1024题根据那个状态转移方程怎么确定初始值,以及好像根据那个转移方程每个数都要用上……为啥
就是每个数都是在那两种情况中选一种被加在里面……然后得出一个二维数组某个最大值……我对动态规划一直都不是很明白,更不要说拿它来做题,
Max Sum Plus Plus
Problem Description
Given a consecutive number sequence S1,S2,S3,S4 ...Sx,...Sn (1 ≤ x ≤ n ≤ 1,000,000,-32768 ≤ Sx ≤ 32767).We define a function sum(i,j) = Si + ...+ Sj (1 ≤ i ≤ j ≤ n).
Now given an integer m (m > 0),your task is to find m pairs of i and j which make sum(i1,j1) + sum(i2,j2) + sum(i3,j3) + ...+ sum(im,jm) maximal (ix ≤ iy ≤ jx or ix ≤ jy ≤ jx is not allowed).
But I`m lazy,I don't want to write a special-judge module,so you don't have to output m pairs of i and j,just output the maximal summation of sum(ix,jx)(1 ≤ x ≤ m) instead.
Input
Each test case will begin with two integers m and n,followed by n integers S1,S2,S3 ...Sn.
Process to the end of file.
Output
Output the maximal summation described above in one line.
Sample Input
1 3 1 2 3
2 6 -1 4 -2 3 -2 3
状态转移方程:B[i][j]=max{B[i][j-1]+A[j],B[i-1][t]+A[j] (i-1
如石恐龙1年前1
tekken2002 共回答了22个问题 | 采纳率95.5%
我打算今晚就做这道题!如果我做出来的话!就和你分享吧!问题真的比较难!
尽量做吧!尽量参考别人的代码吧!
杭电1164不知道我的程序为什么这样?希望大家帮我看看!
杭电1164不知道我的程序为什么这样?希望大家帮我看看!
/*
Problem Description
Eddy's interest is very extensive,recently he is interested in prime number.
Eddy discover the all number owned can be divided into the multiply of prime number,
but he can't write program,so Eddy has to ask intelligent you to help him,
he asks you to write a program which can do the number
to divided into the multiply of prime number factor .
Input
The input will contain a number 1 < x<= 65535 per line
representing the number of elements of the set.
Output
You have to print a line in the output for each entry with the answer
to the previous question.
Sample Input
11
9412
Sample Output
11
2*2*13*181
*/
#include
#define MAX 5000
int n;
int boolean(int nn,int k,int *prime)
{
x05int i,flag=0;
x05for(i=0;ix05{
x05x05if(nn==prime[i])
x05x05{
x05x05x05flag=1;
x05x05x05break;
x05x05}
x05}
x05return flag;
x05
}
void calculate(int *prime,int *key,int k)
{
x05
x05int i,j;
x05for(i=0,j=0;ix05{
x05x05if(n%prime[i]==0)
x05x05{
x05x05x05key[j]=prime[i];
x05x05x05printf("%d*",key[j]);
x05x05x05j++;
x05x05x05n=n/prime[i];
x05x05x05if(boolean(n,k,prime))
x05x05x05{
x05x05x05x05
x05x05x05x05key[j]=n;
x05x05x05x05printf("%dn",key[j]);
x05x05x05x05break;
x05x05x05}
x05x05x05else
x05x05x05{
x05x05x05x05calculate(prime,key+j,k);
x05x05x05}
x05x05x05
x05x05}
x05}
}
int main(int argn,char *args[])
{


x05int i;
x05int j;
x05int k;
x05int prime[MAX];
x05int key[MAX];
x05while(scanf("%d",&n)!=EOF)
x05{
x05x05for(i=2,k=0;i<=n;i++)//用prime数组存放所有n(包括n)之前的所有素数
x05x05{
x05x05x05for(j=2;jx05x05x05{
x05x05x05x05if(i%j==0)
x05x05x05x05{
x05x05x05x05x05break;
x05x05x05x05}
x05x05x05}
x05x05x05if(j==i)
x05x05x05{
x05x05x05x05prime[k]=i;
x05x05x05x05k++;
x05x05x05}
x05x05}


x05x05if(boolean(n,k,prime))
x05x05{
x05x05x05printf("%dn",n);
x05x05}
x05x05else
x05x05{
x05x05x05calculate(prime,key,k);
x05x05x05x05
x05x05}


x05x05


x05}




x05return 0;
}




结果为什么会多一个呀?
eryan06011年前1
麟栾 共回答了24个问题 | 采纳率95.8%
/*
Problem Description
Eddy's interest is very extensive, recently he is interested in prime number.
Eddy discover the all number owned can be divided into the multiply of prime number,
but he can't write program, so Eddy has to ask intelligent you to help him,
he asks you to write a program which can do the number
to divided into the multiply of prime number factor .
Input
The input will contain a number 1 < x<= 65535 per line
representing the number of elements of the set.
Output
You have to print a line in the output for each entry with the answer
to the previous question.
Sample Input
11
9412
Sample Output
11
2*2*13*181
*/
#include
#define MAX 65536
int n;

int boolean(int nn, int k, int *prime)
{
int i, flag = 0;
for (i = 0; i < k; i++)
{
if (nn == prime[i])
{
flag = 1;
break;
}
}
return flag;
}

void calculate(int *prime, int *key, int k)
{
int i, j;
for (i = 0, j = 0; i < k; i++)
{
if (n%prime[i] == 0)
{
key[j] = prime[i];
printf("%d*", key[j]);
j++;
n = n / prime[i];
if (boolean(n, k, prime))
{
key[j] = n;
printf("%dn", key[j]);
break;
}
// 这里无需递归,直接把i倒回去就可以了
i--;
}
}
}

int main(int argn, char *args[])
{

int i;
int j;
int k;
int prime[MAX];
int key[MAX];
n = MAX;
for (i = 2, k = 0; i <= n; i++)//用prime数组存放所有n(包括n)之前的所有素数
{
for (j = 2; j < i; j++)
{
if (i%j == 0)
{
break;
}
}
if (j == i)
{
prime[k] = i;
k++;
}
}
while (scanf("%d", n) != EOF)
{
if (boolean(n, k, prime))
{
printf("%dn", n);
}
else
{
calculate(prime, key, k);
}
}
return 0;
}
杭电acm题1407,求得最小解,是在x
峰人ee1年前1
彩色的空白 共回答了23个问题 | 采纳率91.3%
在x
杭电ACM,1002题,总是格式错误
杭电ACM,1002题,总是格式错误
Input
Input contains an integer N in the first line,and then N lines follow.Each line starts with a integer M,and then M integers follow in the same line.
我的程序:
Output
For each group of input integers you should output their sum in one line,and you must note that there is a blank line between outputs.
#include"stdio.h"
#define N 100
int main()
{int n,m,i,j,sum[N]={0},a;
scanf("%d",&m);
for(j=0;j
feijke1年前1
628585 共回答了17个问题 | 采纳率100%
#include"stdio.h"
#define N 100
int main()
{
int n,m,i,j,sum[N]={0},a;
scanf("%d",&m);
for(j=0;j
杭电的1005题 我不需要代码 请各位给我讲讲思路和做法
杭电的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).
如果就按它那么写的话会超时
我知道有很多解题报告 但是我想请你们先给我讲讲思路 然后我再试着自己去尝试
我将长大1年前1
opensonic 共回答了18个问题 | 采纳率94.4%
这题的关键就在于时间,因为n可能很大很大.
但因为有mod 7,所以f(n)取值是0-6,共7个取值,而f(n)又由f(n-1) 和 f(n-2)两个决定,因此最多有7*7=49种可能的组合,因此在50以内必然出现循环,
所以我们用数组模拟前49组数组,后面的数据只要mod (模除)循环节就可以了,对应的的数组里头取值
杭电OJ 3177题老是WA,/*思路:贪心算法,我们每次搬运想到就是使剩余的洞穴空间尽量大,当有两件物品时,有如下信息
杭电OJ 3177题老是WA,
/*
思路:贪心算法,我们每次搬运想到就是使剩余的洞穴空间尽量大,当有两件物品时,有如下信息
A a1 b1
B a2 b2
加入先搬A,则搬运过程中瞬间占用空间最大为a1+b2,如果先搬运B,
则这一个瞬间最大占用体积为a2+b1,我们想使剩下的体积尽量大,所以我们选择min(a1+b2,a2+b1),如果先选A,
则有a1+b2b2-a2,所以我们可以看出,应该先选搬运体积和本身体积差值最大的贪心,由此得到最优搬运顺序!
*/
#include
typedef struct node{
int a;
int b;
int c;
}Node;
int quicksort(Node a[],int s,int e);
int main()
{
int v,n;
int t;
int i;
int flag;
Node a[1000];
scanf("%d",&t);
while(t--)
{
scanf("%d%d",&v,&n);
for(i=0;iv)flag=0;
else v-=a[i].a;
}
//开始逐个放进洞里.
if(flag)printf("Yesn");
else printf("Non");
}
return 0;
}
int quicksort(Node a[],int s,int e)
{
int f,b,key;
Node m,n;
f=s+1;
b=e;
key=a[s].c;
n=a[s];
if(s>=e)return 0;
while(f
7ujmuhk1年前1
娃哈哈xz556 共回答了23个问题 | 采纳率95.7%
排序法确实有问题
while(f
ACM题目:请问杭电1358的题目意思是什么?
ACM题目:请问杭电1358的题目意思是什么?
以下是题目:
Description
For each prefix of a given string S with N characters (each character has an ASCII code between 97 and 126,inclusive),we want to know whether the prefix is a periodic string.That is,for each i (2
dora2001sp1年前1
烽子 共回答了22个问题 | 采纳率77.3%
KMP,求一个串的重复子串,百度,题解一大堆
杭电acm2034基础题 C++,求改错
杭电acm2034基础题 C++,求改错
Problem Description
参加过上个月月赛的同学一定还记得其中的一个最简单的题目,就是{A}+{B},那个题目求的是两个集合的并集,今天我们这个A-B求的是两个集合的差,就是做集合的减法运算.(当然,大家都知道集合的定义,就是同一个集合中不会有两个相同的元素,这里还是提醒大家一下)
Input
每组输入数据占1行,每行数据的开始是2个整数n(0
xjie183161年前1
swsyjy 共回答了17个问题 | 采纳率88.2%
#include
int main()
{
int a,b,i,n,e,j,temp;
int f[1000],g[1000],h[1000];
while(scanf("%d%d",&a,&b)!=EOF)
{
if(a==0&&b==0) break;
for(i=0;i
杭电ACM 2026输入一个英文句子,将每个单词的第一个字母改成大写字母.Input输入数据包含多个测试实例,每个测试实
杭电ACM 2026
输入一个英文句子,将每个单词的第一个字母改成大写字母.
Input
输入数据包含多个测试实例,每个测试实例是一个长度不超过100的英文句子,占一行.
Output
请输出按照要求改写后的英文句子.
example Input
i like acm
i want to get an acceptedSample Output
I Like Acm
I Want To Get An Accepted
代码
#include
main()
{
char a[100];
int b,c,d,i,j;
while(scanf("%s",&a)!=EOF)
{
printf("%c",a[0]-32);
for(i=1;i
梦之魂1年前1
wangheng 共回答了25个问题 | 采纳率80%
#include
main()
{
char a[100];
int b,c,d,i,j;
while(gets(a)) // 换成gets
{
if(a[0]==0) {printf("n");continue;} // 如果是空行, 直接换行继续
if(a[0]>='a'&&a[0]
杭电acm 1216 怎样用链表解决 满意者追加30分或更多!
杭电acm 1216 怎样用链表解决 满意者追加30分或更多!
原题:http://acm.hdu.edu.cn/showproblem.php?pid=1216
assistance required
problem description
after the 1997/1998 southwestern european regional contest (which was held in ulm) a large contest *** took place. the organization team invented a special mode of choosing those participants that were to assist with washing the dirty dishes. the contestants would line up in a queue, one behind the other. each contestant got a number starting with 2 for the first one, 3 for the second one, 4 for the third one, and so on, consecutively.
the first contestant in the queue was asked for his number (which was 2). he was freed from the washing up and could *** on, but every second contestant behind him had to go to the kitchen (those with numbers 4, 6, 8, etc). then the next contestant in the remaining queue had to tell his number. he answered 3 and was freed from assisting, but every third contestant behind him was to help (those with numbers 9, 15, 21, etc). the next in the remaining queue had number 5 and was free, but every fifth contestant behind him was selected (those with numbers 19, 35, 49, etc). the next had number 7 and was free, but every seventh behind him had to assist, and so on.
let us call the number of a contestant who does not need to assist with washing up a lucky number. continuing the selection scheme, the lucky numbers are the ordered sequence 2, 3, 5, 7, 11, 13, 17, etc. find out the lucky numbers to be prepared for the next contest ***.

input
the input contains several test cases. each test case consists of an integer n. you may assume that 1
m4861年前1
NOMAN_200 共回答了15个问题 | 采纳率93.3%
这道题确实是用链表做的,用链表进行筛选法筛数.题目比较简单,下面的代码使用数组模拟链表的程序.此题也跟POJ的2552题相同!
---------------------------------------------------
#include
#include
#include
int top;
int res[3011];
struct Node{
int v;
int next;
};
Node L[50001];
int N;int main()
{
int i,j,k,p;
for(i=2;i=3001 ) break;
j=i;
while(L[j].next!=-1)
{
k=0;
while(L[j].next!=-1&&k
转动惯量的测定实验 杭电(胡建人)版本
转动惯量的测定实验 杭电(胡建人)版本
转动惯量的测定实验,如果转轴偏离长细棒的中心,实验测得的细棒转动惯量与理论值1/2 m l方 比较是偏大还是偏小 为什么 分析讨论题 第二题
Lily_zou1年前1
year777 共回答了16个问题 | 采纳率93.8%
偏大,设转轴偏离长细棒的中心x,那么,设想在长的一端切下长度为x的一端,粘在短的一端,则恢复为原来的样子,但这一段在切下前距离细棒的中心的距离比粘在短的一端时远,对转动惯量贡献大,因此如果转轴偏离长细棒的中心,实验测得的细棒转动惯量与理论值1/12 m l^2 比较是偏大.
求杭电ACM 1050这道题的解题思路?
2710665711年前1
至少还有狼 共回答了18个问题 | 采纳率88.9%
贪心,把过道分成好多格子,每一次搬的时候给经过的格子加1,最后统计一下哪个格子计数最多.
杭电acm2034题的意思是什么
a3803901年前2
hbczzr 共回答了10个问题 | 采纳率90%
差集定义:一般地,设A,B是两个集合,由所有属于A且不属于B的元素组成的集合,叫做集合A减集合B(或集合A与集合B之差),类似地,对于集合A.B,我们把集合{x/x∈A,且x¢B}叫做A与B的差集,记作A-B.
下面是我以前写的一份代码,供共你参考:
#include
int main(void)
{
int m,n,i,j,k,t;
int num1[105],num2[105],result[105];
while (scanf("%d%d",&n,&m) != EOF && (n + m) != 0)
{
for (i=0; i
杭电数学建模课程怎么算期末成绩?一次点名占期末多少分?
杭电数学建模课程怎么算期末成绩?一次点名占期末多少分?
那总分是多少啊?
liuxiaofang10101年前1
haoqjy 共回答了20个问题 | 采纳率90%
100