st

Codeforces 575A. Fibonotci 矩阵乘法+线段树

做~自己de王妃 提交于 2019-12-03 13:29:51
题解: 这道题……看完题就大概知道怎么做,但是考试时没有实现出来。 考试的时候想的是用倍增来实现,但是细节太多写不出来,正解是用线段树来维护连续n个矩阵的乘积,其实这个做法也挺显然的,但是没有把这两个东西放在一起用过。然后细节还是很多,调了一下午。 代码: #include<bits/stdc++.h> using namespace std ; #define LL long long #define pa pair<int,int> const int Maxn= 50010 ; const int inf= 2147483647 ; LL read() { LL x= 0 ,f= 1 ; char ch=getchar(); while (ch< '0' ||ch> '9' ){ if (ch== '-' )f=- 1 ;ch=getchar();} while (ch>= '0' &&ch<= '9' )x=(x<< 3 )+(x<< 1 )+(ch^ 48 ),ch=getchar(); return x*f; } struct Node{LL pos,bel; int v;}a[Maxn]; bool cmp(Node a,Node b){ return a.pos<b.pos;} LL K,belK; int P,n,m,s[Maxn],F[Maxn]; struct

Is return value of GetTimeZoneInformation also valid for dynamic DST zones?

匿名 (未验证) 提交于 2019-12-03 10:24:21
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 由 翻译 强力驱动 问题: Following function which I have written in Delphi (however, my question is not specific to Delphi) does output the current UTC unix timestamp: function CurrentUnixTimeUTC : int64 ; var tzi : TTimeZoneInformation ; begin // Get the current unix timestamp in local time. Result := DateTimeToUnix ( Now ); // First, add the DST specific bias case GetTimeZoneInformation ( tzi ) of TIME_ZONE_ID_INVALID : RaiseLastOSError ; TIME_ZONE_ID_UNKNOWN : ; // Unknown what to do. We simply don't apply any bias. TIME_ZONE_ID_STANDARD : Result :=

Restart Windows Service in c#

匿名 (未验证) 提交于 2019-12-03 09:06:55
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I got a link from SO Cannot restart a Service where it says to restart the windows service. The way it should restart the service is mentioned in the question as public static void RestartService(string serviceName, int timeoutMilliseconds) { ServiceController service = new ServiceController(serviceName); int millisec1 = Environment.TickCount; TimeSpan timeout = TimeSpan.FromMilliseconds(timeoutMilliseconds); if (!(service.Status.Equals(ServiceControllerStatus.Stopped) || service.Status.Equals(ServiceControllerStatus.StopPending))) { service

fill histogram based on date ranges

匿名 (未验证) 提交于 2019-12-03 09:06:55
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I want to fill a histogram different colors based on date ranges. In the example below, the entire histogram is orange. Let's say I want fill dates 2012-03-01 to 2012-04-28 a different color and keep the rest orange. library(ggplot2) library(lubridate) # random dates # https://stackoverflow.com/questions/14720983/efficiently-generate-a-random-sample-of-times-and-dates-between-two-dates randdate <- function(N, st="2012/01/01", et="2012/12/31") { st <- as.POSIXct(as.Date(st)) et <- as.POSIXct(as.Date(et)) dt <- as.numeric(difftime(et,st,unit=

boost regex sub-string match

匿名 (未验证) 提交于 2019-12-03 08:46:08
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I want to return output "match" if the pattern "regular" is a sub-string of variable st. Is this possible? int main() { string st = "some regular expressions are Regxyzr"; boost::regex ex("[Rr]egular"); if (boost::regex_match(st, ex)) { cout << "match" << endl; } else { cout << "not match" << endl; } } 回答1: The boost::regex_match only matches the whole string, you probably want boost::regex_search instead. 回答2: regex_search does what you want; regex_match is documented as determines whether a given regular expression matches all of a given

AcWing 803. 区间合并

别来无恙 提交于 2019-12-03 08:42:07
#include <iostream> #include <vector> #include <algorithm> using namespace std; typedef pair<int, int> PII; void merge(vector<PII> &segs) { vector<PII> res; sort(segs.begin(), segs.end());//pair排序会优先以左端点排序 int st = -2e9, ed = -2e9; for (auto seg : segs) if (ed < seg.first) { //没遇任何交集 ,说明找到了一个新的区间 if (st != -2e9) //首先不能是初始的区间 res.push_back({st, ed}); //那么就把他加到答案里去 st = seg.first, ed = seg.second; } else ed = max(ed, seg.second); //否则说明是有交集的,更新右端点 //看一下最后一个区间 ,把最后一个区间加到答案里去 if (st != -2e9) res.push_back({st, ed}); //判断主要是防止区间是空的 segs = res; } int main() { int n; scanf("%d", &n); vector<PII> segs

SQL Combine Two Columns in Select Statement

匿名 (未验证) 提交于 2019-12-03 08:36:05
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: If I have a column that is Address1 and Address2 in my database, how do I combine those columns so that I could perform operations on it only in my select statement, I will still leave them separate in the database. I would like to be able to do this WHERE completeaddress LIKE '%searchstring%' Where completedaddress is the combination of Address1 and Address2. searchstring would be like the data they searched for. So if they had '123 Center St' in Address1 and 'Apt 3B' in Address2, how would I have it select it if the searchstring was

ValueError: unconverted data remains: 02:05

匿名 (未验证) 提交于 2019-12-03 08:35:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I have some dates in a json files, and I am searching for those who corresponds to today's date : import os import time from datetime import datetime from pytz import timezone input_file = file(FILE, "r") j = json.loads(input_file.read().decode("utf-8-sig")) os.environ['TZ'] = 'CET' for item in j: lt = time.strftime('%A %d %B') st = item['start'] st = datetime.strptime(st, '%A %d %B') if st == lt : item['start'] = datetime.strptime(st,'%H:%M') I had an error like this : File "/home/--/--/--/app/route.py", line 35, in file.py st = datetime

jooq基本增删改查

人盡茶涼 提交于 2019-12-03 08:15:43
1.首先导包 import static org.jooq.impl.DSL. using ; 2. protected ConsumerCartDaoImpl (Configuration configuration) { super (ConsumerCart. CONSUMER_CART , ConsumerCartPojo. class, configuration) ; } @Override protected Long getId (ConsumerCartPojo consumerCartPojo) { return consumerCartPojo.getId() ; } 3.为要查询的表起别名 Shop _s = Shop. SHOP .as( "_s" ) ; ShopType _st = ShopType. SHOP_TYPE .as( "_st" ) ; 4.1基本查询 public ShopDetilVo findShopDetilByShopId ( long shopId) { //select s.*,st.typeName from shop s,shop_type st //where s.shopTypeId = st.id and shopId = ? return using (configuration()) .select( _s .

2、折半查找——查找算法

北城余情 提交于 2019-12-03 06:32:49
2019/11/02 2、折半查找 ( 折半查找效率比顺序查找效率高 ,但折半查找只适用于 有序表 ,且限于 有序结构 ) 要求: 1.线性表必须采用 顺序存储结构。 2.表中元素按关键字有序排列。 算法描述: [时间复杂度:O(log 2 n) ] int Search_Bin(SSTable ST, KeyTable key){ int low = 1,mid; int high = ST.length; while(low<=high){ mid = (low+high) / 2; if(key==ST.R[mid].key) return mid; //找到待查元素 else if(key<ST.R[mid].key) high=mid-1; //继续在前一子表进行查找 else low=mid+1;//继续在后一子表进行查找 } return 0; //表中不存在待查元素 } 折半查找递归算法: int Search_bin(SSTable ST, KeyType key, int low_in, int high_in){ int low = low_in; int high = high_in; int mid=mid = (low+high) / 2; while(low<=high){ if(key==ST.R[mid].key) return mid; /