偶数求和

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)

Total Submission(s): 69010    Accepted Submission(s): 29401
Problem Description
有一个长度为n(n<=100)的数列,该数列定义为从2开始的递增有序偶数,现在要求你按照顺序每m个数求出一个平均值,如果最后不足m个,则以实际数量求平均值。编程输出该平均值序列。
 
Input
输入数据有多组,每组占一行,包含两个正整数n和m,n和m的含义如上所述。
 
Output
对于每组输入数据,输出一个平均值序列,每组输出占一行。
 
Sample Input
3 2
4 2
 
Sample Output
3 6
3 7
 
Author
lcy
 
Source
 
Recommend
lcy   |   We have carefully selected several similar problems for you:  2016 2017 2018 2021 2023 
一会就吃饭了,开始做点水题!!水水更健康

#include<stdio.h>
#include<string.h>
#include<algorithm>
using namespace std;
int main()
{
int n,m;
int num[10010];
while(scanf("%d%d",&n,&m)!=EOF)
{
int cnt=0;
int i=2;
while(i<=2*n)
{
int s=m;
int sum=0;
int j;
for(j=1;j<=s&&i<=2*n;j++)
{
sum+=i;
i+=2;
}
sum/=(j-1);
num[cnt++]=sum;
}
printf("%d",num[0]);
for(int i=1;i<cnt;i++)
printf(" %d",num[i]);
printf("\n");
}
return 0;
}

hdoj--2015--偶数求和(水题)的更多相关文章

  1. HDOJ 2015 偶数求和

    Problem Description 有一个长度为n(n<=100)的数列,该数列定义为从2开始的递增有序偶数,现在要求你按照顺序每m个数求出一个平均值,如果最后不足m个,则以实际数量求平均值 ...

  2. 2015 偶数求和 AC 杭电

    偶数求和 Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Total Submi ...

  3. HDU 2015 偶数求和

    http://acm.hdu.edu.cn/showproblem.php?pid=2015 Problem Description 有一个长度为n(n<=100)的数列,该数列定义为从2开始的 ...

  4. HDOJ 1056 HangOver(水题)

    Problem Description How far can you make a stack of cards overhang a table? If you have one card, yo ...

  5. HDOJ(HDU) 1718 Rank(水题、、、)

    Problem Description Jackson wants to know his rank in the class. The professor has posted a list of ...

  6. hdoj 5198 Strange Class 水题

    Strange Class Time Limit: 1 Sec  Memory Limit: 256 MB 题目连接 http://acm.hdu.edu.cn/showproblem.php?pid ...

  7. hdoj 4450 Draw Something 水题

    Draw Something Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) Tota ...

  8. zzulioj--1827--石锅全拌(区间求和水题)

    1827: 石锅全拌 Time Limit: 1 Sec  Memory Limit: 128 MB Submit: 6  Solved: 3 SubmitStatusWeb Board Descri ...

  9. Hdu2015 偶数求和

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=2015 偶数求和 Time Limit: 2000/1000 MS (Java/Others)    M ...

随机推荐

  1. 前端Canvas思维导图笔记

    看不清的朋友右键保存或者新窗口打开哦!喜欢我可以关注我,还有更多前端思维导图笔记

  2. Android java.lang.UnsatisfiedLinkError: dalvik.system.PathClassLoader......couldn't find "libweibosdkcore.so

    java.lang.UnsatisfiedLinkError: dalvik.system.PathClassLoader[DexPathList[[zip file "/data/app/ ...

  3. javascript中计算点击多少次

    点击事件:onclick <!DOCTYPE html> <html lang="en"> <head> <meta charset=&q ...

  4. C#设置开机启动项、取消开机启动项

    如果想你写的程序随系统开机一起启动的话,那么你可以照下面这个方法来做. RunWhenStart(false, Application.ProductName, Application.Startup ...

  5. 两款工作流JBPM和CCBPM的对比

    以国外流行的工作流jbpm4的模式与当今中国开源的ccbpm(ccflow和jflow的总称)流程引擎对照.以便让各位能够了解到中国国情的工作流引擎与国际流行的设计规则的差别.不同.与优缺点. 国外工 ...

  6. 【MySQL】ERROR 1005: Can't create table (errno: 150)的错误解决办法

    在mysql 中建立引用约束的时候会出现MySQL ERROR 1005: Can't create table (errno: 150)的错误信息结果是不能建立 引用约束. 出现问题的大致情况 1. ...

  7. PAT_A1021#Deepest Root

    Source: PAT A1021 Deepest Root (25 分) Description: A graph which is connected and acyclic can be con ...

  8. softmax回归---sigmoid(1)

    介绍softmax之前先讲讲sigmoid: 逻辑回归模型常用的函数:sigmoid函数(用来做二分类) 表达式:f(x)=L/(1+exp-k(x-x0)) 其图像: 本质:将一个真值映射到(0,1 ...

  9. 在oracle中将某个字段的数据作为列名的查询

    原表结构 查询语句: select sno,sname,sum(语文) 语文,sum(数学) 数学,sum(英语) 英语 from (select sno,sname,decode(subjiect, ...

  10. constraint、index、view(day04)

    回顾: 1.sql99中的表连接 select 字段列表 from 左表 {[inner]|{left|right|full} [outer]} join 右表 on 关联条件; 集合操作 union ...