vijos-p1077 Clone Dragon (Find pattern + exponential parent function + python)

Source: Internet
Author: User

P1077Clone Dragon Accepted Tags: [show tags]<textarea id="code" class="textbox" style=""></textarea>Describe

Now the dragon cloning has become possible, the Dragon gene is composed of ACTG letters, and the Dragon's genes have the following characteristics:
1, a in the gene appears for an even number of times (including 0);
2, the same is true of C;
There are 6 conditions to meet when n=2:
Tt,tg,gt,gg,aa,cc
You just give the last two digits of the number of genes that meet the criteria;

Format input Format

The input file gives a number of n (1<=n<=10^9). End with 0.

Output format

For the input n, the last two digits of the number of strings that satisfy the condition!

Example 1 sample input 1[copy]
1230
Sample output 1[Copy]
2620
Source

Huyichen

Find the pattern, the exponential parent function will be uploaded later

The 0 here should be treated with special treatment, compared to pits

Python is just a recursive type.



#!/usr/bin/env python3#-*-coding:utf-8-*-import mathimport sysfor cin in Sys.stdin:    n = Long (CIN)    if not n:bre AK    N-= 1    a = Math.ceil (POW (2, N, 0) * (POW (2, N, 00) + 1))    a = Long (a)    if a% = =:        print ' '    Else:        print a% 100

C++:

#include <cstdio> #include <cstring> #include <algorithm>using namespace Std;typedef long Long ll;int A [one] = {2,6,20,72,72,56,60,12,92,56};int B[21] = {0,52,12,56,40,92,32,56,80,32,52,56,20,72,72,56,60,12,92,56};int Main () {    int n;    while (~ scanf ("%i64d", &n), n) {        if (n <=) {            n--;            printf ("%d\n", A[n]);        } else {            if (b[(n-11)%] = = 0) printf ("00\n");            else printf ("%d\n", b[(n-11));        }    }    return 0;}


Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.

vijos-p1077 Clone Dragon (Find pattern + exponential parent function + python)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.