HDU
来源:互联网 发布:mac anaconda使用教程 编辑:程序博客网 时间:2024/05/01 02:31
思路:0表示A,1表示B,2表示C,d(i, j)表示在第j次时正好到达i。
AC代码
#include <cstdio>#include <cmath>#include <algorithm>#include <cstring>#include <utility>#include <string>#include <iostream>#include <map>#include <set>#include <vector>#include <queue>#include <stack>using namespace std;#pragma comment(linker, "/STACK:1024000000,1024000000") #define eps 1e-10#define inf 0x3f3f3f3f#define PI pair<int, int> typedef long long LL;const int maxn = 1000 + 5, mod = 10000;int dp[3][maxn]; //A-0 B-1 C-2void init() {memset(dp, 0, sizeof(dp));dp[0][0] = 1;for(int i = 1; i <= 1000; ++i) {for(int j = 0; j < 3; ++j) {for(int k = 0; k < 3; ++k) {if(j != k) dp[j][i] += dp[k][i-1];dp[j][i] %= mod;}}} }int main() {init();int n;while(scanf("%d", &n) == 1 && n) {printf("%d\n", dp[0][n]);}return 0;}
如有不当之处欢迎指出!
0 0
- hdu
- hdu
- HDU
- hdu ()
- hdu
- hdu
- HDU
- HDU
- hdu
- hdu
- HDU
- Hdu
- hdu
- hdu-
- hdu
- hdu
- hdu
- HDU
- hdu 4283 You Are the One
- 18Lab03 android UI(2)
- 四道编程题
- 基于Web的学校教室租赁系统
- sql语句执行顺序
- HDU
- 欢迎使用CSDN-markdown编辑器
- 我的软件工程课目标【作业】
- ArrayList自动扩容解析
- 26种设计模式之Singleton(单例模式)
- 网易笔试题,推箱子详解
- WordPress 下载量最高的十个插件
- 最长公共子序列(动态规划求法)
- AndroidStudio2.3升级的后遗症解决