码迷,mamicode.com
首页 >  
搜索关键字:ans    ( 3741个结果
P2043 质因子分解
题目如下: 本质是一个分解质因数 代码如下: #include<cstdio> #include<cmath> #include<algorithm> #include<cstring> #include<iostream> using namespace std; int ans[10001]={ ...
分类:其他好文   时间:2020-05-07 13:45:00    阅读次数:71
【数组】228. 汇总区间
题目: 解答: 就很简单的遍历一遍...中间判断数字是否连续。 1 class Solution { 2 public: 3 vector<string> summaryRanges(vector<int>& nums) 4 { 5 vector<string> ans; 6 for(int i = ...
分类:编程语言   时间:2020-05-05 18:02:35    阅读次数:60
模拟退火板子
参数 初始温度 $tmp$, 降温系数 $\Delta$。 接受不优解的条件 $$e^{\frac{ 当前解与最优解的差}{tmp}} rand\_max 1e 14) { / 随机生成一个新解, 当前解与新解的距离 通常与温度有关 / if(calc_ans(新解) 优于 ans) { ans = ...
分类:其他好文   时间:2020-05-04 19:36:23    阅读次数:77
【字符串】151. 翻转字符串里的单词
题目: 解答: 1 class Solution { 2 public: 3 string reverseWords(string s) 4 { 5 if (s.empty()) 6 { 7 return s; 8 } 9 10 int len = 0; 11 string ans = ""; 12 ...
分类:其他好文   时间:2020-05-04 13:24:26    阅读次数:53
【字符串】647. 回文子串
题目: 解答: 1 class Solution { 2 public: 3 int countSubstrings(string s) 4 { 5 // 中心扩展法 6 int ans = 0; 7 for (int center = 0; center < 2 * s.length() - 1; ...
分类:其他好文   时间:2020-05-04 13:04:29    阅读次数:67
【字符串】1309. 解码字母到整数映射
题目: 解答: 1 class Solution { 2 public: 3 string freqAlphabets(string s) 4 { 5 string ans; 6 for (int i = 0; i < s.size(); ++i) 7 { 8 if (i + 2 < s.size( ...
分类:其他好文   时间:2020-05-04 00:24:14    阅读次数:57
uoj418
题意 "uoj" 做法 下面考虑算$ans_1$,也就是 全局 将操作拍成一个序列,一个显然的贪心是放$w_i$后取出$\sum\limits_{v\in son_i}w_v$,相当于到一个点$i$时,$A_i=+w_i \sum\limits_{v\in son_i}w_v$,求最大前缀和 这样会 ...
分类:其他好文   时间:2020-05-03 18:31:01    阅读次数:62
luogu P1272 重建道路 类似树上背包的树形dp
``` #include #include #include using namespace std; const int N = 500; int f[N][N]; int h[N], e[N], ne[N], idx; int n, p; int ans = 0x3f3f3f3f; int in... ...
分类:其他好文   时间:2020-05-02 22:51:03    阅读次数:56
矩阵TG知识总结(矩阵求逆)
关于矩阵: $1.$ 矩阵加法:直接对应位置加 $2.$ 矩阵减法:直接对应位置减 $3.$ 矩阵乘法: $$ans_{i,j}=\sum^{n}_ {k=1} a_{i,j}\times a_{k,j}$$ 这里要求相乘的 $A$ 的行和 $B$ 的列相同 这里矩阵乘法没有交换律 $4.$ 快速幂 ...
分类:其他好文   时间:2020-05-02 20:58:37    阅读次数:54
Codeforces Round #638 (Div. 2) E Phoenix and Berries
首先考虑只按颜色分配的当前答案ans,那么最后剩下的果子数在[0,2k-2]之间,如果剩下的果子数在[0,k-1]之间,那么当前的ans就是最终答案,如果剩下的果子数在[k,2k-2]之间,那么最多答案还可以加一,也就是答案有可能是ans+1,下面我们用dp判断有无这种可能性 举个例子: n=1 k ...
分类:其他好文   时间:2020-05-02 18:46:39    阅读次数:94
3741条   上一页 1 ... 12 13 14 15 16 ... 375 下一页
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!