class Solution { int numTilings(int n) { if (n == 1) { return 1; } List a = List.filled(n, 0); List b = List.filled(n, 0); a[0] = 1; b[0] = 0; a[1] = 2; b[1] = 1; for (int i = 2; i < n; i++) { a[i] = (a[i - 1] + a[i - 2] + 2 * b[i - 1]) % 1000000007; b[i] = (a[i - 2] + b[i - 1]) % 1000000007; } return a[n - 1] % 1000000007; } }

class Solution public int numTilingsint n ifn==1 return 1; long long an; long long bn; a0=1; b0=0; a1=2; b1=1; forint i=2

原文地址: https://www.cveoy.top/t/topic/izpW 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录