首页 > TAG信息列表 > 792

[Google] LeetCode 792 Number of Matching Subsequences

Given a string s and an array of strings words, return the number of words[i] that is a subsequence of s. A subsequence of a string is a new string generated from the original string with some characters (can be none) deleted without changing the relative

AcWing 792. 高精度减法

算法思路 与高精度加法大致相同,同样运用了“列竖式”的思想。 当然,加法中的“进位操作”要改成减法中的“退位操作”。 具体过程如下: 从最低位开始,用被减数的这一位减去减数的这一位; 判断是否构够减,若不够减(即减数的这一位大于被减数的这一位),则向高一位借一(被减数高一位减一,当前

Codeforces Round #792 (Div. 1 + Div. 2)解题报告

A. Digit Minimization 题意:对一个数字串轮流进行如下操作: 1.任选两个不同位置的数字交换 2.删除最后一个数字 问最后剩下的最小的数字是多少 分析:贪心,最后剩下的数一定是第一个位置上的数,那么一开始就把最小的数字放第一位即可,特判数字串长度为2的情况 ac代码 #include<iostream

Codeforces Round #792 (Div. 1 + Div. 2) A-E

Codeforces Round #792 (Div. 1 + Div. 2) A-E A 题目 https://codeforces.com/contest/1684/problem/A 题解 思路 知识点:数学。 显然长度大于等于3的数字串的最小数位是完全可以通过这些操作留到最后。 长度等于2的数字串只可能是个位数字。 时间复杂度 \(O(n)\) 空间复杂度 \(O(

Codeforces Round #792 (Div. 1 + Div. 2) A - E 题解

传送门 A. Digit Minimization 一开始以为是只能换相邻的,wa 了好多发 如果是 n = 2 的话,只能是第二个 其他的情况就都是最小的那个,把最小的放到第一个,然后剩下的慢慢磨 #include <iostream> #include <cstdio> #include <algorithm> #include <vector> #include <string> #include

792. 高精度减法

    #include <iostream> #include <vector> using namespace std; bool cmp(vector<int> A, vector<int> B) { if (A.size() != B.size()) return A.size() > B.size(); for (int i = A.size() - 1; i >= 0; -- i)

acwing 792高精度减法

ACWing 792 高精度减法 题目: #include<iostream> #include<cstdio> #include<algorithm> #include<vector> using namespace std; bool cmp(vector<int>&a,vector<int>&b) { if(a.size()!=b.size()) return a.size()>b

AcWing 792. 高精度减法

基础算法 AcWing 792. 高精度减法二、题解c代码 AcWing 792. 高精度减法 给定两个正整数,计算它们的差,计算结果可能为负数。 输入格式 共两行,每行包含一个整数。 输出格式 共一行,包含所求的差。 数据范围 1