Given are three integers N, K, and S.
Find a sequence A1,A2,…,AN of N integers between 1 and 109 (inclusive) that satisfies the condition below. We can prove that, under the conditions in Constraints, such a sequence always exists.
Input is given from Standard Input in the following format:
N K S
Print a sequence satisfying the condition, in the following format:
A1 A2 … AN
4 2 3
1 2 3 4
Two pairs (l,r)=(1,2) and (3,3) satisfy the condition in the statement.
5 3 100
50 50 50 30 70
思路:看似抽象的问题要简单化思考,许多看似要枚举很多情况的题目其实只要抓住最核心的成立条件即可。
ps:今天一天把收藏的洛谷改版之前新手村的题目做了,感觉确实都是很简单水题,想想上学期还觉得把新手村的题刷通都已经很不错了 233
ac代码:
#include<bits/stdc++.h> using namespace std; #define rep(i,a,n) for(int i=a;i<=n;i++) #define per(i,a,n) for(int i=n;i>=a;i--) #define read(x) scanf("%d",&x) #define Read(x,y) scanf("%d%d",&x,&y) #define write(x) printf("%d\n",x) #define INF 0x3f3f3f3f #define MAX_N 6010 typedef long long ll; int main() { ll n,s,k; cin >> n >> k >> s; ll c = s; if(s > 1) { c --; } else c ++; for(int i = 1;i <= k;++i) cout<<s<<‘ ‘; for(int i = 1;i <= n - k; ++i) cout<<c<<‘ ‘; return 0; }
AtCoder 5749 C - Subarray Sum(简单化)
原文:https://www.cnblogs.com/jaszzz/p/12740746.html