程序员必知:URAL1513.LemonTale(简单的递推)

简介: 程序员必知:URAL1513.LemonTale(简单的递推)

写几组数据就会发现规律了啊。

。但是我是竖着看的。。

。还找了半天啊、、、

只是要用高精度来写,水题啊。就当熟悉一下java了啊。

num【i】 = 2*num【i-1】-num【i-2-k】。

1513. Lemon Tale

Time limit: 1.0 second

Memory limit: 64 MB

Background

For each programmer a point comes when the last contest //代码效果参考:http://www.ezhiqi.com/zx/art_2184.html is lost, and it is time to retire. Even Three Programmers themselves could not escape the common lot. But the Programmers also wanted to keep

a good memory about themselves. For this noble purpose they created problems and organized extremely popular programming contests from time to time. Of course, this work was not well paid, but for true programmers a glory was more important than money.

However it is only the first half of a job to think out a brilliant problem. The second one is to create a politically correct statement for it.

Problem

The matter is the statement of some problem for the upcoming contest was written by the Third Programmer, who knew nothing about political correctness. He just wrote a story about citrus plants growing.

As a result a word "lemon" was mentioned N times in the statement.

Besides, the problem //代码效果参考:http://www.ezhiqi.com/zx/art_3694.html is to be looked through by famous censor Alexander K. right before the contest. And it is a known fact, that lemons remind him of oranges he hates furiously. It worries the First

and the Second Programmers greatly - they know exactly, that if a word "lemon" occurs more than Ktimes successively, the problem will be immediately disqualified from the contest.

That is why the First and the Second Programmers connived secretly to login to the server at the eve of the contest and replace some "lemons" with much more politically correct "bananas" so that the

problem could not be disqualified. How many ways are there to do it?

Input

The only line contains the integer numbers N (1 ≤ N ≤ 10000) and K (0 //代码效果参考:http://www.ezhiqi.com/bx/art_2227.html ≤ K ≤ N).

Output

You should output the desired number of ways.

Sample

input

output

5 2

24

Hint

Let us denote a word "lemon" by a letter "L" and a word "banana" by a letter "B". So in the sample the initial sequence of words "LLLLL" might be transformed into the following politically correct sequences:

"LLBLL", "LLBLB", "LLBBL", "LLBBB", "LBLLB", "LBLBL", "LBLBB", "LBBLL", "LBBLB", "LBBBL", "LBBBB", "BLLBL", "BLLBB", "BLBLL", "BLBLB", "BLBBL", "BLBBB", "BBLLB", "BBLBL", "BBLBB", "BBBLL", "BBBLB", "BBBBL" and "BBBBB".

import java.math.BigInteger;

import java.util.Scanner;

public class Main {

相关文章
|
存储 JSON Ubuntu
时序数据库 TDengine 支持集成开源的物联网平台 ThingsBoard
本文介绍了如何结合 Thingsboard 和 TDengine 实现设备管理和数据存储。Thingsboard 中的“设备配置”与 TDengine 中的超级表相对应,每个设备对应一个子表。通过创建设备配置和设备,实现数据的自动存储和管理。具体操作包括创建设备配置、添加设备、写入数据,并展示了车辆实时定位追踪和车队维护预警两个应用场景。
584 3
|
JavaScript Java 测试技术
基于微信小程序的小说阅读系统的设计与实现(源码+lw+部署文档+讲解等)
基于微信小程序的小说阅读系统的设计与实现(源码+lw+部署文档+讲解等)
317 0
|
消息中间件 运维 Cloud Native
「玩物得志 App」:一家典型的云原生企业,如何在创业早期数次“弯道超车”? | 云原生Talk...
预见未来的最好方式就是创造未来。用「云原生Talk」记录云原生时代下每个造梦者的故事。
5811 75
「玩物得志 App」:一家典型的云原生企业,如何在创业早期数次“弯道超车”? | 云原生Talk...
|
消息中间件 存储 NoSQL
深入学习Redis 消息队列 Stream
Stream 是 Redis 5.0 版本中新增的一种数据结构,它是一个高性能、持久化的消息队列,可以用于实现消息的发布和订阅。Stream 可以看作是一个有序的消息队列,每个消息都有一个唯一的 ID,可以根据 ID 进行消息的查找、删除和确认。在 Stream 中,消息以键值对的形式存储,可以存储任意类型的数据。Stream 还支持多个消费者组,每个消费者组可以独立消费消息,避免消息重复消费。Stream 的引入使得 Redis 在消息队列领域更具竞争力,同时也为开发者提供了一种高效、可靠的消息处理方式
1073 0
深入学习Redis 消息队列 Stream
|
物联网 API 数据安全/隐私保护
NB-oT 移动 OneNet 云平台接入流程 | 学习笔记
快速学习 NB-oT 移动 OneNet 云平台接入流程
NB-oT 移动 OneNet 云平台接入流程 | 学习笔记
|
存储 安全 Java
Java 移除List中的元素,这玩意讲究!
Java 移除List中的元素,这玩意讲究!
1028 0
Java 移除List中的元素,这玩意讲究!
带你读《6G重塑世界》第一章移动通信发展概述1.2移动通信系统的发展历程(二)
带你读《6G重塑世界》第一章移动通信发展概述1.2移动通信系统的发展历程
带你读《6G重塑世界》第一章移动通信发展概述1.2移动通信系统的发展历程(二)
|
编译器 开发工具 Windows
Qt使用过程中,遇到error及解决方法总结
Qt使用过程中,遇到error及解决方法总结
1027 0
|
Web App开发 JavaScript 算法
用RSA加密实现Web登录密码加密传输
用RSA加密实现Web登录密码加密传输 原文地址: http://www.cnblogs.com/guogangj/archive/2012/03/05/2381117.html 通常我们做一个Web应用程序的时候都需要登录,登录就要输入用户名和登录密码,并且,用户名和登录密码都是明文传输的,这样就有可能在中途被别人拦截,尤其是在网吧等场合。
3638 0