码迷,mamicode.com
首页 >  
搜索关键字:ans    ( 3741个结果
选择困难症
#include<bits/stdc++.h> using namespace std; #define int long long const int maxn = 110; int k, m; int a[maxn], v[maxn][maxn]; int ans; void dfs(int p ...
分类:其他好文   时间:2020-05-02 16:38:49    阅读次数:44
4038: Robot Navigation --bfs(求最短路及其路径条数)
http://www.tzcoder.cn/acmhome/problemdetail.do?method=showdetail&id=4038 用bfs找出最短路,同时更新到该点的路径条数ans 用ans[i][j][f]表示i,j点f方向 f用0,1,2,3表示4个方向 同时和dx,dy数组联系 ...
分类:其他好文   时间:2020-05-01 15:05:30    阅读次数:55
一本通 高手训练 1763 简单树 可持久化线段树 树链刨分 标记永久化
LINK: "简单树" 以后我再不认真读题 我TM活该退役 又因为没认真读题多调了20min.时间珍贵啊。 题目最后让ans%n 我没取模 自闭ing. 还是挺有意思的题目。求x到区间[L,R]的所有点的距离。 这个还是一个非常经典的问题。需要把答案的式子列出来。 $\sum_{i=L}^R(dis ...
分类:其他好文   时间:2020-04-30 21:00:27    阅读次数:67
【小米OJ-找出可能的合的组合】深搜(dfs)
import java.util.*; public class Main { static int ans; static int num[]; public static void main(String args[]) { Scanner scan = new Scanner(System.i ...
分类:移动开发   时间:2020-04-30 19:18:28    阅读次数:65
1002. 查找常用字符
思路: 1、按字符串长度升序排列,以排序后的首字符串中的元素为目标;2、遍历首字符串,每一趟遍历前要统计当前字符ch分别在首字符串和返回值ans中的个数:numi和numans;3、若ch未在ans里出现过(即numans<1),且在剩余字符串中都出现过,则将ch追加到ans中; 遍历剩余字符串时, ...
分类:其他好文   时间:2020-04-29 11:07:57    阅读次数:63
977. 有序数组的平方
代码一: 1 class Solution(object): 2 def sortedSquares(self, A): 3 """ 4 :type A: List[int] 5 :rtype: List[int] 6 """ 7 ans=[] 8 for i in range(len(A)): 9 ...
分类:编程语言   时间:2020-04-29 10:50:17    阅读次数:66
【经典】容斥+排列组合——cf1342E
/* 设每行都有一个,每列上每多一个攻击对就会+1, 列上多了k个,那么只有n-k列上有棋子C(n,n-k) 问题变成将n个棋子放在n-k列上,且每列必须有一个,每行必须有且仅有一个的方案数 容斥: ans=将n个棋子随便放在某一列 pow(n-k,n) -有一个空行 pow(n-k-1,n)C(n ...
分类:其他好文   时间:2020-04-28 13:13:59    阅读次数:50
动态规划入门
例1: def jianshuiguo(n,ans): dp=[[0 for i in range(n+1)]for j in range(n+1)] dp[1][0]=ans[1][0] # print(dp) sum=0 for i in range(2,n+1): for j in range ...
分类:其他好文   时间:2020-04-28 09:21:07    阅读次数:34
luogu P3478 [POI2008]STA-Station 换根dp
``` #include #include #include #include using namespace std; #define int long long const int N=4e6+10; int e[N],ne[N],h[N],idx; int depth[N]; int ans[... ...
分类:其他好文   时间:2020-04-27 21:00:16    阅读次数:52
大家都知道斐波那契数列,现在要求输入一个整数n,请你输出斐波那契数列的第n项(从0开始,第0项为0)。 n<=39
public class Solution { public int Fibonacci(int n) { int ans[] = new int[40]; ans[0] = 0; ans[1] = 1; for(int i=2;i<=n;i++){ ans[i] = ans[i-1] + ans[ ...
分类:其他好文   时间:2020-04-25 19:29:03    阅读次数:97
3741条   上一页 1 ... 13 14 15 16 17 ... 375 下一页
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!