Avin meets a rich customer today. He will earn 1 million dollars if he can solve a hard problem. There are n warehouses and m workers. Any worker in the i-th warehouse can handle ai orders per day. The customer wonders whether there exists one worker assignment method satisfying that every warehouse handles the same number of orders every day. Note that each worker should be assigned to exactly one warehouse and no worker is lazy when working.

Input

The first line contains two integers n (1 ≤ n ≤ 1, 000), m (1 ≤ m ≤ 1018). The second line contains n integers. The i-th integer ai (1 ≤ ai ≤ 10) represents one worker in the i-th warehouse can handle ai orders per day.

Output

If there is a feasible assignment method, print "Yes" in the first line. Then, in the second line, print n integers with the i-th integer representing the number of workers assigned to the i-th warehouse.
Otherwise, print "No" in one line. If there are multiple solutions, any solution is accepted.

Sample Input

2 6
1 2
2 5
1 2
Sample Output
Yes
4 2
No 题意:n个仓库,m个工人,每个仓库有一个派单速度,问:能否合理的分配每个工人,使得每个仓库一天的派单量相同。若能,输出分配方法 题解:求出n个派单速度的最小公倍数p,如果m%n==0,则合理分配
#include<iostream>
#include<algorithm>
#include<string.h>
#include<string>
#define ll long long
using namespace std;
ll n, m;
ll p[];
ll gcd(ll a, ll b)//最大公约数
{
return b == ? a : gcd(b, a % b);
} ll lcm(ll a, ll b)//最小公倍数
{
return a / gcd(a, b) * b;
}
int main()
{
while (cin >> n >> m)
{
for (ll i = ; i <= n; i++)
cin >> p[i];
ll temp = p[];
for (ll i = ; i <= n; i++)
{
temp = lcm(temp, p[i]);
} ll cnt = , flag = , d;
for (ll i = ; i <= n; i++)
cnt = cnt + temp / p[i];
if (m%cnt != )
flag = ;
else
d = m / cnt;
if (flag == )
{
cout << "Yes" << endl;
for (ll i = ; i <= n; i++)
{
if (i != n)
cout << temp / p[i] * d << ' ';
else
cout << temp / p[i] * d << endl;
}
}
else
cout << "No" << endl;
}
return ;
}

J - Worker的更多相关文章

  1. MySQL: Tree-Hierarchical query

             http://dba.stackexchange.com/questions/30021/mysql-tree-hierarchical-query     No problem. ...

  2. poj1821 Fence【队列优化线性DP】

    Fence Time Limit: 1000MS   Memory Limit: 30000K Total Submissions: 6122   Accepted: 1972 Description ...

  3. 826. Most Profit Assigning Work

    https://leetcode.com/problems/most-profit-assigning-work/description/ class Solution { public: int m ...

  4. 使用OpenMP加快OpenCV图像处理性能 | speed up opencv image processing with openmp

    本文首发于个人博客https://kezunlin.me/post/7a6ba82e/,欢迎阅读! speed up opencv image processing with openmp Serie ...

  5. 2019CCPC-江西省赛

    目录 Contest Info Solutions A. Cotree C.Trap D.Wave F.String G. Traffic H.Rng I. Budget J. Worker K. C ...

  6. JXCPC 试题册

    JXCPC 试题册 Input file: standard input Output file: standard output Time limit: 1s Memory limit: 256 m ...

  7. HDU重现赛之2019CCPC-江西省赛

    本人蒟蒻,5个小时过了5道,看到好几个大佬AK,%%%%%%% http://acm.hdu.edu.cn/contests/contest_show.php?cid=868 先放大佬的题解(不是我写 ...

  8. C++职工管理系统

    目录 职工管理系统 一. 需求 二. 创建管理类 1.创建文件 2. 头文件实现 3. 源文件实现 三. 菜单功能 1. 添加成员函数 2. 功能实现 3. 测试菜单功能 四. 退出功能 1. 提供功 ...

  9. Web Worker javascript多线程编程(一)

    什么是Web Worker? web worker 是运行在后台的 JavaScript,不占用浏览器自身线程,独立于其他脚本,可以提高应用的总体性能,并且提升用户体验. 一般来说Javascript ...

随机推荐

  1. 【剑指Offer面试编程题】题目1360:乐透之猜数游戏--九度OJ

    题目描述: 六一儿童节到了,YZ买了很多丰厚的礼品,准备奖励给JOBDU里辛劳的员工.为了增添一点趣味性,他还准备了一些不同类型的骰子,打算以掷骰子猜数字的方式发放奖品.例如,有的骰子有6个点数(点数 ...

  2. UCOS-III API函数

    附录:UCOS-III API函数 任务管理 就绪列表 挂起队列 时间管理 信号量 消息队列 内存管理

  3. 「luogu2617」Dynamic Rankings

    「luogu2617」Dynamic Rankings 传送门 树套树直接上树状数组套主席树,常数很大就是了. 树套树参考代码: /*-------------------------------- ...

  4. Python语法速查: 20. 线程与并发

    返回目录 本篇索引 (1)线程基本概念 (2)threading模块 (3)线程间同步原语资源 (4)queue (1)线程基本概念 当应用程序需要并发执行多个任务时,可以使用线程.多个线程(thre ...

  5. node指针

  6. 2020.2.19 restful的学习

    restful Api 设计要素 3-8 如何设计Restful Api 资源路径(url),HTTP动词,过滤信息(做分页),状态码,错误处理,返回结果    3-9    初始化运行参数 3-10 ...

  7. 带你了解后渗透工具Koadic

    前言: 在朋友的博客上看到推荐的一款工具Koadic,我接触了以后发现很不错这款工具的强大之处我觉得就是拿到shell后的各种模块功能,我就自己写出来发给大家看看吧. 首先把项目克隆到本地: 项目地址 ...

  8. 等级保护2.0-mysql

    控制点 安全要求 要求解读 测评方法 预期结果或主要证据 身份鉴别 a)应对登录的用户进行身份标识和鉴别,身份标识具有唯一性,身份鉴别信息具有复杂度要求并定期更换 应检查MySQL数据库的口令策略配置 ...

  9. 与(&)、非(~)、或(|)、异或(^)

    位运算符主要针对二进制,它包括了:“与”.“非”.“或”.“异或”.从表面上看似乎有点像逻辑运算符,但逻辑运算符是针对两个关系运算符来进行逻辑运算,而位运算符主要针对两个二进制数的位进行逻辑运算.下面 ...

  10. 使用Spring Cloud Gateway保护反应式微服务(二)

    抽丝剥茧,细说架构那些事——[优锐课] 接着上篇文章:使用Spring Cloud Gateway保护反应式微服务(一) 我们继续~ 将Spring Cloud Gateway与反应式微服务一起使用 ...