CodeForces 474.D Flowers】的更多相关文章

题意: 有n朵花排成一排,小明要么吃掉连续的k朵白花,或者可以吃单个的红花. 给出一个n的区间[a, b],输出总吃花的方法数模 109+7 的值. 分析: 设d(i)表示吃i朵花的方案数. 则有如下递推关系: d[i] = d[i-1] + d[i-k], (i ≥ k, d[0] = 1) 我们在计数i+1的情况时,可以分为如下两种情况: 最后一朵是红花,方案数为d[i] 最后k朵是白花,方案数为d[i-k] 然后预处理一下前缀和. 代码中注意取模. #include <cstdio> +…
线段树求某一段的GCD..... F. Ant colony time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Mole is hungry again. He found one ant colony, consisting of n ants, ordered in a row. Each ant i (1 ≤ i ≤ n)…
水太...... E. Pillars time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Marmot found a row with n pillars. The i-th pillar has the height of hi meters. Starting from one pillar i1, Marmot wants…
无脑暴力题,算出所有点到圆心p1的距离的平方,从小到大排序. 然后暴力枚举p1的半径的平方,计算剩余点中到p2的最大距离的平方,枚举过程中记录答案 #include<cstdio> #include<cstring> #include<vector> #include<cmath> #include<queue> #include<list> #include<algorithm> using namespace std;…
[链接] 我是链接,点我呀:) [题意] 让你吃东西 B食物一次必须要吃连续k个 但是对A食物没有要求 问你有多少种吃n个食物的方法(吃的序列) [题解] 设f[i]表示长度为i的吃的序列且符合要求的方法 有两种转移方法 一种是吃一个A食物 一种是吃k个食物 f[i] = f[i-1]+f[i-k] f[0] = 1 然后做一个前缀和输出区间和就好 [代码] import java.io.*; import java.util.*; public class Main { static Inpu…
4*4*4*4暴力+点的旋转+推断正方型 C. Captain Marmot time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Captain Marmot wants to prepare a huge and important battle against his enemy, Captain Snake. For this…
D. Flowers time limit per test:1.5 seconds memory limit per test:256 megabytes We saw the little game Marmot made for Mole's lunch. Now it's Marmot's dinner time and, as we all know, Marmot eats flowers. At every dinner he eats some red and white flo…
题目链接:http://codeforces.com/problemset/problem/474/D 题目意思:Marmot 吃两种类型的花(实在难以置信呀--):red 或者 white,如果要吃到white这种花,就需要吃连续 k 朵 white:而如果吃 red,就没有这种限制.给定区间[a, b],问总共的吃法有多少种. dp 题!状态转移方程不难得到.设 dp[i] 表示 长度为 i 时 的吃法种数. dp[i] = dp[i-1] + dp[i-k] 对于当前 i,或者是从第 i-…
C. Watering Flowers 题目连接: http://www.codeforces.com/contest/617/problem/C Descriptionww.co A flowerbed has many flowers and two fountains. You can adjust the water pressure and set any values r1(r1 ≥ 0) and r2(r2 ≥ 0), giving the distances at which t…
题目链接:http://codeforces.com/problemset/problem/474/D 用RW组成字符串,要求w的个数要k个连续出现,R任意,问字符串长度为[a, b]时,字符串的种类有多少. 递推,dp[i]表示长度为i的种类有多少.当i < k的时候 dp[i] = 1 , 当i == k的时候 dp[i] = 2 ,  否则 dp[i] = dp[i - 1] + dp[i - k] . #include <bits/stdc++.h> using namespac…