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)