当前位置:   article > 正文

time limit per test/memory limit per test_e. negatives and positives time limit per test2 se

e. negatives and positives time limit per test2 seconds memory limit per tes

time limit per test
2 seconds
memory limit per test
256 megabytes
input
standard input
output
standard output
Petya loves lucky numbers. We all know that lucky numbers are the positive integers whose decimal representations contain only the lucky digits 4 and 7. For example, numbers 47, 744, 4 are lucky and 5, 17, 467 are not.

Petya recently learned to determine whether a string of lowercase Latin letters is lucky. For each individual letter all its positions in the string are written out in the increasing order. This results in 26 lists of numbers; some of them can be empty. A string is considered lucky if and only if in each list the absolute difference of any two adjacent numbers is a lucky number.

For example, let’s consider string “zbcdzefdzc”. The lists of positions of equal letters are:

b: 2
c: 3,10
d: 4,8
e: 6
f: 7
z: 1,5,9
Lists of positions of letters a, g, h, …, y are empty.
This string is lucky as all differences are lucky numbers. For letters z: 5-1=4, 9-5=4, for letters c: 10-3=7, for letters d: 8-4=4.

Note that if some letter occurs only once in a string, it doesn’t influence the string’s luckiness after building the lists of positions of equal letters. The string where all the letters are distinct is considered lucky.

Find the lexicographically minimal lucky string whose length equals n.

Input
The single line contains a positive integer n (1≤n≤105) − the length of the sought string.

Output
Print on the single line the lexicographically minimal lucky string whose length equals n.

Examples
Input
5
Output
abcda
Input
3
Output
abc
Note
The lexical comparison of strings is performed by the < operator in modern programming languages. String a is lexicographically less than string b if exists such i (1≤i≤n), that ai<bi, and for any j (1≤j<i) aj=bj.

#include<stdio.h>
#include<stdlib.h>
int main(){
	int n;
	int i,j;
	int m=98;
	char N[110];
//	printf("Input\n");
	scanf("%d",&n);
	if(n>4){
		for(i=0;i<n;i++){
			if(m==101)
					m=98;
			if(i%4==0){
				N[i]=(char)(97);
			}
			else{
				N[i]=(char)m;
				m++;		
			}	
		}
	}
	else
		for(i=0;i<n;i++){
			N[i]=(char)m;
			m++; 
		}
//	printf("Output\n");	 
	for(i=0;i<n;i++)
		printf("%c",N[i]);
	
}
  • 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
声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/weixin_40725706/article/detail/71594
推荐阅读
相关标签
  

闽ICP备14008679号