1188:0 starting point algorithm 95--Domino shop time limit:1 Sec Memory limit:32 MB 64bit IO Format:%lld
submitted:1003 accepted:409
[Submit] [Status] [Web Board] Description
In a rectangular square of 2xn, fill the squares with a 1x2 domino, enter N, and output the total number of paving schemes.
For example, when n=3, for 2x3 squares, the Domino placement scheme has three kinds, such as:
Input
The input data consists of multiple lines, each containing an integer n, indicating that the size of the rectangular square of the test instance is 2xn (0<n<=50).
Output
For each test instance, output the total number of placement scenarios, one row for each instance output.
Sample Input
132
Sample Output
132
Source
0 Starting point Learning algorithm
The code is as follows:
#include <stdio.h>int main () { int n, i; Long Long T, a1, A2; while (scanf ("%d", &n)! = EOF) { a1 = 1; A2 = 2; if (n <= 2) { printf ("%d\n", n); Continue; } for (i = 3; I <= n; i++) { t = A2; a2 = A1 + A2; a1 = t; } printf ("%lld\n", A2); } return 0;}
Wust Online Judge-1188:0 starting point algorithm 95--dominoes shop Squares