ICode9

精准搜索请尝试: 精确搜索
  • UVA11584 划分成回文串 Partitioning by Palindromes2022-09-11 22:00:10

    题面       这道题一开始想用简单的区间DP   #include<stdio.h> #include<iostream> #include<cstdlib> #include<string.h> #include<algorithm> using namespace std; int T; char s[2000]; int dp[1010][1010]; int palind(int l,int r)//回文判断函数 { wh

  • 情侣名2022-08-23 15:30:08

                    解析: 主要是char  string 与 int 的转换 用map即可 构造出关系矩阵就好了 #include <bits/stdc++.h> using namespace std; map<string, int> index; map<string, int> hashmap; map<int, string> unhashmap; map<string, int> vis; vector<stri

  • 1010 Radix(25分)2022-08-22 01:02:30

    Given a pair of positive integers, for example, 6 and 110, can this equation 6 = 110 be true? The answer is yes, if 6 is a decimal number and 110 is a binary number. Now for any pair of positive integers N1​ and N2​, your task is to find the radix of on

  • Codeforces Round #812 (Div. 2) E(并查集)2022-08-07 23:03:04

    种类并查集:定义种类之间的关系来判断操作是否进行 题目大意:对于题目给出的一个矩阵,我们可以进行一种操作:swap(a[i][j],a[j][i]) 使得矩阵可以变换为字典序最小的矩阵   思路:   通过扫描整个矩阵,每次都判断a[i][j] 和 a[j][i]是否需要交换   交换的前提就是: 对第i行/第j列操作

  • hdu 2639 Bone Collector II2022-08-03 00:34:08

    题目链接:https://vjudge.net/problem/HDU-2639 题目大意:求一个0-1背包中第k个最优解   思路:   将最优解的个数也作为背包的一维来进行递推,只不过递推的依据需要额外的两个数组来记录在相同体积下的第s次最优解    1 # include<iostream> 2 # include<bits/stdc++.h> 3 us

  • P2853 [USACO06DEC]Cow Picnic S2022-07-30 17:01:21

    P2853 [USACO06DEC]Cow Picnic S   和这道差不多P3916 图的遍历,图的遍历通过方向建边使子节点被标记最大编号。这题可以通过奶牛找牧场 分析:从奶牛的位置开始dfs,对每个被dfs的点进行标记,最后统计有多少个点的标记的数量等于奶牛的值。 代码: #include<iostream> #include<algorit

  • js位运算2022-07-26 21:35:53

    位运算 1.左移 << num<<n:将 num 转为二进制,左移 n 位, 在后面补n个0(输出的结果是十进制的) 例如:1. 10<<2  //结果为 40(101000 )    2. 负数怎么移位 (以-10<<2为例)                2.右移 >>   num>>n:将 num 转为二进制,右移 n 位 例如:1. 10>>2 //10的二进制

  • 1010 Radix 测试点7 只能用二分查找2022-07-19 14:04:40

    易错点 这道题的测试点7的数据很大,因此如果硬要用顺序查找在找到之前会超时,只能用所谓的二分法才能通过这个点。 用二分查找的时候,需要注意long long也会溢出,需要设置一个特别的判断。 代码 #include <iostream> #include <cstdio> #include <iomanip> using namespace std; float

  • AcWing算法基础课第五讲2022-07-18 23:35:48

    (typora要清理,暂时上传避免丢了) #2 01背包问题 题目描述 有 \(N\) 件物品和一个容量是 \(V\) 的背包。每件物品只能使用一次。 第 \(i\) 件物品的体积是 \(v_i\),价值是 \(w_i\)。 求解将哪些物品装入背包,可使这些物品的总体积不超过背包容量,且总价值最大。 输出最大价值。 试解 #in

  • 1010 「木」迷雾森林 线性DP 动态规划2022-07-06 01:31:08

    链接:https://ac.nowcoder.com/acm/problem/53675来源:牛客网 题目描述 </h2> 赛时提示:保证出发点和终点都是空地 帕秋莉掌握了一种木属性魔法 这种魔法可以生成一片森林(类似于迷阵),但一次实验时,帕秋莉不小心将自己困入了森林 帕秋莉处于地图的左下角,出口在地图右上

  • 数制转换2022-06-18 22:03:28

    一、计算机的数制 数制:计数的方法,指用一组固定的符号和统一的规则表示数值的方法 数位:指数字符号在一个数中所处的位置 基数:指在某种进位计数制中,数位上所能使用的数字符号的个数 位权:指在某种进位计数制中,数位所代表的大小,即处在某一位上的“1”所表示的数值的大小 1、十进制数

  • 判断两个IP地址是否同一个网段2022-06-16 17:06:26

    ================================ ©Copyright 蕃薯耀 2022-06-16 https://www.cnblogs.com/fanshuyao/   第一个IP地址 IPv4 地址 . . . . . . . . . . . . : 192.168.10.175 子网掩码 . . . . . . . . . . . . : 255.255.254.0 (IP和子网掩码)转换成二进制: 1100 0000,1010

  • 【完全背包问题】AcWing3.完全背包问题——朴素、优化、状压、思维转换2022-06-13 18:03:28

    AcWing3.完全背包问题 题解 朴素写法 #include <iostream> using namespace std; const int N = 1010; int v[N], w[N]; int f[N][N]; int main() { int n, m; cin >> n >> m; for(int i = 1; i <= n; ++i) cin >> v[i] >> w[

  • 洛谷P1216 [USACO1.5][IOI1994]数字三角形 Number Triangles (DP入门)2022-06-11 17:01:35

    考虑逆推就行了。 1 #include<bits/stdc++.h> 2 using namespace std; 3 int n; 4 int a[1010][1010]; 5 int main(){ 6 scanf("%d",&n); 7 for(int i=1;i<=n;i++) 8 for(int j=1;j<=i;j++) 9 scanf("%d",

  • 维修道路2022-06-10 22:05:58

       这道题目涉及到一个新算法:Floyd 这里不放洋屁了,大体就是 DP! 就是一个固定格式的dp 它的核心代码非常简单(也非常像dp) for(int k=1;k<=V;k++) { for(int i=1;i<=V;i++) { for(int j=1;j<=V;j++) { if(dis[i][j]

  • 最短路-离开中山路2022-06-09 11:04:22

    离开中山路 题目背景 《爱与愁的故事第三弹·shopping》最终章。 题目描述 爱与愁大神买完东西后,打算坐车离开中山路。现在爱与愁大神在x1,y1处,车站在x2,y2处。现在给出一个n×n(n<=1000)的地图,0表示马路,1表示店铺(不能从店铺穿过),爱与愁大神只能垂直或水平着在马路上行进。爱与愁大神

  • 2021级ACM班&2022年寒假集训《数据结构》专题12--拓扑排序和关键路径2022-05-11 16:02:27

    A - 数据结构实验之图论十:判断给定图是否存在合法拓扑序列 题目链接 https://acm.sdut.edu.cn/onlinejudge3/contests/3990/problems/A 判定拓扑序列模板题 1 #include<bits/stdc++.h> 2 using namespace std; 3 int n,m,flag; 4 int mapp[1010][1010]; 5 int vis[1010];

  • 剪花布条 HDU-20872022-05-05 23:34:08

    题目链接:https://vjudge.net/problem/HDU-2087 居然WA #include<cstdio> #include<cstring> #include<cmath> #include<algorithm> using namespace std; int nxt[1010]; void get_nxt(char t[]){ int j=0, k=-1; nxt[0]=-1; int tlen=strlen

  • PAT Advanced Level 1010 Radix2022-04-27 08:32:02

    原题传送门 1. 问题描述 2. Solution 1、思路分析 分析:convert函数:给定一个数值和一个进制,将它转化为10进制。转化过程中可能产生溢出 find_radix函数:找到令两个数值相等的进制数。在查找的过程中,需要使用二分查找算法,如果使用当前进制转化得到数值比另一个大或者小于0,说明这个进

  • 【DP】动态规划专题2022-04-20 14:04:20

    895. 最长上升子序列 #include <iostream> using namespace std; const int N = 1010; int n; int a[N], f[N]; int main() { scanf("%d", &n); for(int i = 1; i <= n; i ++ ) scanf("%d", &a[i]); for(int i = 1; i &l

  • Cow Picnic S2022-04-19 18:35:03

    题目描述 K(1≤K≤100)只奶牛分散在N(1≤N≤1000)个牧场.现在她们要集中起来进餐.牧场之间有M(1≤M≤10000)条有向路连接,而且不存在起点和终点相同的有向路.她们进餐的地点必须是所有奶牛都可到达的地方.那么,有多少这样的牧场呢? 输入 第一行三个数,K,N,M 接下来K+1行,每行一个数表示

  • 洛谷P4147 玉蟾宫 (单调栈)2022-04-15 22:02:26

    要求我们去找一个最大矩形面积。 单调栈做法(和P1950 长方形那道题类似(一模一样))。 1 #include<bits/stdc++.h> 2 using namespace std; 3 char M[1010][1010]; 4 int n,m,h[1010],l[1010],r[1010]; 5 int s[1010],top; 6 7 void ddzl(){ 8 top=0; 9 for(int i=m

  • P1216 [USACO1.5][IOI1994]数字三角形 Number Triangles 题解2022-04-08 12:03:47

    题目描述 观察下面的数字金字塔。 写一个程序来查找从最高点到底部任意处结束的路径,使路径经过数字的和最大。每一步可以走到左下方的点也可以到达右下方的点。 7 3 8 8 1 0 2 7 4 4 4 5 2 6 5 在上面的样例中,从 $ 7 \to 3 \to 8

  • 洛谷 P2437 蜜蜂路线2022-04-02 13:32:17

    题目链接 https://www.luogu.com.cn/problem/P2437 和p1255数楼梯这个题,不能说是毫不相同,只能说是一模一样。 不过是起点变化,不再是第一层了。 放AC代码 1 #include<bits/stdc++.h> 2 using namespace std; 3 int n,m,len=1; 4 int f[1010][1010]; 5 void fib_high(int x)

  • acwing.【完全背包问题】(dp)2022-02-23 17:03:53

    #include<iostream> #include<vector> #include<string> #include<set> #include<algorithm> #include<stdio.h> using namespace std; int vi[1010],wi[1010]; long long dp[1010][1010]; long long dfs(int i,int j){ long long res=

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

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

ICode9版权所有