题目大意: 给出一个序列,然后求这个序列的最大上升子序列的和。 题解:定义状态dp[i]表示前i个数的最大和,dp[i]的最小值应该是arr[i]了,因为i前边可能有负数,对于负数,虽然可以构成上升子序列,但是没有必要选。 code: #include<bits/stdc++.h> using namespace std; const long long INF
1087 有多少不同的值 (20分) 当自然数 n 依次取 1、2、3、……、N 时,算式 ⌊n/2⌋+⌊n/3⌋+⌊n/5⌋ 有多少个不同的值?(注:⌊x⌋ 为取整函数,表示不超过 x 的最大自然数,即 x 的整数部分。) 输入格式: 输入给出一个正整数 N(2≤N≤10^4)。 输出格式: 在一行中输出题面中算式取到的不同
题目 题意: 有N个城市,M条无向边,从某个给定的起始城市出发,前往名为ROM的城市。每个城市(除了起始城市)都有一个点权(称为幸福值),和边权(每条边所需的花费)。求从起点到ROM所需要的最少花费,并输出其路径。如果路径有多条,给出幸福值最大的那条。如果仍然不唯一,选择路径上的城市平均幸福
题解 最短路径经典题型。套最短路的板子再加上额外的要求就可以了(说起来好简单)。SPFA也行,Dijkstra也可以。这里我用的是SPFA。因为题目要求,将地名和其对应的数字用map映射一下,这样方便处理。 same[i]代表到达地点 i 有几种路径; dist[i]代表从
带飞网址
原题链接在这里:https://leetcode.com/problems/brace-expansion/ 题目: A string S represents a list of words. Each letter in the word has 1 or more options. If there is one option, the letter is represented as is. If there is more than one option, then curly
当自然数 n 依次取 1、2、3、……、N 时,算式 ⌊n/2⌋+⌊n/3⌋+⌊n/5⌋ 有多少个不同的值?(注:⌊x⌋ 为取整函数,表示不超过 x 的最大自然数,即 x 的整数部分。) 输入格式: 输入给出一个正整数 N(2≤N≤104)。 输出格式: 在一行中输出题面中算式取到的不同值的个数。 输入样例: 2017 输出样例:
E - Super Jumping! Jumping! Jumping!HDU - 1087 题目链接:https://vjudge.net/contest/68966#problem/E 题目: Nowadays, a kind of chess game called “Super Jumping! Jumping! Jumping!” is very popular in HDU. Maybe you are a good boy, and know little about this game
1087 All Roads Lead to Rome (30 分) Indeed there are many different tourist routes from our city to Rome. You are supposed to find your clients the route with the least cost while gaining the most happiness. Input Specification: Each input file contains
传送门 题意: 给你一个\(n*n\)的格子,如果第\(i\)个格子放入了棋子,则八联通方向都不能放置棋子,问放置\(k\)个棋子的方案数。 分析: 很明显可以进行\(dp\),又因为\(n\)非常的小,因此我们可以采用状态压缩的方法。设\(dp[i][state][k]\)为当前第\(i\)行的状态为\(state\)时,放置了\(k\)个棋
https://blog.csdn.net/lvshubao1314/article/details/42926803 https://blog.csdn.net/scut_pein/article/details/9671969
Poj 1087 A Plug for UNIX 最大流 题目描述: You are in charge of setting up the press room for the inaugural meeting of the United Nations Internet eXecutive (UNIX), which has an international mandate to make the free flow of information and ideas on the Internet
风华是一指流砂,苍老是一段年华。 题目描述 用筛法求N(<1000)之内的素数。 输入 N 输出 0~N的素数 样例输入 copy 100 样例输出 2 3 5 7 11 13 17 19 23 29 31 37 41 43 47 53 59 61 67 71 73 79 83 89 97 #include <iostream> #include<cstring> #include<cstdio> #include<i
题目描述: 输入n个整数,依次输出每个数的约数的个数 输入: 输入的第一行为N,即数组的个数(N<=1000) 接下来的1行包括N个整数,其中每个数的范围为(1<=Num<=1000000000) 当N=0时输入结束。 输出: 可能有多组输入数据,对于每组输入数据, 输出N行,其中每一行对应上面的一个数的约数的个数。
https://pintia.cn/problem-sets/994805342720868352/problems/994805379664297984 Indeed there are many different tourist routes from our city to Rome. You are supposed to find your clients the route with the least cost while gaining the most happiness. Inp
Nowadays, a kind of chess game called “Super Jumping! Jumping! Jumping!” is very popular in HDU. Maybe you are a good boy, and know little about this game, so I introduce it to you now. The game can be played by two or more than two players. It consists o