/** * 31天的 1, 3, 5, 7, 8, 10 ,12 30天的 4, 6,9,11 28天(平年) 2 29天(闰年) 2 */ class Demo{ public static void main(String[] args){ //年数 int n = 2015; //月数 int y =3; //天数 int t =0; switch(y){ case 1: case 3: case 5: case 7: case 8: case 10: case 12: t = 31; b
题目戳这里 一句话题意 一个大小为8的环,求从1到5正好n步的方案数(途中不能经过5). Solution 巨说这个题目很水 应该是比较容易的DP,直接从把左边和右边的方案数加起来即可,但是有几个需要注意的地方: 1.因为n有1e7所以需要滚动数组. 2.因为不能经过5,所以4只能从3转移,6只能从7转移. 3.记得取模. Coding #include<bits/stdc++.h> using namespace std; int f[2][9]; const int P=1e3; int