CommvaultOA #2
Count Ways to Travel Cities
估计中等评测数据准备中,可先阅读题面
In a country there are different cities and the cities marked with integer number starting from 1. And now you need to travel in the N cities with some following criteria.
- You need to travel exactly N cities and you can start travelling from any of the cities
- If you visit a city of number n, then the next city number will be more than or equal to 2n
- And you are also given a number K and any city number can't more than K.
Now you are given N and K, need to find how many ways you can travel the cities by keeping in mind the conditions given. And return the answer in module 1000000007 as the answer will be very large.
Function Description
Complete the function
countWaysToTravelCitiesin the editor.countWaysToTravelCitieshas the following parameters:N: an integer, the number of cities to travelK: an integer, the maximum city number allowed Returns int: the number of ways to travel the cities modulo 1000000007
Example 1
Input:
N = 3
K = 10
Output:
TO-DO
Explanation: Some of the valid city paths will be -
- 1-2-4
- 1-3-6
- 1-4-8 There are more ways to travel the cities, but these are just a few examples.