【ACM】ACM steps 1.1.8

桃花潭水深千尺,不及AC送我情~
A+B for Input-Output Practice (VIII)

Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 40850 Accepted Submission(s): 12244

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
解:

#include
void main()
{
int n,i,j,t,sum,a,out[1000],q;
sum=0;
scanf(“%dn”,&n);
for (i=0;i<n;i++)
{
scanf(“%d”,&j);
for (t=0;t<j;t++)
{
scanf(“%d”,&a);
sum=sum+a;
out[i]=sum;
}
sum=0;
}
q=n-1;
for (i=0;i<q;i++)
{
printf(“%dnn”,out[i]);
}
printf(“%dn”,out[q]);
}

唔,写的比较麻烦。一开始试提示有格式错误.检查了一下,发现是最后面多了一行空行,RT。

当时源代码是这样的:
后来没有很好的解决方法,于是就用了一个笨办法:
于是就变成了这样:
但是HDOJ还是提示格式错误,于是突发奇想在最后的输出那里加了一个n。于是就AC了……
格式错误的原因是最后没有换行……
感觉这个代码好乱,又整理了另外的一个写法:
#include
int main()
{
    int a,b,i,j,l[1000],k;
    scanf(“%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(“%dnn”,l[j]);
    printf(“%dn”,l[i]);
}

至此,ACM steps1 系列的题目全部AC~撒花~

【ACM】ACM steps 1.1.7

A+B for Input-Output Practice (VII)

Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 19199 Accepted Submission(s): 12214

Problem Description
Your task is to Calculate a + b.

Input
The input will consist of a series of pairs of integers a and b, separated by a space, one pair of integers per line.

Output
For each pair of input integers a and b you should output the sum of a and b, and followed by a blank line.

Sample Input
1 5
10 20

Sample Output
6

30
参考题解:

#include
void main()
{
int a,b,sum;
while(scanf(“%d%d”,&a,&b)!=EOF)
{
sum=a+b;
printf(“%dn”,sum);
printf(“n”);
}
}
 很简单的一道题……
但是有更简单的做法
#include
 main()
 {
    int a,b;
   while(scanf(“%d%d”,&a,&b)!=EOF)
   printf(“%dnn”,a+b);
 }

这貌似是这道题最简单的做法了……

【ACM】ACM steps 1.1.6

A+B for Input-Output Practice (VI)

Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 18437 Accepted Submission(s): 12465

Problem Description
Your task is to calculate the sum of some integers.

Input
Input contains multiple test cases, and one case one line. Each case starts with an integer N, and then N integers follow in the same line.

Output
For each test case you should output the sum of N integers in one line, and with one line of output for each line in input.

Sample Input
4 1 2 3 4
5 1 2 3 4 5

Sample Output
10
15
参考题解:

#include
int main()
{
int n,i,sum,t;
sum=0;
while(scanf(“%d”,&n)!=EOF)
{
for(i=0;i

这道题纠结了好久……一开始的写法是这样的,但是一直没有找到错误。

#include
int main()
{
int n,i,sum,t;
sum=0;
while(scanf(“%d”,&n)!=EOF);
{
for(i=0;i

但是HDOJ一直提示WA,也没有找到那里有错误。请教了一下学长,找了好久终于发现while语句后面不应该有分号,否则不会有任何输出…………

鲜血的教训啊……

另附一个正确的写法:

#include
void main()
{
int n,a,i,sum;
while(scanf(“%d”,&n)!=EOF)
{
sum=0;
for(i=0;i
	

【ACM】ACM steps 1.1.5*

A+B for Input-Output Practice (V)

Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 18072 Accepted Submission(s): 13110

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 with one line of output for each line in input.

Sample Input
2
4 1 2 3 4
5 1 2 3 4 5

Sample Output
10
15

Author
lcy

参考题解:

#include
int main()
{
    int n,a,b,i,j,sum;
    sum=0;
    while(scanf("%dn",&n)!=EOF)
    {
        for(i=0;i

唔,九点了。感觉有点不在状态。本来打算今天刷完第一系列的,现在看看能刷到多少吧……
这道题也不是很难,尤其是有前一题做铺垫,注意有时候该写注释的写注释,定义的变量太多的话自己会晕掉的= =  。还有就是要注意最后还要对sum进行初始化。

【ACM】ACM steps 1.1.4*

A+B for Input-Output Practice (IV)

Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 25266 Accepted Submission(s): 13962

Problem Description
Your task is to Calculate the sum of some integers.

Input
Input contains multiple test cases. Each test case contains a integer N, and then N integers follow in the same line. A test case starting with 0 terminates the input and this test case is not to be processed.

Output
For each group of input integers you should output their sum in one line, and with one line of output for each line in input.

Sample Input
4 1 2 3 4
5 1 2 3 4 5
0

Sample Output
10
15

参考题解:

#include 
int main()
{
    int n,sum,i,t;
    while(scanf("%d",&n)!=EOF)
    {
        if(n==0) break;
            sum=0;
        for(i=0;i<n;i++)
        {
            scanf("%d",&t);
            sum=sum+t;
        }
        printf("%dn",sum);
    }
}

!=EOF的作用就是一直读到文件的末尾,还有就是要注意if(n==0) break;要直接放在while语句的下面。且这个语句后面要加分号。

【ACM】ACM steps 1.1.3

A+B for Input-Output Practice (III)

Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 28263 Accepted Submission(s): 15357

Problem Description
Your task is to Calculate a + b.

Input
Input contains multiple test cases. Each test case contains a pair of integers a and b, one pair of integers per line. A test case containing 0 0 terminates the input and this test case is not to be processed.

Output
For each pair of input integers 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 input.

Sample Input
1 5
10 20
0 0

Sample Output
6
30

解:

#include
 int main()
 {
    int a,b;
    scanf("%d %d",&a,&b);
    while(!(a==0&&b==0))
    {
    printf("%dn",a+b);
     scanf("%d %d",&a,&b);
    }
 }
华丽丽的一次过,没什么好说的……貌似之前的两题在wp上发表的时候格式有点问题……已经修正这个问题了~

【ACM】 ACM steps 1.1.2

1.1.2 A+B for Input-Output Practice (II)

 

Problem Description

Your task is to Calculate a + b.

 

Input

Input contains an integer N in the first line, and then N lines follow. Each line consists of a pair of integers a and b, separated by a space, one pair of integers per line.

Output

For each pair of input integers 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 input.

Sample Input

2

1 5

10 20

Sample Output

6

30

Author

lcy

Recommend

JGShining

解:

#include
#define M 1000
int main()
{
int a,b,i,j,sum[M];//一维数组来解
scanf("%d",&i);
for(j=0;j

简单的一维数组的应用,注意while语句不要直接把自增循环写进去,这道题又没有一次过,原因又是低级错误,一开始我还以为HDOJ不能把注释写进去呢……

【ACM】ACM steps 1.1.1

从今天开始做steps上面的题目了。大体看了一下难度,感觉不是很难,现在都是一些A+B的题目,争取一次过掉。把源码发在这里,再写几句解题心得什么的……

1.1.1A+B for Input-Output Practice (I)

 

Problem Description

Your task is to Calculate a + b.
Too easy?! Of course! I specially designed the problem for acm beginners.
You must have found that some problems have the same titles with this one, yes, all these problems were designed for the same aim.

 

 

Input

The input will consist of a series of pairs of integers a and b, separated by a space, one pair of integers per line.

Output

For each pair of input integers 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 input.

Sample Input

1 5

10 20

Sample Output

6

30

Author

lcy
参考代码:

#include
 int main()
 {
    int a,b;
   while(scanf("%d%d",&a,&b)!=EOF)
   printf("%dn",a+b);
 }

 

最简单的题目了,没什么好说的,注意while语句后面不要加分号,一开始居然错在这上面了………………

当小白兔遇上大灰狼

欢乐的视频开场

转自PKAV技术宅小组,感谢@only_guest

=========我是罪恶的分割线==========

RT,这类信息你是不是也收到过?!

唔,QQ上最近出现了好多这类的信息。一般都是通过做一个假的空间登陆页面来获取用户的QQ密码一类诈骗。如图示:

昨晚,又收到了一条这类的消息。本打算默默回句话提醒一下对方改改密码,岂不知那盗号的居然还没有下线。于是就有了如下的对话……

盗号的好嚣张!!貌似到这里盗号者灰溜溜的下线了?!

所以今天写这篇文章的目的就是告诉大家这类链接背后的故事……

============我是正文的分割线==============

鸣谢PKAV技术宅小组提供的视频演示~

 

看到这里一定有人会说:既然这么恐怖,那么我们小白兔又改如何防御呢?

答案是:无法防御,防不胜防……

但是我们可以尽可能的不让自己上当~尽管小白兔无法与大灰狼匹敌,但是至少我们可以做到不去点陌生的链接,不去随便输自己的用户名密码。然后嘛,把这些诈骗的信息发给技术大牛来解决。

最后,为了更多的小伙伴们的账号安全,用力的转起吧!

欢迎↓点击下面↓的分享到按钮分享~



昨日黑莓,明日黄花

本文全文转载自微信公众号:MACtalk。

今天看到一则消息,黑莓正式宣布裁员40%,将近4500人失去了在黑莓工作的机会。根据媒体报道,黑莓第二季度的营收仅为16亿美元,手中的现金只能维持16个月的光景,裁员是避免公司进一步下滑的措施之一。何去何从?已经是摆在黑莓桌面上的生死难题。

 

黑莓手机一度是智能手机的品牌代表,独特的全键盘用户体验和安全特性,让很多公司为他们的商业精英配备了黑莓手机,他们一边开会一边在黑莓上打字,拇指上下翻飞,一条条短信和邮件顺着手臂、拇指流到键盘和屏幕上,各种事务和业务在黑莓上流转,我曾经看到一位国外的媒体人员用黑莓手机敲敲打打写出了一篇新闻稿,长达几十屏,由于身边没有小伙伴,只好自己惊呆了。

 

黑莓手机成了个人电脑的有效补充,在智能手机界一时间谈笑有鸿儒,往来无白丁,高端大气不做他想。

 

如果这个世界上没有出现 iOS 和 Android,现在的黑莓一定风光无限。这个假想同样适用于坚硬的诺基亚和明媚的摩托罗拉。可惜2007年 iOS 伴随着 iPhone 横空出世,一年后 Android 问世。那时候这些手机巨头的想法是:

 

「现在我们一年要卖出好几百万台智能手机,苹果连一部都还没卖出去」

「技术上很难实现,他们的手机续航时间可能只能支持一天,有多少用户会购买这样的手机呢」

「他们试图把电脑塞进手机里,太可笑了」

 

现在的想法是:

 

「我们再也不是一家充满创新活力的公司」

「客观地说,iPhone 的出现让我们措手不及」

「他们赢了」

 

iPhone 从2007年起步,历时6年,时至今日,与 Android 一起横扫天下。历史为这些公司预留了足够的时间,但是非常遗憾,没有人去打开时间之门。

 

 

半冷半暖秋天,熨帖在你身边

静静看着流光飞舞

那风中一片片红叶,惹心中一片绵绵

半醉半醒之间,再忍笑眼千千

 

今日依然流光飞舞,但是昨日黑莓,可能已是明日黄花。