Codeforces Round #643 (Div. 2) D. Game With Array
程序员文章站
2022-06-26 16:14:12
...
D. Game With Array
题目链接-D. Game With Array
题目大意
构造一个长度为的序列,并且个数的和为,问能不能找到一个数,使得数组里找不出一个子序列的和为或者
解题思路
- 取,数组中的前个元素都设为,第个元素为 ,只要第个元素不等于 即可,前提是
n<=s/2
,否则就输出NO
- 具体操作见代码
附上代码
#pragma GCC optimize("-Ofast","-funroll-all-loops")
#include<bits/stdc++.h>
#define int long long
#define lowbit(x) (x &(-x))
#define endl '\n'
using namespace std;
const int INF=0x3f3f3f3f;
const int dir[4][2]={-1,0,1,0,0,-1,0,1};
const double PI=acos(-1.0);
const double e=exp(1.0);
const double eps=1e-10;
const int M=1e9+7;
const int N=2e5+10;
typedef long long ll;
typedef pair<int,int> PII;
typedef unsigned long long ull;
inline void read(int &x){
char t=getchar();
while(!isdigit(t)) t=getchar();
for(x=t^48,t=getchar();isdigit(t);t=getchar()) x=x*10+(t^48);
}
signed main(){
ios::sync_with_stdio(false);
cin.tie(0);cout.tie(0);
int n,s;
cin>>n>>s;
if(n<=s/2){
cout<<"YES"<<endl;
for(int i=0;i<n-1;i++){
cout<<2<<" ";
s-=2;
}
cout<<s<<endl<<1<<endl;
}
else
cout<<"NO"<<endl;
return 0;
}
推荐阅读
-
Educational Codeforces Round 97 (Rated for Div. 2) D. Minimal Height Tree
-
Codeforces Round #665 (Div. 2) D. Maximum Distributed Tree(dfs)
-
Codeforces Round #619 (Div. 2) D. Time to Run
-
Codeforces Round #583 (Div. 1 + Div. 2,) D. Treasure Island(dfs+思维)
-
Codeforces Round #533 (Div. 2) D. Kilani and the Game(bfs+模拟)
-
Codeforces Round #651 (Div. 2) C. Number Game
-
Codeforces Round #643 (Div. 2) D. Game With Array
-
Codeforces Round #459 (Div. 2):D. MADMAX(记忆化搜索+博弈论)
-
Codeforces Round #260 (Div. 2) D. A Lot of Games(树上博弈)
-
Codeforces Round #662 (Div. 2) D. Rarity and New Dress