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. Python之json库

    JSON简介 JSON (JavaScript Object Notation) 是一种用于表示结构化数据的流行数据格式. 常用于服务器和Web应用程序之间传输和接收数据. 在Python中,JSON ...

  2. linux用户权限、系统信息相关命令(待学)

    用户权限相关命令 目标 用户 和 权限 的基本概念 用户管理 终端命令 组管理 终端命令 修改权限 终端命令 01.用户和权限的基本概念 1.1 基本概念 用户 是Linux系统工作中重要的一环, 用 ...

  3. 03.Scala编程实战

    Scala编程实战 1.    课程目标 1.1.  目标:使用Akka实现一个简易版的spark通信框架 2.    项目概述 2.1.   需求 Hivesql----------> sel ...

  4. 1 观察者模式 observer 模拟监听器的实现

    参考(http://blog.csdn.net/allwefantasy/article/details/3062277) 假设我有一台电脑.电脑里面有一个事件,当你按下电源按钮的时候,那么显示器会亮 ...

  5. FLASK - 请求和响应

    请求都封装在request对象里面了 from flask import Flask from flask import request from flask import render_templa ...

  6. java实现邮箱发送邮件

    第一步:封装发件人账号密码 import javax.mail.Authenticator;import javax.mail.PasswordAuthentication; /** * 发件人账号密 ...

  7. 按钮UIButton的使用

    一.使用概要 当添加一个按钮到你的界面,执行以下步骤: 1.在创建时设置按钮的类型. 2.提供一个标题字符串或图像,为您的内容适当调整按钮的大小. 3.连接一个或多个操作按钮的方法. 4.设置自动布局 ...

  8. 记录要做的事情,把sql字符串替换写成工具网页。

    之前使用的是java的本地控制台进行sql占位符的替换. 现在我想换个方式,想到了两种. 第一种是使用java +jsp进行替换,前台输出. 第二种是把java代码改成js代码,反正也不用访问数据库. ...

  9. 解决css中display:inline-block产生的空隙问题

    <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8&quo ...

  10. 修剪草坪 HYSBZ - 2442

    在一年前赢得了小镇的最佳草坪比赛后,FJ变得很懒,再也没有修剪过草坪.现在,新一轮的最佳草坪比赛又开始了,FJ希望能够再次夺冠. 然而,FJ的草坪非常脏乱,因此,FJ只能够让他的奶牛来完成这项工作.F ...