Problem Statement
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.
- There are exactly K pairs (l,r) of integers such that 1≤l≤r≤N and Al+Al+1+[cdots]+Ar=S.
Constraints
- 1≤N≤105
- 0≤K≤N
- 1≤S≤109
- All values in input are integers.
Input
Input is given from Standard Input in the following format:
N K S
Output
Print a sequence satisfying the condition, in the following format:
A1 A2 … AN
Sample Input 1
Copy
4 2 3
Sample Output 1
Copy
1 2 3 4
Two pairs (l,r)=(1,2) and (3,3) satisfy the condition in the statement.
Sample Input 2
Copy
5 3 100
Sample Output 2
Copy
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 ",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; }