[原]hdu2045 不容易系列三——LELE的RPG难题 (递推方程)
原题:http://acm.hdu.edu.cn/showproblem.php?pid=2045
题意:中文不用我说了吧。
这个题目的关键就在于递推方程——以及错误的测试数据
首先这个题目就是简单的置换群着色问题——
去除了反转的问题,难一点的大家可以看P197(离散数学,高等教育出版社)
我在做这个题目的时候首先被f [ 1 ] = 3 困扰了。。拜托,根本不符合题意好吗- =一个格子能说是首尾颜色不同吗?
后来写错了递推方程——f [ n ] = f [ n - 1 ] + 3 * f [ n - 2 ],把 f [ n - 1 ] 的情况多考虑了一遍- = 。
正确的方程应该是 —— f [ n ] = f [ n - 1 ] + 2 * f [ n - 2 ] , n >= 4; (去除了f [ 1 ] = 3 这个坑爹的干扰。)
写成lln是为了防止超范围——写完以后记得DEBUG一下看看有没有超范围——
代码:
#include <iostream>
#include <cstdio>
#include <cstring> using namespace std;
#define lln long long int lln f[51]; void ace()
{
memset(f, 0x3f, sizeof(f));
int i;
f[1] = 3;
f[2] = 6;
f[3] = 6;
for(i = 4; i <= 50; i++)
{
f[i] = f[i - 1] + 2 * f[i - 2];
} int t;
while(~scanf("%d", &t))
{
printf("%I64d\n", f[t]);
} } int main()
{
ace();
return 0;
}
[原]hdu2045 不容易系列三——LELE的RPG难题 (递推方程)的更多相关文章
- HDU 2045不easy系列之三LELE的RPG难题(趋向于DP的递推)
不easy系列之(3)-- LELE的RPG难题 Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Ot ...
- (杭电 2045)不容易系列之(3)—— LELE的RPG难题
不容易系列之(3)-- LELE的RPG难题 Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Othe ...
- hdoj 2045 不容易系列之(3)—— LELE的RPG难题
不容易系列之(3)—— LELE的RPG难题 Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/O ...
- HDU 2045 不容易系列之(3)—— LELE的RPG难题(递归/动态规划)
不容易系列之(3)—— LELE的RPG难题 Problem Description 人称“AC女之杀手”的超级偶像LELE最近忽然玩起了深沉,这可急坏了众多“Cole”(LELE的粉丝,即" ...
- HDU 2045 LELE的RPG难题(递推)
不容易系列之(3)—— LELE的RPG难题 Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/O ...
- Z - 不容易系列之(3)―― LELE的RPG难题
Description 人称“AC女之杀手”的超级偶像LELE最近忽然玩起了深沉,这可急坏了众多“Cole”(LELE的粉丝,即"可乐"),经过多方打探,某资深C ...
- 2045不容易系列之(3)—— LELE的RPG难题
Problem Description人称“AC女之杀手”的超级偶像LELE最近忽然玩起了深沉,这可急坏了众多“Cole”(LELE的粉丝,即”可乐”),经过多方打探,某资深Cole终于知道了原因,原 ...
- Hdoj 2045.不容易系列之(3)—— LELE的RPG难题 题解
Problem Description 人称"AC女之杀手"的超级偶像LELE最近忽然玩起了深沉,这可急坏了众多"Cole"(LELE的粉丝,即"可乐 ...
- A - 不容易系列之(3)―― LELE的RPG难题 简单递推
人称“AC女之杀手”的超级偶像LELE最近忽然玩起了深沉,这可急坏了众多“Cole”(LELE的粉丝,即"可乐"),经过多方打探,某资深Cole终于知道了原因,原来,LELE最近研 ...
随机推荐
- ubuntu开机遇到-您的当前网络有.local域,我们不建议这样做而且这与AVAHI网络服务探测不兼容。该服务已被禁用
解决 http://askubuntu.com/questions/339702/network-service-discovery-disabled-what-does-this-mean-for- ...
- gettimeofday() 获取系统时间,精确到微秒 这个似乎只能在linux 下用,不能在windows 下用
struct timeval{ long int tv_sec; // 秒数 同time(NULL) 的返回值 long int tv_usec; // 微秒数 10 的6次方 }; struct t ...
- oracle查询锁和杀锁
查询锁: SELECT l.session_id sid, s.serial#, l.locked_mode,l.oracle_username, l.os_user_name,s.machine, ...
- shell 统计 awk
time awk '{a[$1]++}END{for(i in a){printf("%d\t%s\n",a[i],i)}}' access.log | sort -nr | he ...
- win7系统安装
系统之家地址:http://www.ghostxp3.com/ Ylmf_Ghost_Win7_x64_CJB_V2016.iso
- Js 时间与字符串转示例
<!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <m ...
- How to Modify Public Network Information including VIP in Oracle Clusterware (文档 ID 276434.1)
APPLIES TO: Oracle Database - Enterprise Edition - Version 11.2.0.3 to 12.1.0.2 [Release 11.2 to 12. ...
- Orchard官方文档翻译(三) 通过zip文件手动安装Orchard
原文地址:http://docs.orchardproject.net/Documentation/Manually-installing-Orchard-zip-file 想要查看文档目录请用力点击 ...
- Object-oriented features
Python is an object-oriented programing language, which means that it provides features that support ...
- only one is important
今天早上还是去了图书馆,看了一早上的hello world(intel opencl),清楚了程序编写的基本流程,但是,仍和以前一样,貌似看懂了,其实什么也不会,没有发现什么问题.中午,回来取了我的笔 ...