D. Game With Array

链接:https://codeforces.com/contest/1355/problem/D

Petya and Vasya are competing with each other in a new interesting game as they always do.

At the beginning of the game Petya has to come up with an array of NN positive integers. Sum of all elements in his array should be equal to SS. Then Petya has to select an integer KK such that 0≤K≤S0≤K≤S.

In order to win, Vasya has to find a non-empty subarray in Petya's array such that the sum of all selected elements equals to either KK&nbs***bsp;S−KS−K. Otherwise Vasya loses.

You are given integers NN and SS. You should determine if Petya can win, considering Vasya plays optimally. If Petya can win, help him to do that.

Input

The first line contains two integers NN and SS (1≤N≤S≤1061≤N≤S≤106) — the required length of the array and the required sum of its elements.

Output

If Petya can win, print "YES" (without quotes) in the first line. Then print Petya's array in the second line. The array should contain NN positive integers with sum equal to SS. In the third line print KK. If there are many correct answers, you can print any of them.

If Petya can't win, print "NO" (without quotes).

You can print each letter in any register (lowercase or uppercase).

Examples

input

Copy

1 4

output

Copy

YES
4
2

input

Copy

3 4

output

Copy

NO

input

Copy

3 8

output

Copy

YES
2 1 5
4

代码:

#include <algorithm>
#include <bitset>
#include <cctype>
#include <cerrno>
#include <clocale>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <limits>
#include <list>
#include <map>
#include <iomanip>
#include <ios>
#include<iosfwd>
#include <iostream>
#include <istream>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <utility>
#include <vector>
#include <cwchar>
#include <cwctype>
#define ll long long
#define rep(i,a,n) for(int i=a;i<=n;i++)
using namespace std;
ll n,m,t,k,s,ans;
ll a[200001];
int main()
{
	cin>>n>>s;
	k=floor(s*1.0/n);
	if(k!=1)
	{
		cout<<"YES"<<endl;
		t=s%n;
		for(int i=1;i<=t;i++)
		{
			cout<<k+1<<' ';
		}
		for(int i=t+1;i<=n;i++)
		{
			cout<<k<<" ";
		}
		cout<<endl;
		cout<<1<<endl;
	}
	else
	{
		cout<<"NO"<<endl;
	}
}
 

 

全部评论

相关推荐

06-26 22:20
门头沟学院 Java
码农索隆:让你把简历发给她,她说一些套话,然后让你加一个人,说这个人给你改简历,然后开始卖课
我的求职精神状态
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务