随笔分类 -  ACM模板

摘要:1 #include <iostream> 2 #include <vector> 3 #include <algorithm> 4 #include <string> 5 #include <cstdio> 6 using namespace std; 7 int a[100010]; 8 int 阅读全文
posted @ 2022-05-12 10:51 TTTCoder 阅读(78) 评论(0) 推荐(0)
摘要:1 #include <iostream> 2 #include <algorithm> 3 using namespace std; 4 5 void max_heapify(int arr[], int start, int end) { 6 // 建立父節點指標和子節點指標 7 int dad 阅读全文
posted @ 2020-12-12 15:22 TTTCoder 阅读(165) 评论(0) 推荐(0)
摘要:1 #include <iostream> 2 #include <vector> 3 #include <algorithm> 4 #include <string> 5 #include <cstdio> 6 using namespace std; 7 int a[100010]; 8 /* 9 void quick_sort(int *a,int left,int right){ 10 i 阅读全文
posted @ 2019-09-12 15:24 TTTCoder 阅读(250) 评论(0) 推荐(0)
摘要:#include #include #include #include using namespace std; const int maxn = 1e5 + 10; int n, m; int cnt; struct node{ int L, R;//分别指向左右子树 int sum;//该节点所管辖区间范围内数的个数 node(){ sum = 0; ... 阅读全文
posted @ 2018-10-13 21:22 TTTCoder 阅读(276) 评论(0) 推荐(0)
摘要:1 nth_element(a+1 , a + m, a + n+1); 2 nth_element(first , mth, end); 3 区间【first,end)以第m个数为分界线前面都小,后面都大 阅读全文
posted @ 2018-08-04 20:09 TTTCoder 阅读(185) 评论(0) 推荐(0)
摘要:1 #include 2 #include 3 #include 4 #include 5 #define LL long long 6 using namespace std; 7 const int N = 10;//矩阵大小 8 int mod; 9 int k;//矩阵的幂 10 int a[15]; 11 12 struct Matrix 13 { 14 ... 阅读全文
posted @ 2018-05-02 15:35 TTTCoder 阅读(208) 评论(0) 推荐(0)
摘要:#include #include #include #include #define LL long long using namespace std; typedef __int64 int64; const int N = 3; __int64 k , MOD = 1e9+7; int arr[50] ; struct Matrix{ int64 mat[N][N]; ... 阅读全文
posted @ 2018-04-18 17:42 TTTCoder 阅读(242) 评论(0) 推荐(0)
摘要:Fibonacci again and again 任何一个大学生对菲波那契数列(Fibonacci numbers)应该都不会陌生,它是这样定义的: F(1)=1; F(2)=2; F(n)=F(n-1)+F(n-2)(n>=3); 所以,1,2,3,5,8,13……就是菲波那契数列。 在HDOJ 阅读全文
posted @ 2018-01-31 23:48 TTTCoder 阅读(210) 评论(0) 推荐(0)
摘要:The branch of mathematics called number theory is about properties of numbers. One of the areas that has captured the interest of number theoreticians 阅读全文
posted @ 2018-01-25 12:13 TTTCoder 阅读(258) 评论(0) 推荐(0)
摘要:4009: Doges 题目描述 在一个遥远的地方,住着n只 Doge,它们分别被编号为1到n之间的正整数。 有一天,一个叫 Jrisme 的人来到这里,进行了一些「虐狗」行为。具体的,Jrisme 每次会虐编号连续的一些 Doge。现给出每次虐狗的区间,求最幸运(被虐次数最多)Doge 被虐了多少 阅读全文
posted @ 2017-10-31 21:53 TTTCoder 阅读(2017) 评论(0) 推荐(0)
摘要:int l; char a[1100]; int tmp[1100]; bool div(int k) { int j=0; int y=0; for(int i=0;i<l;i++) { int sum=a[i]+y*10; int x=sum/k; y=sum%k; ... 阅读全文
posted @ 2017-10-27 21:53 TTTCoder 阅读(272) 评论(0) 推荐(0)
摘要:KMP图解 阅读全文
posted @ 2017-10-14 18:00 TTTCoder 阅读(257) 评论(0) 推荐(0)
摘要:字典树模板 阅读全文
posted @ 2017-10-14 17:53 TTTCoder 阅读(258) 评论(0) 推荐(0)
摘要:1. 概述 RMQ(Range Minimum/Maximum Query),即区间最值查询,是指这样一个问题:对于长度为n的数列A,回答若干询问RMQ(A,i,j)(i,j<=n),返回数列A中下标在i,j之间的最小/大值。这两个问题是在实际应用中经常遇到的问题,下面介绍一下解决这两种问题的比较高 阅读全文
posted @ 2017-08-15 15:55 TTTCoder 阅读(275) 评论(0) 推荐(0)
摘要:1 #include 2 #include 3 #include 4 5 using namespace std; 6 7 int main() 8 { 9 string str; 10 cin >> str; 11 sort(str.begin(), str.end()); 12 cout 2 #include 3 #incl... 阅读全文
posted @ 2017-07-26 17:05 TTTCoder 阅读(288) 评论(0) 推荐(0)
摘要:1 #include 2 #include 3 #include 4 using namespace std; 5 int gcd(int a,int b) 6 { 7 return b==0?a:gcd(b,a%b); 8 } 9 int main() 10 { 11 int b,a; 12 while(~scanf("%d%d",&a,&b))... 阅读全文
posted @ 2017-05-30 22:53 TTTCoder 阅读(223) 评论(0) 推荐(0)
摘要:/* 2 |埃式筛法| 3 |快速筛选素数| |15-7-26| 4 */ #include <iostream> #include <cstdio> using namespace std; const int SIZE = 1e7; int prime[SIZE]; // 第i个素数 bool 阅读全文
posted @ 2017-04-16 20:39 TTTCoder 阅读(293) 评论(0) 推荐(0)