HDU2015 偶数求和
来源:互联网 发布:网络入侵 编辑:程序博客网 时间:2024/04/30 13:42
#include <stdio.h>#include <string.h>intmain(int argc, char **argv) { int n, m, i; int num[105]; int res[105]; int sum, cnt; for (i = 1; i < 105; ++ i) { num[i] = i * 2; } while (scanf("%d%d", &n, &m) == 2) { sum = 0; cnt = 0; memset(res, 0, sizeof(res)); for (i = 1; i <= n; ++ i) { sum += num[i]; if (i % m == 0) { res[cnt++] = sum / m; sum = 0; } } if (n > n / m * m) { for (i = 0; i < cnt; ++ i) printf("%d ", res[i]); printf("%d\n", sum / (n - n / m * m)); } else { for (i = 0; i < cnt - 1; ++ i) printf("%d ", res[i]); printf("%d\n", res[cnt - 1]); } } return 0;}
0 0
- hdu2015 偶数求和
- hdu2015偶数求和
- hdu2015偶数求和
- HDU2015 偶数求和
- HDU2015 偶数求和
- hdu2015(偶数求和)
- HDU2015偶数求和
- HDU2015偶数求和
- 偶数求和(HDU2015)
- HDU2015 偶数求和
- HDU2015--偶数求和
- HDU2015 偶数求和
- HDU2015偶数求和
- HDU2015 偶数求和
- hdu2015——偶数求和
- (解题报告)HDU2015---偶数求和
- 偶数求和
- 偶数求和
- HDU2012 素数判定
- HDU2013 蟠桃记
- [转载]iPhone 之内存管理机制
- HDU2014 青年歌手大奖赛_评委会打分
- oc学习小结(字符串的截取)
- HDU2015 偶数求和
- HDU2016 数据的交换输出
- HDU2017 字符串统计
- BZOJ 1143 CTSC2008 祭祀river 二分图最大匹配
- HDU2018 母牛的故事
- oc学习小结(ForEach,copy方法等方法的使用)
- HDU2019 数列有序!
- Leetcode: Populating Next Right Pointers in Each Node II
- 第二章