Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- #include <string.h>
- int main(void)
- {
- int n;
- char c;
- char s[1000000];
- scanf("%d\n",&n);
- c=getchar();
- int k=0;
- while(c!='EOF'){
- s[k]=c;
- c=getchar();
- k++;
- }
- int len=strlen(s);
- int N=0;
- for(int i=0;i<len;i++){
- if (s[i]==' ') N++;
- }
- int lish=n-len;
- int u;
- if(lish%N!=0) u=lish/N+1;
- else u=lish/N;
- for(int i=0;i<len;i++){
- if (s[i] != ' ')
- printf("%c",s[i]);
- else {
- for(int j=0;j<u;j++){
- putchar(' ');
- }
- if(N!=1){
- lish-=u;
- N--;
- if (N==0) {printf("NO"); return 0;}
- if (lish%N!=0)
- u=lish/N+1;
- else
- u=lish/N;
- }}
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement