题目link
思路
思维题
发现 m 与 0 交错出现值最大
signed main()
{
int n,m;cin>>n>>m;
cout << n*(n-1)/2*m << endl;
int f = 0;
forr(i,1,n){
if(!f) cout << m << " ",f = 1;
else cout << 0 << " ",f = 0;
}
return 0;
}
微信扫一扫
题目link
思维题
发现 m 与 0 交错出现值最大
signed main()
{
int n,m;cin>>n>>m;
cout << n*(n-1)/2*m << endl;
int f = 0;
forr(i,1,n){
if(!f) cout << m << " ",f = 1;
else cout << 0 << " ",f = 0;
}
return 0;
}
相关推荐