原创 KMP算法(模板)

//S是要被匹配的串,s是用來匹配的串 //求出S串中有多少s //getnext() int cnt=0; next[0]=-1; for(int i=0;s[i];i++) { int k=next[i]; w

原创 2018 Multi-University Training Contest 1

1001:Maximum Multiple 從n中拆出x,y,z,並要求x,y,z能被n整除且xyz最大。推一下就能夠知道符合要求的時候就是能被三整除或者能被四整除時候,分爲n/3,n/3,n/3或者n/4,n/4,n/2。 #

原创 HDU 2089(數位DP)

題目地址:http://acm.hdu.edu.cn/showproblem.php?pid=2089 數位DP基礎(模版)題 #include<iostream> #include<algorithm> #include<cst

原创 Codeforces Round #287 (Div. 2)E. Breaking Good

E. Breaking Good time limit per test 2 seconds memory limit per test 256 megabytes input standard input

原创 Codeforces Round #287 (Div. 2)B. Amr and Pins

B. Amr and Pins time limit per test 1 second memory limit per test 256 megabytes input standard input o

原创 HDU 1698 Just a Hook

題目鏈接:http://acm.hdu.edu.cn/showproblem.php?pid=6315 線段樹區間更新模板題(還少了query)。。 #include<bits/stdc++.h> using namespace

原创 西安電子科技大學第16屆程序設計競賽網絡同步賽

比賽地址:https://www.nowcoder.com/acm/contest/107#question 牛客網貌似直接複製會變亂碼,真的毒瘤。 A:水題直接寫 #include<bits/stdc++.h> using namesp

原创 2018 Multi-University Training Contest 2

1004:Game 找幾個數找一下規律就行了,就能得出來先手必勝。不過據說有證明。。 #include<bits/stdc++.h> using namespace std; int main(){ int n;

原创 Codeforces Round #290 (Div. 2)A. Fox And Snake

A. Fox And Snake time limit per test 2 seconds memory limit per test 256 megabytes input standard input

原创 牛客網暑期ACM多校訓練營(第二場)

A:run 基礎DP,直接做就行了。DP時候求出來到哪個距離有幾種走法,然後求一下前綴和。輸出答案的時候減一下就行了。 #include<iostream> #include<algorithm> #include<cstrin

原创 第六屆福建省賽

A:題意是有n個手機和一個充電寶,問你最多能把幾個手機充滿電(100%)。直接排序嘛,然後一直減就行了。#include<iostream> #include<algorithm> using namespace std; int mai

原创 NOIP 攔截導彈

題目鏈接:https://www.luogu.org/problemnew/show/P1020 題意很簡潔,一共兩問。 第一問是求單個攔截系統最多能攔截多少個,根據題意即最長非上升子序列。 第二問有多少導彈攔截系統才能攔截

原创 Codeforces Round #479 (Div. 3)

題目鏈接:http://codeforces.com/contest/977 A:題意是對這個數進行k次操作,如果這個數能被10整除,就除以10,不能的話就減1。 #include<iostream> #include<algorithm

原创 rope

#include <ext/rope> //頭文件 using namespace __gnu_cxx; //調用命名空間 int a[1000]; rope<int> x; rope<int> x(a,a + n); rope<

原创 斯特林公式

斯特林公式是一條用來取n!的近似值的數學公式,也可用來求取n!的位數。 //在x進制下的位數 LL res = (LL)((log(2 * pi*n) / 2 + n*log(n) - n) / log(x));