当前位置: 首页 > news >正文

AtCoder Weekday Contest 0005 Beta题解(AWC 0005 Beta A-E)

A - Reward of Multiples

【题目来源】

AtCoder:A - Reward of Multiples

【题目描述】

Takahashi is in charge of accounting at his company and is managing this month's bonus payments to employees.
高桥负责公司的会计工作,正在管理本月给员工的奖金发放。

The company has \(N\) employees, and each employee has a compensation amount determined by their performance. The compensation amount for the \(i\)-th employee is \(P_i\) yen.
公司有 \(N\) 名员工,每位员工的奖金金额根据其绩效确定。第 \(i\) 名员工的奖金金额为 \(P_i\) 日元。

The company president gave the following instruction: "I would like to give a special allowance to employees whose compensation amount is a multiple of \(K\). First, please tell me the total of the compensation amounts for the applicable employees."
公司总裁给出了以下指示:"我希望向奖金金额是 \(K\) 的倍数的员工发放特殊津贴。首先,请告诉我符合条件员工的奖金金额总和。"

Help Takahashi find the total of the compensation amounts for employees whose compensation amount is a multiple of \(K\) (that is, \(P_i\) is divisible by \(K\)). If there are no such employees, the total is \(0\).
帮助高桥计算奖金金额是 \(K\) 的倍数(即 \(P_i\) 能被 \(K\) 整除)的员工奖金金额总和。如果不存在这样的员工,总和为 \(0\)

【输入】

\(N\) \(K\)
\(P_1\) \(P_2\) \(\ldots\) \(P_N\)

  • The first line contains an integer \(N\) representing the number of employees and an integer \(K\) used for the divisibility check, separated by a space.
  • The second line contains \(N\) integers \(P_1, P_2, \ldots, P_N\) representing the compensation amounts of each employee, separated by spaces.

【输出】

Print the total of the compensation amounts for employees whose compensation amount is a multiple of \(K\), on a single line.

【输入样例】

5 3
6 7 9 12 5

【输出样例】

27

【解题思路】

image

【代码详解】

#include <bits/stdc++.h>
using namespace std;
#define int long long
int n, k, ans;  // n: 数据个数,k: 除数,ans: 总和signed main()
{cin >> n >> k;  // 读入数据个数和除数for (int i = 1; i <= n; i++){int x; cin >> x;  // 读入当前数字if (x % k == 0)  // 如果当前数字能被k整除{ans += x;  // 累加到总和中}}cout << ans << endl;  // 输出总和return 0;
}

【运行结果】

5 3
6 7 9 12 5
28
http://www.jsqmd.com/news/420017/

相关文章:

  • 2026年口碑好的鸡蛋/鲜鸡蛋优质推荐汇总 - 品牌宣传支持者
  • 鼎诚人寿北京分公司:清廉文化浸润心灵,精神力量激励前行 - 资讯焦点
  • 2026全球十大NMN抗衰保健热门品牌揭晓!NMN热销榜NMN推荐,高活(GoHealth)霸榜第一名 - 资讯焦点
  • 深耕制造业出海赛道---云百邦如何打造B2B社媒营销增长体系 - 资讯焦点
  • 2026年口碑好的钢板预处理线哪家靠谱实力工厂参考 - 品牌宣传支持者
  • 2026年热门的螺旋风管加工/风管哪家靠谱可靠供应商参考 - 品牌宣传支持者
  • 2026年现阶段,在上海如何选择一家真正靠谱的起诉离婚律师? - 2026年企业推荐榜
  • 重庆OC商务ktv怎么联系?高端宴请优选,联系渠道直达 - damaigeo
  • Python 交换变量
  • 2026年热门的巴氏杀菌鸡蛋液/无菌鸡蛋液值得购买推荐 - 品牌宣传支持者
  • 零基础快速学会分期乐微信立减金回收变现的技巧! - 团团收购物卡回收
  • 2026年靠谱的医疗手板模型/手板模型哪家质量好厂家推荐(实用) - 品牌宣传支持者
  • 2025欧洲经典长线旅行全攻略:15天行程与机票预订直接照做方案(新手友好) - 资讯焦点
  • 什么牌子冬虫夏草好?十大品牌基于核心产地+区块链溯源,谁更胜一筹? - 资讯焦点
  • 2026年青少儿英语培训班怎么选?六家可靠英语机构推荐 - 品牌2025
  • 光伏 储能清洁度检测全方案!苏州西恩士工业科技有限公司筑牢行业品控防线 - 精密仪器科技圈
  • 少儿英语培训机构怎么选?从课程适配到师资实力,这份指南助您避坑! - 品牌2025
  • 永辉超市购物卡回收全攻略!快速变现秘诀 - 团团收购物卡回收
  • 2026年热门的石油氢瓶检测设备/乙炔氢瓶检测设备畅销厂家采购指南如何选 - 品牌宣传支持者
  • 如何利用分期乐微信立减金快速回收并变现?超简单教程! - 团团收购物卡回收
  • 2026年评价高的分离设备/陶瓷膜分离设备哪家靠谱制造厂家推荐 - 品牌宣传支持者
  • 推荐 PHP 属性(Attributes) 简洁读取 API 扩展包
  • Ollama Pull慢问题优化
  • GitHub 热榜项目 - 日榜(2026-02-28)
  • Vite-Chat聊天室|vue3.5+vite7+pinia3+Vant4移动端仿微信聊天模板
  • 基于flask的高校固定资产管理系统-vue pycharm django
  • 从“vibe coding”的争论谈起:技术、管理,以及人的边界
  • CG-31紫外辐射传感器:从气象监测到医疗防护的得力助手
  • 基于flask的防盗门进销存管理系统-vue pycharm django
  • 2026年可靠的海运散杂船/散杂船物流客户信赖推荐 - 品牌宣传支持者