摘要:
link # Write your MySQL query statement below select t3.product_id,p.product_name,year as report_year,amount as total_amount from ( select product_id, 阅读全文
摘要:
link class Solution { public: int racecar(int target) { vector<int> dp(target+1); for(int i=1;i<=target;i++){ dp[i]=INT_MAX; int j=1; int m=1; // 先向前走 阅读全文
摘要:
int main(){ int n; cin>>n; int bit=1; int res=0; while(true){ if(n/bit==0) break; int cur=n/bit%10; int high=n/bit/10; int low=n%bit; if(cur==0){ res+ 阅读全文
摘要:
link 解法: maxprime存一个数的最大质因数,primeMin[i] 一个数n的质因数存在i,以n结尾所分得的最小子数组数。 class Solution { public: static const int maxn=1000000; int maxprime[maxn+1]; int 阅读全文
摘要:
class Solution { public: vector<int> singleNumbers(vector<int>& nums) { int total=0; for(int i:nums) total^=i; int one=1; while((one&total)==0) one<<= 阅读全文
摘要:
link 1.dfs+memo: class Solution { public: int n; int maxJumps(vector<int>& arr, int d) { n=arr.size(); vector<int> memo(n,-1); int res=0; for(int i=0; 阅读全文
摘要:
link 1. Fenwick Tree: #include <iostream> #include <vector> #include <algorithm> #include <unordered_set> #include <cstring> #include <queue> #include 阅读全文
摘要:
link 解法: 只需要枚举质数能否整除n。提前筛除sqrt(n)以内的质数,然后到时候只需要枚举这些质数i能否整除n,若能整除,n=n/i;最后n必定是一个质数或是1。 #include <iostream> #include <vector> #include <algorithm> #incl 阅读全文
摘要:
link using deque: class Solution { public: int constrainedSubsetSum(vector<int>& nums, int k) { int n=nums.size(); int res=nums[0]; deque<int> dq; for 阅读全文
摘要:
link class Solution { public: int dir[4][2]={{1,0},{-1,0},{0,1},{0,-1}}; struct Point{ int x; int y; }; int dis[105][105]; int m,n; Point S,T; int mcn 阅读全文