数论基本糙作: gcd,快速幂,逆元,欧拉函数,分解因数balabala一通乱搞. POJ1845 Sumdiv (数论:算数基本定理+数论基本操作) 题目: Sumdiv Time Limit: 1000MS Memory Limit: 30000K Total Submissions: 29012 Accepted: 7127 Description Consider two natural numbers A and B. Let S be the sum of all natural d
从昨天开始刷题,但是昨天比较懒,没有总结一下.今天开始总结一下刷题什么的遇到的bug和之前不注意的事情. 顺时针旋转矩阵 有一个NxN整数矩阵,请编写一个算法,将矩阵顺时针旋转90度. 给定一个NxN的矩阵,和矩阵的阶数N,请返回旋转后的NxN矩阵,保证N小于等于300. 很简单的矩阵变换,我是通过两次矩阵变换得到的,首先对角线交换,然后左右翻转就可以了. class Rotate: def rotateMatrix(self, mat, n): c = [[0 for i in range(0
Given a binary tree containing digits from 0-9 only, each root-to-leaf path could represent a number. An example is the root-to-leaf path 1->2->3 which represents the number 123. Find the total sum of all root-to-leaf numbers. For example, 1 / 2 3 T
Given a string containing only digits, restore it by returning all possible valid IP address combinations. For example:Given "25525511135", return ["255.255.11.135", "255.255.111.35"]. (Order does not matter) 题解:深度优先搜索.用resul