ZYB's Biology解题报告

<div class="problem-title">问题描述</div><pre class="problem-content"><span><span class="katex"><span class="katex-mathml"><math><semantics><mrow><mi>Z</mi><mi>Y</mi><mi>B</mi><mo>(</mo><mi>Z</mi><mi>J</mi><mo>−</mo><mn>2</mn><mn>6</mn><mn>7</mn><mo>)</mo></mrow><annotation encoding="application/x-tex">ZYB(ZJ-267)</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="strut" style="height: 0.75em;"></span><span class="strut bottom" style="height: 1em; vertical-align: -0.25em;"></span><span class="base textstyle uncramped"><span class="mord mathit" style="margin-right: 0.07em;">Z</span><span class="mord mathit" style="margin-right: 0.22em;">Y</span><span class="mord mathit" style="margin-right: 0.05em;">B</span><span class="mopen">(</span><span class="mord mathit" style="margin-right: 0.07em;">Z</span><span class="mord mathit" style="margin-right: 0.09em;">J</span><span class="mbin">−</span><span class="mord">2</span><span class="mord">6</span><span class="mord">7</span><span class="mclose">)</span></span></span></span></span>在<span><span class="katex"><span class="katex-mathml"><math><semantics><mrow><mi>N</mi><mi>O</mi><mi>I</mi><mi>P</mi></mrow><annotation encoding="application/x-tex">NOIP</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="strut" style="height: 0.68em;"></span><span class="strut bottom" style="height: 0.68em; vertical-align: 0em;"></span><span class="base textstyle uncramped"><span class="mord mathit" style="margin-right: 0.1em;">N</span><span class="mord mathit" style="margin-right: 0.02em;">O</span><span class="mord mathit" style="margin-right: 0.07em;">I</span><span class="mord mathit" style="margin-right: 0.13em;">P</span></span></span></span></span>拿到<span><span class="katex"><span class="katex-mathml"><math><semantics><mrow><mn>6</mn><mn>0</mn><mn>0</mn></mrow><annotation encoding="application/x-tex">600</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="strut" style="height: 0.64em;"></span><span class="strut bottom" style="height: 0.64em; vertical-align: 0em;"></span><span class="base textstyle uncramped"><span class="mord">6</span><span class="mord">0</span><span class="mord">0</span></span></span></span></span>分之后开始虐生物题,他现在扔给你一道简单的生物题:给出一个<span><span class="katex"><span class="katex-mathml"><math><semantics><mrow><mi>D</mi><mi>N</mi><mi>A</mi></mrow><annotation encoding="application/x-tex">DNA</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="strut" style="height: 0.68em;"></span><span class="strut bottom" style="height: 0.68em; vertical-align: 0em;"></span><span class="base textstyle uncramped"><span class="mord mathit" style="margin-right: 0.02em;">D</span><span class="mord mathit" style="margin-right: 0.1em;">N</span><span class="mord mathit">A</span></span></span></span></span>序列和一个<span><span class="katex"><span class="katex-mathml"><math><semantics><mrow><mi>R</mi><mi>N</mi><mi>A</mi></mrow><annotation encoding="application/x-tex">RNA</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="strut" style="height: 0.68em;"></span><span class="strut bottom" style="height: 0.68em; vertical-align: 0em;"></span><span class="base textstyle uncramped"><span class="mord mathit" style="margin-right: 0em;">R</span><span class="mord mathit" style="margin-right: 0.1em;">N</span><span class="mord mathit">A</span></span></span></span></span>序列,
问它们是否配对。

<span><span class="katex"><span class="katex-mathml"><math><semantics><mrow><mi>D</mi><mi>N</mi><mi>A</mi></mrow><annotation encoding="application/x-tex">DNA</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="strut" style="height: 0.68em;"></span><span class="strut bottom" style="height: 0.68em; vertical-align: 0em;"></span><span class="base textstyle uncramped"><span class="mord mathit" style="margin-right: 0.02em;">D</span><span class="mord mathit" style="margin-right: 0.1em;">N</span><span class="mord mathit">A</span></span></span></span></span>序列是仅由<span><span class="katex"><span class="katex-mathml"><math><semantics><mrow><mi>A</mi><mo separator="true">,</mo><mi>C</mi><mo separator="true">,</mo><mi>G</mi><mo separator="true">,</mo><mi>T</mi></mrow><annotation encoding="application/x-tex">A,C,G,T</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="strut" style="height: 0.68em;"></span><span class="strut bottom" style="height: 0.87em; vertical-align: -0.19em;"></span><span class="base textstyle uncramped"><span class="mord mathit">A</span><span class="mpunct">,</span><span class="mord mathit" style="margin-right: 0.07em;">C</span><span class="mpunct">,</span><span class="mord mathit">G</span><span class="mpunct">,</span><span class="mord mathit" style="margin-right: 0.13em;">T</span></span></span></span></span>组成的字符串,<span><span class="katex"><span class="katex-mathml"><math><semantics><mrow><mi>R</mi><mi>N</mi><mi>A</mi></mrow><annotation encoding="application/x-tex">RNA</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="strut" style="height: 0.68em;"></span><span class="strut bottom" style="height: 0.68em; vertical-align: 0em;"></span><span class="base textstyle uncramped"><span class="mord mathit" style="margin-right: 0em;">R</span><span class="mord mathit" style="margin-right: 0.1em;">N</span><span class="mord mathit">A</span></span></span></span></span>序列是仅由<span><span class="katex"><span class="katex-mathml"><math><semantics><mrow><mi>A</mi><mo separator="true">,</mo><mi>C</mi><mo separator="true">,</mo><mi>G</mi><mo separator="true">,</mo><mi>U</mi></mrow><annotation encoding="application/x-tex">A,C,G,U</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="strut" style="height: 0.68em;"></span><span class="strut bottom" style="height: 0.87em; vertical-align: -0.19em;"></span><span class="base textstyle uncramped"><span class="mord mathit">A</span><span class="mpunct">,</span><span class="mord mathit" style="margin-right: 0.07em;">C</span><span class="mpunct">,</span><span class="mord mathit">G</span><span class="mpunct">,</span><span class="mord mathit" style="margin-right: 0.1em;">U</span></span></span></span></span>组成的字符串。

<span><span class="katex"><span class="katex-mathml"><math><semantics><mrow><mi>D</mi><mi>N</mi><mi>A</mi></mrow><annotation encoding="application/x-tex">DNA</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="strut" style="height: 0.68em;"></span><span class="strut bottom" style="height: 0.68em; vertical-align: 0em;"></span><span class="base textstyle uncramped"><span class="mord mathit" style="margin-right: 0.02em;">D</span><span class="mord mathit" style="margin-right: 0.1em;">N</span><span class="mord mathit">A</span></span></span></span></span>和<span><span class="katex"><span class="katex-mathml"><math><semantics><mrow><mi>R</mi><mi>N</mi><mi>A</mi></mrow><annotation encoding="application/x-tex">RNA</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="strut" style="height: 0.68em;"></span><span class="strut bottom" style="height: 0.68em; vertical-align: 0em;"></span><span class="base textstyle uncramped"><span class="mord mathit" style="margin-right: 0em;">R</span><span class="mord mathit" style="margin-right: 0.1em;">N</span><span class="mord mathit">A</span></span></span></span></span>匹配当且仅当每个位置上<span><span class="katex"><span class="katex-mathml"><math><semantics><mrow><mi>A</mi></mrow><annotation encoding="application/x-tex">A</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="strut" style="height: 0.68em;"></span><span class="strut bottom" style="height: 0.68em; vertical-align: 0em;"></span><span class="base textstyle uncramped"><span class="mord mathit">A</span></span></span></span></span>与<span><span class="katex"><span class="katex-mathml"><math><semantics><mrow><mi>U</mi></mrow><annotation encoding="application/x-tex">U</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="strut" style="height: 0.68em;"></span><span class="strut bottom" style="height: 0.68em; vertical-align: 0em;"></span><span class="base textstyle uncramped"><span class="mord mathit" style="margin-right: 0.1em;">U</span></span></span></span></span>,<span><span class="katex"><span class="katex-mathml"><math><semantics><mrow><mi>T</mi></mrow><annotation encoding="application/x-tex">T</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="strut" style="height: 0.68em;"></span><span class="strut bottom" style="height: 0.68em; vertical-align: 0em;"></span><span class="base textstyle uncramped"><span class="mord mathit" style="margin-right: 0.13em;">T</span></span></span></span></span>与<span><span class="katex"><span class="katex-mathml"><math><semantics><mrow><mi>A</mi></mrow><annotation encoding="application/x-tex">A</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="strut" style="height: 0.68em;"></span><span class="strut bottom" style="height: 0.68em; vertical-align: 0em;"></span><span class="base textstyle uncramped"><span class="mord mathit">A</span></span></span></span></span>,<span><span class="katex"><span class="katex-mathml"><math><semantics><mrow><mi>C</mi></mrow><annotation encoding="application/x-tex">C</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="strut" style="height: 0.68em;"></span><span class="strut bottom" style="height: 0.68em; vertical-align: 0em;"></span><span class="base textstyle uncramped"><span class="mord mathit" style="margin-right: 0.07em;">C</span></span></span></span></span>与<span><span class="katex"><span class="katex-mathml"><math><semantics><mrow><mi>G</mi></mrow><annotation encoding="application/x-tex">G</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="strut" style="height: 0.68em;"></span><span class="strut bottom" style="height: 0.68em; vertical-align: 0em;"></span><span class="base textstyle uncramped"><span class="mord mathit">G</span></span></span></span></span>,<span><span class="katex"><span class="katex-mathml"><math><semantics><mrow><mi>G</mi></mrow><annotation encoding="application/x-tex">G</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="strut" style="height: 0.68em;"></span><span class="strut bottom" style="height: 0.68em; vertical-align: 0em;"></span><span class="base textstyle uncramped"><span class="mord mathit">G</span></span></span></span></span>与<span><span class="katex"><span class="katex-mathml"><math><semantics><mrow><mi>C</mi></mrow><annotation encoding="application/x-tex">C</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="strut" style="height: 0.68em;"></span><span class="strut bottom" style="height: 0.68em; vertical-align: 0em;"></span><span class="base textstyle uncramped"><span class="mord mathit" style="margin-right: 0.07em;">C</span></span></span></span></span>匹配。
输入描述
第一行一个整数TTT表示数据组数。

对于每组数据:

第一行一个整数NNN表示DNADNADNARNARNARNA序列的长度.

第二行一个长度为NNN的字符串AAA表示DNADNADNA序列.

第三行一个长度为NNN的字符串BBB表示RNARNARNA序列.

1≤T≤101 \leq T \leq 101T10,1≤N≤1001 \leq N \leq 1001N100
输出描述
对于每组数据,输出一行YESYESYESNONONO,表示是否匹配.
输入样例
2
4
ACGT
UGCA
4
ACGT
ACGU
输出样例
YES
NO
 
 
 
 
 
 
 
 
 
 
 
 
 
 
#include <cstdio>

using namespace std;

int main()
{
    int n, i, m;
    char str[2][105];

    scanf("%d", &n);

    while (n--)
    {
        int flag = 1;
        scanf("%d", &m);
        scanf("%s %s", str[0], str[1]);		//两个字符串,比较起来方便

        for (i=0; i<m; ++i)
        {
            if (str[0][i]=='A'){
                if (str[1][i]!='U' && str[1][i]!='T')
                    flag = 0;
            }
            if (str[0][i]=='U'){
                if (str[1][i]!='A')
                    flag = 0;
            }
            if (str[0][i]=='T'){
                if (str[1][i]!='A')
                    flag = 0;
            }
            if (str[0][i]=='C'){
                if (str[1][i]!='G')
                    flag = 0;
            }
            if (str[0][i]=='G'){
                if (str[1][i]!='C')
                    flag = 0;
            }
        }
        if (flag == 1)
            printf("YES\n");
        else
            printf("NO\n");
    }
    return 0;
}



你可能感兴趣的:(BestCoder)