Codeforces 41D Pawn 简单dp】的更多相关文章

题目链接:点击打开链接 给定n*m 的矩阵 常数k 以下一个n*m的矩阵,每一个位置由 0-9的一个整数表示 问: 从最后一行開始向上走到第一行使得路径上的和 % (k+1) == 0 每一个格子仅仅能向↖或↗走一步 求:最大的路径和 最后一行的哪个位置作为起点 从下到上的路径 思路: 简单dp #include <cstdio> #include <algorithm> #include<iostream> #include<string.h> #incl…
题目链接:http://codeforces.com/problemset/problem/279/C 题意: 给出 $n$ 个整数 $a[1 \sim n]$,$m$ 个查询,对于一个查询 $[l_i,r_i]$,对应于子段 $a[l_i], a[l_i+1], \cdots, a[r_i]$,需要你判断这个子段是不是单峰的. 此处的单峰,指的是,开始时是一段单调不减的,然后以一段单调不增结束:同时这两段的长度为零也是可以的. 题解: 令 $f[i]$ 表示第 $i$ 个整数往前走,保持单调不…
题目链接:http://codeforces.com/problemset/problem/180/C 题意: 有一段字符串,包含大小写字母,每次可以将其中一个字母由大写变成小写,或者小写变成大写.要求这个字符串最终变成任意大写字母都在任意小写字母的前面的情况.问最少变换多少个字母可达到要求. 题解: $f[i][0,1]$ 表示前 $i$ 个字母,第 $i$ 个字母为 $0$大写 / $1$小写,最少要改变的字母数. AC代码: #include<bits/stdc++.h> #define…
题目链接:http://codeforces.com/problemset/problem/698/A 题意: 有 $n$ 天假期,每天有四种情况:0.体育馆不开门,没有比赛:1.体育馆不开门,有比赛:2.体育馆开门,没有比赛:3.体育馆开门,有比赛. 每天都可以选择一件事做:休息.去体育馆运动.打比赛. 现在有一个限制条件:不能连续两天都去体育馆,或者连续两天都打比赛.要求尽量使得休息的天数最少,求出这个天数. 题解: $f[i][0,1,2]$ 表示前 $i$ 天,第 $i$ 天休息/运动/…
题目链接:http://codeforces.com/problemset/problem/455/A 给你n个数,要是其中取一个大小为x的数,那x+1和x-1都不能取了,问你最后取完最大的和是多少. 简单dp,dp[i]表示取i时zui最大和为多少,方程为dp[i] = max(dp[i - 1] , dp[i - 2] + cont[i]*i). #include <bits/stdc++.h> using namespace std; typedef __int64 LL; ; LL a…
Problem H. ICPC QuestTime Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/gym/100500/attachments Description Noura Boubou is a Syrian volunteer at ACM ACPC (Arab Collegiate Programming Contest) since 2011. She graduated from Tishreen Un…
C. Writing Code Time Limit: 20 Sec  Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/544/problem/C Description Programmers working on a large project have just received a task to write exactly m lines of code. There are n programmers working o…
D. Fedor and Essay time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output After you had helped Fedor to find friends in the «Call of Soldiers 3» game, he stopped studying completely. Today, the E…
C. Dasha and Password time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output After overcoming the stairs Dasha came to classes. She needed to write a password to begin her classes. The password i…
Super Jumping! Jumping! Jumping! Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 33384    Accepted Submission(s): 15093 Problem Description Nowadays, a kind of chess game called “Super Jumping!…