LeetCode Contest 166】的更多相关文章

LeetCode Contest 166 第一次知道LeetCode 也有比赛. 很久没有打过这种线上的比赛,很激动. 直接写题解吧 第一题 很弱智 class Solution { public: int subtractProductAndSum(int n) { int num1=0; int num2=1; while(n) { int x = n%10; num1+=x; num2*=x; n/=10; } return num2-num1; } }; 第二题 也很简单的,我先排个序.…
[LeetCode]166. Fraction to Recurring Decimal 解题报告(Python) 标签(空格分隔): LeetCode 作者: 负雪明烛 id: fuxuemingzhu 个人博客: http://fuxuemingzhu.cn/ 题目地址:https://leetcode.com/problems/fraction-to-recurring-decimal/description/ 题目描述: Given two integers representing t…
Q1: 520. Detect Capital Given a word, you need to judge whether the usage of capitals in it is right or not. We define the usage of capitals in a word to be right when one of the following cases holds: All letters in this word are capitals, like "USA…
No.166 FractionToDecimal 分数到小数 题目 给定两个整数,分别表示分数的分子 numerator 和分母 denominator,以字符串形式返回小数. 如果小数部分为循环小数,则将循环的部分括在括号内. 示例 输入: numerator = 1, denominator = 2 输出: "0.5" 输入: numerator = 2, denominator = 1 输出: "2" 输入: numerator = 2, denominato…
Fraction to Recurring Decimal Given two integers representing the numerator and denominator of a fraction, return the fraction in string format. If the fractional part is repeating, enclose the repeating part in parentheses. For example, Given numera…
题目 Given two integers representing the numerator and denominator of a fraction, return the fraction in string format. If the fractional part is repeating, enclose the repeating part in parentheses. For example, Given numerator = 1, denominator = 2, r…
VP赛况如下: 前言:感觉这一场题目难度还是比较贴近新生的,我一个codeforces小蓝名一小时居然AK了,F题数据有点水(?)暴力dfs居然都能过... A:A?C 题意:给你字符串,如果字符串是ABC,那么就输出ARC:反之输出ABC. #include<bits/stdc++.h> using namespace std; int main(){ string a;cin>>a; ]=='R') cout<<"ABC"<<endl…
题目二 题目描述 5690. 最接近目标价格的甜点成本  难度:中等-中等 题解 解法一:三进制状态压缩 考虑到baseCosts.toppingCosts的长度最多都为10,每一种辅料都有加0.1.2份的选择,因此可以考虑三进制状态压缩求解.类似二进制的状态压缩. 以10种辅料为例. 直到curJ为0. 代码: 1 class Solution { 2 public int closestCost(int[] baseCosts, int[] toppingCosts, int target)…
Fraction to Recurring Decimal Given two integers representing the numerator and denominator of a fraction, return the fraction in string format. If the fractional part is repeating, enclose the repeating part in parentheses. Example 1: Input: numerat…
463. Island Perimeterhttps://leetcode.com/problems/island-perimeter/就是逐一遍历所有的cell,用分离的cell总的的边数减去重叠的边的数目即可.在查找重叠的边的数目的时候有一点小技巧,就是沿着其中两个方向就好,这种题目都有类似的规律,就是可以沿着上三角或者下三角形的方向来做.一刷一次ac,但是还没开始注意codestyle的问题,需要再刷一遍. class Solution { public: int islandPerime…