链接:Link 耗时:0.139s
前言
这道题的主要思路就是打表,看看Fibonacci数列模n几个一循环。但由于这题给的数太大了,从而在细节上耗了很久。在此记录一下:
var
x: qword;
y: longint;
begin
x := 1<<64-1;
y := 100;
x := x mod y; //报错201
x := x mod qword(y); //正确
end.
Code
var
a,b: qword;
_, n, i, k, cnt: longint;
f: array [1..1000000] of longint;
fun继续阅读 »
题目
先把题目放上:
链接:https://leetcode.com/problems/sort-colors
Given an array with n objects colored red, white or blue, sort them so that objects of the same color are adjacent, with the colors in the order red, white and blue.
Here, we will use the integers 0, 1, and 2 to represent the color red, white, and blue respec继续阅读 »
Question
Given an array of integers, return indices of the two numbers such that they add up to a specific target.
You may assume that each input would have exactly one solution.
Example:
Given nums = [2, 7, 11, 15], target = 9,
Because nums[0] + nums[1] = 2 + 7 = 9,
return [0, 1].
UPDATE (2016/2/13):
The return forma继续阅读 »