本题来自 Project Euler 第13题:https://projecteuler.net/problem=13 # Project Euler: Problem 13: Large sum # Work out the first ten digits of the sum of the following one-hundred 50-digit numbers. # Answer: 5537376230 numbers = '''371072875339021027987979982…
1.oracle 取前10条记录 1) select * from tbname where rownum < 11; 2) select * from (select * from tbname order by id desc ) where rownum<=10; 下面是关于rownum的介绍================================三. Rownum和row_number() over()的使用ROWNUM是oracle从8开始提供的一个伪列,是把SQL出来的结果…
在sql server中,取数据中前10条语句,我们可以用top 10 这样语句,但是oracle就没有这个函数,接下来介绍它们之间的区别 1.sql server 取前10语句和随机10条的语法 --测试表数据-- select * from BdsPaperItem --查询测试表的前10条语句-- * from BdsPaperItem order by Uid asc --随机查询测试表10条语句-- * from BdsPaperItem order by NEWID() 结果实例:…
场景举例: 假如我们有某个班级的语文成绩数据,格式为字典,其中字典key为学生姓名,value为学生成绩: 那么,如何获得单科成绩排名前3的学生姓名? 代码如下:--数据样例,方便测试 def dic_order_value_and_get_key(dicts, count): # by hellojesson # 字典根据value排序,并且获取value排名前几的key # 样例: dicts = {'王二狗':66,'李大东':55,'刘小明':99, '胡八一':88} final_re…
很多时候,在调用接口时,需要对请求进行签名.需要用到unix时间戳. 在python里,在网上介绍的很多方法,得到的时间戳是10位.而java里默认是13位(milliseconds,毫秒级的). 下面介绍python获得时间戳的方法: 1.10位时间戳获取方法:强制转换是直接去掉小数位. import timea = time.time()print(a)print(int(a)) 1554949545.15074041554949545 2.13位时间戳获取方法: 默认情况下python的时…
--oracle取前十条数据 --(1)第一种 ; --(2)第二种 ;…
打印斐波拉契数列前n项 #encoding=utf-8 def fibs(num):    result =[0,1]    for i in range(num-2):        result.append(result[-2]+result[-1])    return resultprint fibs(10) 结果:…
场景: 有两个表,表可以是文本或Json数据,结构化后分别是Table1(A,B,C)和Table2(C.D.E),两个表通过C关联,要求求出D+E之和,并以(A.B.D+E)三列返回 解答: 思路:SparkSQL支持读取Json创建表,同时创建的表可以做联合查询,类似传统Sql语句进行关联查询和统计分析 代码: package study import org.apache.spark.SparkContext import org.apache.spark.sql.SparkSession…
1L.2L的分别用mid函数和left函数都没有问题. 问题是,如果用left函数,必须先确认,字符串中汉字必须排在左边第一个,接下来几个也必须是汉字:mid函数则是根据从左边第某个字符开始,一共取几个.因此,这个同样需要先确定汉字开始位置.如果无法确定汉字起始位置,但是有特别汉字的话,可以用search函数结合mid函数来处理.例如想找出以下字符串中城市名称:=MID(A1,SEARCH("市",A1,1)-2,3) 这里假定以上字符放在A1单元格. 没有一定规律的字符串是很难截取的…
直接&255 因为Integer.toBinaryString(255) 是 8个1. 如果一个负数byte转成int则前面全部会补1,就是24个1和它自己的八位,,于是和八个1相&就是八个1了. 举个例子,-1和255 11111111 11111111 11111111 11111111 &00000000 00000000 00000000 11111111 ———————————————————————— =00000000 00000000 00000000 111111…
SELECT ATA FROM LM_FAULT WHERE ( OCCUR_DATE BETWEEN to_date( '2017-05-01', 'yyyy-MM-DD' ) AND to_date( '2017-05-15', 'yyyy-MM-DD' ) ) ORDER BY ATA ASC ; 修改如下 不忘初心,如果您认为这篇文章有价值,认同作者的付出,可以微信二维码打赏任意金额给作者(微信号:382477247)哦,谢谢.…
题意: 项的自幂级数求和为 11 + 22 + 33 + - + 1010 = 10405071317. 求如下一千项的自幂级数求和的最后10位数字:11 + 22 + 33 + - + 10001000. 思路: 求最后十位数字 % 1010 即可. 对于快速幂中数据溢出的问题,有两种解决方法: 1. 方法一:对于两个数 x y,现在想求 x * y % MOD,可以将 x 表示成 a * DIGS + b,y 表示成 c * DIGS + d,x * y % MOD 则等价与 ( a * c…
第一次第一次用MarkDown来写博客,先试试效果吧! 昨天2018俄罗斯世界杯拉开了大幕,作为一个伪球迷,当然也得为世界杯做出一点贡献啦. 于是今天就编写了一个爬虫程序将腾讯新闻下世界杯专题的相关新闻和链接提取出来,同时也再复习一下 Python爬虫类库的使用. 爬取前相关库文件的安装 1.python安装,如果还没有安装可以去Python官网去下载安装相应的版本,这里我使用的是Python3.6.1. 2.requests库安装,使用cmd命令打开命令行,接着pip install requ…
今天看了篇文章,对oracle取前几条数据的方式和说明,总结比较全,学习了,做个记录点.oracle 取前10条记录 以下内容是原始文章内容,用于做留存阅读. 1.oracle 取前10条记录 1) select * from tbname where rownum < 11; 2) select * from (select * from tbname order by id desc ) where rownum<=10; 下面是关于rownum的介绍===================…
本题来自 Project Euler 第5题:https://projecteuler.net/problem=5 # Project Euler: Problem 5: Smallest multiple # 2520 is the smallest number that can be divided by # each of the numbers from 1 to 10 without any remainder. # What is the smallest positive num…
本题来自 Project Euler 第4题:https://projecteuler.net/problem=4 # Project Euler: Problem 4: Largest palindrome product # A palindromic number reads the same both ways. # The largest palindrome made from the product # of two 2-digit numbers is 9009 = 91 × 9…
开始做 Project Euler 的练习题.网站上总共有565题,真是个大题库啊! # Project Euler, Problem 1: Multiples of 3 and 5 # If we list all the natural numbers below 10 # that are multiples of 3 or 5, we get 3, 5, 6 and 9. # The sum of these multiples is 23. # Find the sum of all…
本题来自 Project Euler 第19题:https://projecteuler.net/problem=19 ''' How many Sundays fell on the first of the month during the twentieth century (1 Jan 1901 to 31 Dec 2000)? Answer: 171 ''' from datetime import * firstDay = date(1901,1,1) lastDay = date(…
本题来自 Project Euler 第16题:https://projecteuler.net/problem=16 ''' Project Euler 16: Power digit sum 2**15 = 32768 and the sum of its digits is 3 + 2 + 7 + 6 + 8 = 26. What is the sum of the digits of the number 2**1000? Answer: 1366 ''' print(sum(int(i…
本题来自 Project Euler 第11题:https://projecteuler.net/problem=11 # Project Euler: Problem 10: Largest product in a grid # In the 20×20 grid below, four numbers along a diagonal line have been marked in red. # The product of these numbers is 26 × 63 × 78 ×…
本题来自 Project Euler 第9题:https://projecteuler.net/problem=9 # Project Euler: Problem 9: Special Pythagorean triplet # A Pythagorean triplet is a set of three natural numbers, # a < b < c, for which, a**2 + b**2 = c**2 # For example, 3**2 + 4**2 = 9 +…
本题来自 Project Euler 第7题:https://projecteuler.net/problem=7 # Project Euler: Problem 7: 10001st prime # By listing the first six prime numbers: # 2, 3, 5, 7, 11, and 13, we can see that the 6th prime is 13. # What is the 10 001st prime number? # Answer…
本题来自 Project Euler 第22题:https://projecteuler.net/problem=22 ''' Project Euler: Problem 22: Names scores Using names.txt (right click and 'Save Link/Target As...'), a 46K text file containing over five-thousand first names, begin by sorting it into al…
本题来自 Project Euler 第21题:https://projecteuler.net/problem=21 ''' Project Euler: Problem 21: Amicable numbers Let d(n) be defined as the sum of proper divisors of n (numbers less than n which divide evenly into n). If d(a) = b and d(b) = a, where a ≠ b…
本题来自 Project Euler 第20题:https://projecteuler.net/problem=20 ''' Project Euler: Problem 20: Factorial digit sum n! means n × (n − 1) × ... × 3 × 2 × 1 For example, 10! = 10 × 9 × ... × 3 × 2 × 1 = 3628800, and the sum of the digits in the number 10! i…
本题来自 Project Euler 第17题:https://projecteuler.net/problem=17 ''' Project Euler 17: Number letter counts If the numbers 1 to 5 are written out in words: one, two, three, four, five, then there are 3 + 3 + 5 + 4 + 4 = 19 letters used in total. If all th…
本题来自 Project Euler 第15题:https://projecteuler.net/problem=15 ''' Project Euler: Problem 15: Lattice paths Starting in the top left corner of a 2×2 grid, and only being able to move to the right and down, there are exactly 6 routes to the bottom right…
本题来自 Project Euler 第14题:https://projecteuler.net/problem=14 ''' Project Euler: Problem 14: Longest Collatz sequence The following iterative sequence is defined for the set of positive integers: n → n/2 (n is even) n → 3n + 1 (n is odd) Using the rule…
本题来自 Project Euler 第12题:https://projecteuler.net/problem=12 # Project Euler: Problem 12: Highly divisible triangular number # The sequence of triangle numbers is generated by adding the natural numbers. # So the 7th triangle number would be 1 + 2 + 3…