![](https://img-blog.csdnimg.cn/20201014180756927.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
C++
without honor
这个作者很懒,什么都没留下…
展开
-
Fight Monsters
题目https://codeforces.com/problemset/problem/1296/D大神解法:将h[i]设置为还要额外加打的次数,比如怪14血,我攻击力2,队友攻击力3,那么取模后还剩4血,我再来一招,剩2血,这是正常打法,无需用技能换顺序,之和若再按正常打法则被队友打死,但又可能会因为需要加打的次数太多而不确定是否放技能,所以将额外加打次数存下,为1.然后对加打次数排序,...原创 2020-02-05 11:07:23 · 185 阅读 · 0 评论 -
Food Buying
题目https://codeforces.com/problemset/problem/1296/B买10送1比如你有141元先买140,送14剩14+1=15于是等价于15能买多少,形成递归#include<bits/stdc++.h>using namespace std;#define ll long longint main(){ ll t; c...原创 2020-02-05 10:46:12 · 191 阅读 · 0 评论 -
Array Sharpening
题目链接https://codeforces.com/contest/1291/problem/B最小为0,且相邻不重复,只能减不能加从左往右,第一个数最小是0,第二个数最小是1…将满足的dpl[i]令为true,直到第一个不满足跳出从右往右,第一个数最小是0,第二个数最小是1…后面同理若存在i,使得dpl[i]==true&&dpr[i]==true,则有峰#in...原创 2020-02-03 12:03:24 · 213 阅读 · 0 评论 -
地下城游戏--逆动态规划--LeetCode.174
class Solution {public: int calculateMinimumHP(vector<vector<int>>& dungeon) { int row=dungeon.size(); if(row==0)return 0; int col=dungeon[0].size(); ...原创 2020-02-01 20:52:07 · 149 阅读 · 0 评论 -
逆波兰表达式的求值
class Solution {public: int evalRPN(vector<string>& tokens) { stack<int>nums; queue<char>op; int size=tokens.size(); int i=0; while(i...原创 2020-01-31 21:22:55 · 85 阅读 · 0 评论 -
链表的归并排序
class Solution {public: ListNode* sortList(ListNode* head) { if(!head||!head->next)return head; return mergeSort(head); } ListNode*mergeSort(ListNode* head){ if...原创 2020-01-31 20:23:58 · 61 阅读 · 0 评论 -
LeetCode 143:重排链表
找到中点,反转后一半,合并前后class Solution {public: void reorderList(ListNode* head) { if(head==nullptr||head->next==nullptr){ return; } ListNode* slow=head; L...原创 2020-01-30 16:41:58 · 97 阅读 · 0 评论 -
same gcds
给m,n找出满足gcd(m,n)==gcd(m+x,n)&&x>=0&&m<n的所有整数x的个数#include<bits/stdc++.h>using namespace std;#define ll long longll gcd(ll m, ll n) { return n % m == 0 ? m : gcd(n %...原创 2020-01-30 12:49:10 · 274 阅读 · 0 评论 -
LeetCode 86: partition list
method 1: 使用两个空头结点记录 ListNode* partition(ListNode* head, int x) { ListNode*before_head=new ListNode(0); ListNode*before=before_head; ListNode*after_head=new ListNode(0); ...原创 2020-01-28 10:46:06 · 71 阅读 · 0 评论 -
反转链表
ListNode* reverseList(ListNode* head) { ListNode*pre=NULL; ListNode*post=NULL; if(!head)return head; post=head->next; while(post){ head->next...原创 2020-01-27 22:54:28 · 68 阅读 · 0 评论 -
c++二维vector用特定元素排序时sort中cmp的重写
Method 1:class Solution { public: vector<int> filterRestaurants(vector<vector<int>>& restaurants, int veganFriendly, int maxPrice, int maxDistance) { int size=...原创 2020-01-27 13:04:52 · 1392 阅读 · 0 评论 -
collecting packages
使用map存下每一列的最大值与最小值合法条件,后一列最小值大于等于前一列最大值#include<bits/stdc++.h>using namespace std;int main() { int n; cin >> n; while (n--) { int m; cin >> m; map<int, vector<i...原创 2020-01-23 15:53:25 · 178 阅读 · 0 评论 -
vs2019赋值问题不报错
int a = 225.0000000000000000000000001; cout << a; cout<< typeid(1.0).name();结果a是225,1.0是double所以小数默认double,若赋值给float,虽然不会报错,但精度的损失仍是存在的...原创 2019-12-27 08:43:29 · 656 阅读 · 0 评论