標籤:Least Common Ancestors節點範圍是1~1e18,至多1000次詢問。只要不斷讓深的節點退一層(>>1)就能到達LCA。用點來存邊權,用map儲存節點和父親連邊的權值。#include<cstdio>#include<map>#define ll long longusing namespace std;map<ll,ll>m;ll u,v,w;void add(){while(u!=v){if(u<v){m[v]+=
標籤:關於declspec的一點說明我遇到這個單詞總覺得記不住,時間一長就忘了。今天在複習dll的時候又遇到了這個單詞,我感覺應該是兩個單詞的縮寫,但又不敢確定,特地發帖網上求助,得到兩位高手的協助。下面是答案。The __declspec keyword must prefix the declaration specification簡單的可以理解為“聲明規範”。給出解答的可是位高手,CSDN積分排名第7名,獎章一大堆,呵呵,見著高手了。 原文轉自
標籤:final關鍵字的作用相信對於final的用法,大多數人都可以隨口說出三句話:1、被final修飾的類不可以被繼承2、被final修飾的方法不可以被重寫3、被final修飾的變數不可以被改變 1 public static void main(String[] args) { 2 final User u = new User("aaa"); 3 u.setName("bbb"); 4
標籤:F. New Year Snowflake As Gerald ..., in other words, on a New Year Eve Constantine prepared an unusual present for the Beautiful Lady. The present is the magic New Year snowflake that can make any dream come true.The New Year snowflake
標籤:題目網址:https://leetcode.com/problems/reverse-string/Write a function that takes a string as input and returns the string reversed.Example:Given s = "hello", return "olleh". 解法: C++:class Solution {public: string reverseString(string s)
標籤: 思路:排個序,依次選就好了。 #include <bits/stdc++.h>#define PB push_back#define MP make_pairusing namespace std;typedef long long LL;typedef pair<int,int> PII;#define PI acos((double)-1)#define E exp(double(1))#define K 1000+9int