ICode9

精准搜索请尝试: 精确搜索
  • P1063 能量项链2019-07-16 14:03:28

    题面:https://www.luogu.org/problemnew/show/P1063 本题应先将数组拓宽一倍,这样就实现了环,之后枚举起始端点和区间长度,这样就能够算出结束端点,再利用转移方程f[l][r]=max(f[l][r],f[l][j]+f[j+1][r]+a[l]*a[j+1]*a[r+1])就能算出答案。 #include<iostream> #include<cstdio> #

  • [HAOI2006]聪明的猴子2019-07-14 23:52:46

    [Time Gate] https://www.luogu.org/problemnew/show/P2504 【解题思路】 这题和P2872道路建设几乎差不多,主要思路:   算两点之间距离,然后跑Kruskal找最大的边,和每只猴子跳跃距离比较一下,同步计数即可 【code】 1 #include <cstdio> 2 #include <cmath> 3 #include <algorithm>

  • 【HDU - 2612】Find a way2019-07-05 21:51:39

    -->Find a way 直接上Chinese  Descriptions: hsj和lsh最近迷上了pokemon go的游戏。在双十一大物期中考试来临之前,他们想抓一只稀有土拨鼠来攒攒人品(因为土拨鼠的刷新地点最近来到了哈工程)但是由于土拨鼠过于强大,他的雷霆半月斩以及惊天浪涛沙都可以轻松的将他们两击败,但是他们两

  • [POJ-3613]Cow Relays2019-06-22 13:37:52

    题目传送门 解析:这道题本质上是求两点之间经过n条边的最短路,是一道快速幂的应用,只需把快速幂自乘的操作改成最短路边数*2,把快速幂乘答案的操作改成维护答案即可。 #include<iostream>#include<cstdio>#include<map>#include<cstring>using namespace std;int minn[1005][1005],b[1

  • P1435 回文字串(DP)2019-06-15 10:00:55

    题目描述 回文词是一种对称的字符串。任意给定一个字符串,通过插入若干字符,都可以变成回文词。此题的任务是,求出将给定字符串变成回文词所需要插入的最少字符数。 比如 “Ab3bd”插入2个字符后可以变成回文词“dAb3bAd”或“Adb3bdA”,但是插入少于2个的字符无法变成回文词。 注:此问

  • 高级算法--贪心2019-06-08 20:50:39

    下面是对信息学奥赛一本通网站评测上的AC代码的总结 ·例一: 题目描述:   设有n个活动的集合E={1,2,…,n},其中每个活动都要求使用同一资源,如演讲会场等,而在同一时间内只有一个活动能使用这一资源。每个活动i都有一个要求使用该资源的起始时间si和一个结束时间fi,且si <fi。如果选择

  • LeetCode 1005 Longest Palindromic Substring2019-05-31 13:44:06

    题目 c++ 回文串,区间DP class Solution { public: int dp[1005][1005]; string longestPalindrome(string s) { int len = s.length(); int ii,jj; int m=0; for(int l=0;l<len;l++) {

  • lemon2019-05-18 17:44:51

    #include<bits/stdc++.h>using namespace std;const int maxn=1e6+5;const int INF=1e9+5;int n,m,k,w,tot,minn=INF,mark;int f[1005][1005],a[1005],b[101],d[101];template <class t>void red(t &x){ x=0; int w=1; char ch=getchar(); while(

  • D - Sequence Swapping DP2019-05-04 10:42:59

    D - Sequence Swapping  看了一天终于会写了哇咔咔。 题意:给你个长度为n的括号序列,每个括号对应一个数字,每操作你可以选择相邻的左右括号交换它们的位置同时将它们的值相乘,你可以操作任意次,问你它们值相乘的结果的和最大可以是多少啊?   解法:因为每个左括号所能到达最右的位置是固

  • PAT 1030 Travel Plan*2019-05-02 14:51:01

    1030 Travel Plan (30 分)   A traveler's map gives the distances between cities along the highways, together with the cost of each highway. Now you are supposed to write a program to help a traveler to decide the shortest path between his/her star

  • 动态规划-01背包2019-04-28 09:40:50

      https://vjudge.net/contest/297216?tdsourcetag=s_pctim_aiomsg#problem/D   #include<bits/stdc++.h>using namespace std;int a[1005];int f[1005];int main(){ int n,m; while(scanf("%d",&n)&&n!=0) { memset(f,0,sizeof

  • POJ2533 Longest Ordered Subsequence LIS2019-04-24 12:50:52

                    DescriptionA numeric sequence of ai is ordered ifa1 < a2 < ... < aN. Let the subsequence of the given numeric sequence (a1,a2, ..., aN) be any sequence (ai1,ai2, ..., aiK), where 1 <=i1 < i2 < ... < iK <=N. For exam

  • 加法天才2019-04-16 12:40:04

    题目描述 贝贝是一个聪明的小孩,他总喜欢玩数字加法的游戏。一天,他的数学老师为了考一考他的能力,出了一道这样的题:要求他在短时间内计算出两个大数相加的结果。这两个大数可不是普通的数字,它们是11位以上的“庞然大物”。 请你编程序,帮贝贝解决这个问题。 输入输出格式 输入格式: 两

  • P3974 [TJOI2015]组合数学2019-04-13 12:47:38

    题目描述 为了提高智商,ZJY开始学习组合数学。某一天她解决了这样一个问题:给一个网格图,其中某些格子有财宝。每次从左上角出发,只能往右或下走。问至少要走几次才可能把财宝全捡完。 但是她还不知足,想到了这个问题的一个变形:假设每个格子中有好多块财宝,而每一次经过一个格子至

  • 1013 Battle Over Cities2019-04-08 15:49:00

    1013 Battle Over Cities (25 分) It is vitally important to have all the cities connected by highways in a war. If a city is occupied by the enemy, all the highways from/toward that city are closed. We must know immediately if we need to repair any other

  • 洛谷 P1141 01迷宫2019-04-03 21:47:36

    看似普通的 bfs 题(实际上也不怎么难 主要是我太菜了) 题目链接:https://www.luogu.org/problemnew/show/P1141 如果直接用简单的bfs一顿求的话,会超时(别问我为什么 因为我一开始就是这么写的) 超时的代码就不贴了 所以这里就需要求它的连通块 大体思路是: 先遍历每一个点,如果这个点已经

  • Leetcode 1005. K 次取反后最大化的数组和2019-03-28 23:41:21

    1005. K 次取反后最大化的数组和  显示英文描述 我的提交返回竞赛   用户通过次数377 用户尝试次数413 通过次数385 提交次数986 题目难度Easy 给定一个整数数组 A,我们只能用以下方法修改该数组:我们选择某个个索引 i 并将 A[i] 替换为 -A[i],然后总共重复这个过

  • 10052019-03-26 15:54:15

    n = int(input()) numbers = [] numbers_print = [] numbers_input = [] numbers_input[:] = input().split() numbers_input = numbers_input[: n] i = 0 for num in numbers_input:     num = int(num)     while num != 1:         if num % 2 == 1:          

  • 【日常训练】Volleyball(CodeForces-96D)2019-03-16 15:50:24

    题意与分析 这题也是傻逼题,可是我当时打比赛的时候板子出问题了- -|||,怎么调也调不过。 不过思路是很清晰的:先做n次dijkstra然后重新建图,建完了以后根据新的单向图再跑一次dijkstra。 代码 1 #include <bits/stdc++.h> 2 3 #define ZERO(x) memset(x, 0, sizeof(x)) 4 using na

  • 洛谷1005(dp)2019-03-14 08:52:20

    1.不要贪,缩小区间去dp就好。 2.预处理指数。 3.__int128可还行。 1 #include <cstdio> 2 #include <cctype> 3 #include <cstring> 4 #include <iostream> 5 #include <algorithm> 6 using namespace std; 7 8 template <typename T> void read(T &x)

  • 匈牙利算法-二分图最大匹配问题2019-03-13 12:41:37

    https://www.luogu.org/problemnew/show/P3386 #include<cstdio>int e[1005][1005],match[1005],book[1005]; // match数组用来记录配对关系 int n,m,t;int dfs(int u){ for(int v=1; v<=m; v++) { if(book[v]==0&&e[u][v]==1) { book

  • PAT Basic 10052019-03-08 19:50:03

    1005 继续(3n+1)猜想 (25 分) 卡拉兹(Callatz)猜想已经在1001中给出了描述。在这个题目里,情况稍微有些复杂。 当我们验证卡拉兹猜想的时候,为了避免重复计算,可以记录下递推过程中遇到的每一个数。例如对 n=3 进行验证的时候,我们需要计算 3、5、8、4、2、1,则当我们对 n=5、8、4

  • hdu 1005 Number Sequence2019-02-24 22:51:30

    Number Sequence A number sequence is defined as follows: f(1) = 1, f(2) = 1, f(n) = (A * f(n - 1) + B * f(n - 2)) mod 7. Given A, B, and n, you are to calculate the value of f(n). Input The input consists of multiple test cases. Each test case contains 3

  • pat 1001-10052019-02-17 14:53:44

    1#include<stdio.h>int main(){ int n,t=0; scanf("%d",&n); while(n!=1){ if(n%2==0){ n=n/2; t++; }else{ n=(3*n+1)/2; t++; } } printf("%d\n",t); return 0;} //2#include<stdio.h>#include<string.h> int main()

  • P2219 [HAOI2007]修筑绿化带(二维单调队列)2019-02-12 16:38:10

          题目描述 为了增添公园的景致,现在需要在公园中修筑一个花坛,同时在画坛四周修建一片绿化带,让花坛被绿化带围起来。 如果把公园看成一个M*N的矩形,那么花坛可以看成一个C*D的矩形,绿化带和花坛一起可以看成一个A*B的矩形。 如果将花园中的每一块土地的“肥沃度”定义为该块土

专注分享技术,共同学习,共同进步。侵权联系[81616952@qq.com]

Copyright (C)ICode9.com, All Rights Reserved.

ICode9版权所有