Logo
(追記) (追記ここまで)

32323번 - Password Protection 다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
8 초 (추가 시간 없음) 1024 MB164425.000%

문제

You have recently made an account on a website. You used a password manager to produce a random password. One of the constraints was that your password does not contain your first or last name. You assumed that containment here referred to having a substring (contiguous sequence of characters) that were identical to the sequence of characters that comprised either your first or last name.

You were unlucky enough that your first password did not satisfy this criterion. You want to know how often such an unfortunate turn of events could happen. Write a program to help in this endeavor by simply counting the number of passwords that contain either a given first name or last name as a substring. For example, if your first name was “ali” (quotes for clarity), then the password “california” contains your first name as a substring but the password “applied” does not contain your first name as a substring, even though “ali” is a subsequence of this password.

Note that this is an “inclusive or” which means either or both, i.e., a password is not valid if it contains the first name or the last name or both.

Given a first name, last name, and password length, determine the number of randomly generated passwords that will contain your first or last name as a substring (contiguous subsequence of characters). You can assume that passwords generated will contain only lowercase letters.

입력

The first input line contains an integer, n (1 ≤ n ≤ 107), representing the length of the password that is randomly generated. The second input line contains a string of x lowercase letters (1 ≤ x ≤ 128), representing the first name to check. The third input line contains a string of y lowercase letters (1 ≤ y ≤ 128), representing the last name to check.

출력

Print an integer representing the number of invalid passwords, i.e., they contain the first or last name. Since the answer can be quite large, your program should report the number as the smallest non-negative remainder when divided by 1,000,000,007.

제한

예제 입력 1

6
ali
orooji

예제 출력 1

70304

예제 입력 2

5
arup
guha

예제 출력 2

104

힌트

출처

University > University of Central Florida > 2024 Local Programming Contest (Final Round) 10번

(追記) (追記ここまで)

출처

대학교 대회

  • 사업자 등록 번호: 541-88-00682
  • 대표자명: 최백준
  • 주소: 서울시 서초구 서초대로74길 29 서초파라곤 412호
  • 전화번호: 02-521-0487 (이메일로 연락 주세요)
  • 이메일: contacts@startlink.io
  • 통신판매신고번호: 제 2017-서울서초-2193 호

AltStyle によって変換されたページ (->オリジナル) /