题解 | #LCS#
LCS
https://ac.nowcoder.com/acm/contest/11255/C
C 题题解
思路:构造
参考:https://blog.nowcoder.net/n/9efb42ac11a64a5ebcf0d604115df70d
Code
#include <bits/stdc++.h> using namespace std; string s1,s2,s3; int a,b,c,n; int main(){ cin>>a>>b>>c>>n; int minm=min(min(a,b),c); for(int i=1;i<=minm;i++) s1+='a'; s3=s2=s1; for(int i=1;i<=a-minm;i++) s1+='b',s2+='b'; for(int i=1;i<=b-minm;i++) s2+='c',s3+='c'; for(int i=1;i<=c-minm;i++) s3+='d',s1+='d'; if(s1.size()>n||s2.size()>n||s3.size()>n) puts("NO"); else { while(s1.size()<n) s1+='x'; while(s2.size()<n) s2+='y'; while(s3.size()<n) s3+='z'; cout<<s1<<endl<<s2<<endl<<s3<<endl; } return 0; }