문제해결(PS)/ROSALIND

Inferring mRNA from Protein(단백질로 mRNA 추론)

곰탱이장 2024. 8. 11. 17:00

https://rosalind.info/problems/mrna/

 

ROSALIND | Inferring mRNA from Protein

It appears that your browser has JavaScript disabled. Rosalind requires your browser to be JavaScript enabled. Inferring mRNA from Protein solved by 10037 2012년 7월 2일 12:00:00 오전 by Rosalind Team Topics: Combinatorics Pitfalls of Reversing Transl

rosalind.info

Problem

For positive integers aa and nn, aa modulo nn (written amodnamodn in shorthand) is the remainder when aa is divided by nn. For example, 29mod11=729mod11=7 because 29=11×2+729=11×2+7.

Modular arithmetic is the study of addition, subtraction, multiplication, and division with respect to the modulo operation. We say that aa and bb are congruent modulo nn if amodn=bmodnamodn=bmodn; in this case, we use the notation abmodna≡bmodn.

Two useful facts in modular arithmetic are that if abmodna≡bmodn and cdmodnc≡dmodn, then a+cb+dmodna+c≡b+dmodn and a×cb×dmodna×c≡b×dmodn. To check your understanding of these rules, you may wish to verify these relationships for a=29a=29, b=73b=73, c=10c=10, d=32d=32, and n=11n=11.

As you will see in this exercise, some Rosalind problems will ask for a (very large) integer solution modulo a smaller number to avoid the computational pitfalls that arise with storing such large numbers.

Given: A protein string of length at most 1000 aa.

Return: The total number of different RNA strings from which the protein could have been translated, modulo 1,000,000. (Don't neglect the importance of the stop codon in protein translation.)

Sample Dataset

MA

Sample Output

12

 이 문제는 아미노산 서열이 주어지고 그 아미노산 서열을 만들 수 있는 mRNA 서열의 가짓수를 역으로 추론하는 문제이다. 예를 들어 M인 메싸이오닌은 1개로만 만들어지고 종결코돈은 3개인 것처럼 그렇게 다 곱하면 된다. 

 그리고 이 문제의 답은 너무나 크기 때문에 모듈러 백만의 값을 내야한다.(백만으로 나눈 나머지)

AA_to_RNA={
    'A':4,
    'R':6,
    'N':2,
    'D':2,
    'C':2,
    'Q':2,
    'E':2,
    'G':4,
    'H':2,
    'I':3,
    'L':6,
    'K':2,
    'M':1,
    'F':2,
    'P':4,
    'S':6,
    'T':4,
    'W':1,
    'Y':2,
    'V':4
}

a=input()
start=1
for aa in a:
    start = start*AA_to_RNA[aa]
print((start*3)%1000000)