#include<iostream> #define rep(a,b) for(int a=0; a<(b); ++a) #define nl "\n" using namespace std; int n,counter=0; char letters[]={0,0,0,'a','f','k','w'}; int main() { cin>>n; string s; cin>>s; for(auto i:s){ counter+=i-'0'; } int d = counter/n; int r = counter%n; //clog<<d<<" "<<r<<nl; if(counter<n*3||counter>n*6){ cout<<"NIE"<<nl; return 0; } rep(i,n-r){ cout<<letters[d]; } rep(i,r){ cout<<letters[d+1]; } cout<<nl; return 0; }
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 | #include<iostream> #define rep(a,b) for(int a=0; a<(b); ++a) #define nl "\n" using namespace std; int n,counter=0; char letters[]={0,0,0,'a','f','k','w'}; int main() { cin>>n; string s; cin>>s; for(auto i:s){ counter+=i-'0'; } int d = counter/n; int r = counter%n; //clog<<d<<" "<<r<<nl; if(counter<n*3||counter>n*6){ cout<<"NIE"<<nl; return 0; } rep(i,n-r){ cout<<letters[d]; } rep(i,r){ cout<<letters[d+1]; } cout<<nl; return 0; } |