CF852A Digits 隔壁yijian大佬写出了正解。那我就写一个随机化大法吧? 我们先考虑一种错误的贪心,每个数字分成一位,使其分割后数字和最小。虽然这样是错的,但是我们发现错误的概率很小,所以我们可以每次随机一个数字一位或者两个数字一位。后者的概率调整在百分之一左右。我们用这样的方法做出第 ...
分类:
其他好文 时间:
2019-07-24 09:29:01
阅读次数:
163
题目描述 For a decimal number x with n digits (AnAn-1An-2 ... A2A1), we define its weight as F(x) = An * 2n-1 + An-1 * 2n-2 + ... + A2 * 2 + A1 * 1. Now y ...
分类:
其他好文 时间:
2019-07-18 13:30:13
阅读次数:
92
Are They Equal (25) 时间限制 1000 ms 内存限制 65536 KB 代码长度限制 100 KB 题目描述 If a machine can save only 3 significant digits, the float numbers 12300 and 12358.9 ...
分类:
其他好文 时间:
2019-07-17 00:44:02
阅读次数:
110
A. Nearest Interesting Number 题目链接:http://codeforces.com/contest/1183/problem/A 题目: Polycarp knows that if the sum of the digits of a number is divisi ...
分类:
其他好文 时间:
2019-07-08 00:15:32
阅读次数:
119
Given a non-negative integer n, count all numbers with unique digits, x, where 0 ≤ x < 10n. Example: Input: 2 Output: 91 Explanation: The answer shoul ...
分类:
其他好文 时间:
2019-07-05 19:24:57
阅读次数:
90
背景 在LeetCode上遇到这道题:Add Digits 题目很简单,但是如果要用 O(1) 时间复杂度,不要涉及循环或递归来解答的话,我就不知道如何下手了。 于是我找了一下别人的解法,发现涉及到一个 Digital Root 的原理(由于维基百科打不开,所以我觉得有必要记录一下我搜集到的信息和理 ...
分类:
其他好文 时间:
2019-06-26 19:24:11
阅读次数:
139
这是悦乐书的第 363 次更新,第 391 篇原创 01 看题和准备 今天介绍的是 算法题中 级别的第 题(顺位题号是 )。给定4个整数组成的数组,返回最大的24小时时间。 最小的24小时时间是00:00,最大的是23:59。 从00:00开始,如果从午夜开始经过更多时间,则时间会更长。 将答案作为 ...
分类:
其他好文 时间:
2019-06-25 09:38:12
阅读次数:
70
本文介绍Python3中String模块ascii_letters和digits方法,其中ascii_letters是生成所有字母,从a-z和A-Z,digits是生成所有数字0-9.string.punctuation是所有标点'!"#$%&\'()*+,-./:;<=>?@[\\]^_`{|}~ ...
分类:
编程语言 时间:
2019-06-19 00:28:14
阅读次数:
114
Given a non-negative integer num represented as a string, remove k digits from the number so that the new number is the smallest possible. Note: The l ...
分类:
其他好文 时间:
2019-06-15 15:43:20
阅读次数:
104