- 博客(44)
- 收藏
- 关注
原创 Codeforces Round #763 (Div. 2)——E. Middle Duplication
E. Middle Duplication1.先找到所有需要<重复>的节点;2.对树上的节点进行标记,上面部分为可以<重复>的节点,下面部分为不能<重复>的节点。#define _CRT_SECURE_NO_WARNINGS#include <iostream>#include<stdio.h>#include<math.h>#include<algorithm>#include<string.h>
2022-01-27 15:15:15
159
原创 UDP 计算校验和
1.数据来源2.实验结果checksum : 0110100100010010check the checksum : 11111111111111113.代码#include<iostream>#include<string>using namespace std;int n = 14, m = 16;string a[14] = {"1001100100010011","0000100001101000","1010101100000011","
2021-08-09 21:02:21
455
原创 ACM 模板
1. 树状数组[1, 2, 3… n]; 查询[l, r];int n;ll a[MAX_N + 1];ll bit[MAX_N + 1];ll query(int l, int r) { ll res = 0; while (r >= l) { res = gcd(res, a[r]); r--; while (r - (r & -r) >= l) { res = gcd(res, bit[r]); r -= r & -r; } }
2021-08-06 20:07:11
139
原创 Educational Codeforces Round 90 (Rated for Div. 2) E - Sum of Digits
题目链接:https://codeforces.com/contest/1373/problem/E枚举结果的后两位,从[0,100 - k),保证最后一个数不会对百位产生进位影响(至于为什么这样,打表观测后,猜测不会有进位到百位的情况);最后两位确定了,然后这k+1个数的其他位是相同的,用x9999…填充,x可以计算得出;比较取出最小的值即可;ac代码:#define _CRT_SECURE_NO_WARNINGS#include<iostream>#include<std
2020-06-28 16:56:06
215
原创 Codeforces Round #652 (Div. 2) A-D题
比赛链接:https://codeforces.com/contest/1369A.FashionabLee判断边数是否为4的倍数#include <iostream> using namespace std; int main(){ int T; cin>>T; while(T--){ int n; cin>>n; if(n%4==0)cout<<"YES"<<
2020-06-25 16:15:34
257
原创 哈工大LTP使用
# coding=utf-8from pyltp import SentenceSplitterfrom pyltp import Segmentorfrom pyltp import Postaggerfrom pyltp import NamedEntityRecognizerfrom pyltp import Parserfrom nltk import DependencyGr...
2020-05-06 20:22:13
596
原创 win10安装ubuntu16.04双系统、ubuntu16.04使用gparted重新调整分区大小
参考:https://blog.youkuaiyun.com/qq_41057206/article/details/80534194制作ubuntu启动盘(1)插入U盘。该U盘会被格式化,如果有重要内容需要提前备份(2)打开UltraSO软件,选择“文件”-“打开”打开之前下好的iso映像文件(3)选择“启动”-“写入硬盘映像”。此处注意选择正确硬盘驱动器。(4)依次点击“格式化”和“写入”,完成...
2020-05-05 18:21:14
978
原创 维基百科简体中文语料训练word2vec词向量
维基百科简体中文语料训练word2vec词向量步骤:1.下载维基百科中文语料2.使用工具从压缩包中抽取正文文本3.将繁体字转简体字4.分词5.训练模型6.测试模型1.下载维基百科中文语料语料下载地址:https://dumps.wikimedia.org/zhwiki/有不同时间段的下载地址,我们需要训练词向量,请选择包含articles.xml.bz2字段的链接(包含词...
2020-04-01 11:54:00
1928
1
原创 WikiExtractor.py(维基百科抽取器)
#!/usr/bin/env python# -*- coding: utf-8 -*-# =============================================================================# Version: 2.75 (March 4, 2017)# Author: Giuseppe Attardi (attardi@di....
2020-03-31 11:02:49
3795
2
原创 pycharm导包太慢解决方案
方案一:将pip的下载源更换为国内的镜像源即可参考:https://blog.youkuaiyun.com/qq_41648012/article/details/104109133方案二:pycharm设置本地解释器
2020-03-30 10:56:28
5334
原创 KMP模板
字符串匹配算法,时间复杂度为O(n+m)#include<bits/stdc++.h>using namespace std;typedef long long ll;const int INF=0x3f3f3f3f;const int MAX_N=100;const int M=1e9+7;char s[100005],p[100005];int net[100...
2020-03-20 22:45:09
142
原创 point
#include<bits/stdc++.h>using namespace std;typedef long long ll;const int INF=0x3f3f3f3f;const int MAX_N=100+5;const int MAX_M=200+5;const int M=25;struct node{ int b[M*3];};str...
2020-02-20 15:17:05
195
1
原创 GA求正态分布最值
#include<bits/stdc++.h>using namespace std;typedef long long ll;const int INF=0x3f3f3f3f;const int MAX_N=1000+5;const int PI=acos(-1.0);const int DNA_SIZE=20;int n;int pop[MAX_N],pop_...
2020-02-19 18:30:35
738
原创 lda c++代码
#include<bits/stdc++.h>using namespace std;typedef long long ll;const int INF=0x3f3f3f3f;const int MAX_M=1e4+5;const int MAX_K=30+5;const int MAX_N=1e6+5;struct node{ int id,k;//词...
2020-02-10 20:26:29
945
5
原创 C++生成正态分布样本、M-H采样
#include<bits/stdc++.h>using namespace std;typedef long long ll;typedef vector<double> vec;typedef vector<vec> mat;const int INF=0x3f3f3f3f;const int MAX_N=100;const double ...
2020-02-09 14:28:54
719
原创 C++矩阵相乘、矩阵快速幂
#include<bits/stdc++.h>using namespace std;typedef long long ll;typedef vector<double> vec;typedef vector<vec> mat;const int INF=0x3f3f3f3f;const int MAX_N=100;mat mul(mat...
2020-02-09 13:43:49
352
1
原创 plsa c++代码
#include<bits/stdc++.h>using namespace std;typedef long long ll;const int INF=0x3f3f3f3f;const int MAX_M=1e3+5;const int MAX_K=30+5;const int MAX_N=1e6+5;struct node{ int num; ...
2020-01-30 15:24:28
198
原创 lda Python代码
import chardetimport jiebaimport gensimS1 = []S2 = []with open('C:\\Users\\28612\\Desktop\\news_sohusite_xml.dat', 'rb') as f: lines = f.readlines() ans = 0 for line in lines: ...
2020-01-21 21:05:51
597
2
原创 POJ3662 Telephone Lines(二维最短路)
传送门DescriptionFarmer John wants to set up a telephone line at his farm. Unfortunately, the phone company is uncooperative, so he needs to pay for some of the cables required to connect his farm to t...
2019-09-10 11:07:23
232
原创 (扩展欧拉定理)
#include<bits/stdc++.h>using namespace std;typedef long long ll;const int INF=0x3f3f3f3f;const int MAX_N=300+5;const int MAX_M=506+5;ll a,b,m;ll mod_pow(ll x,ll n,ll mod,bool &t){...
2019-09-02 22:33:42
209
原创 2019牛客多校第七场E-Find the median(线段树+离散化区间)
传送门#include<bits/stdc++.h>using namespace std;#define fi first#define se secondtypedef long long ll;typedef pair<int,int> P;const int INF=0x3f3f3f3f;const int MAX_N=400000+5;con...
2019-08-09 15:23:52
181
原创 2019牛客多校第五场 F-maximum clique 1(匈牙利算法二分图匹配)
传送门#include<bits/stdc++.h>using namespace std; typedef long long ll; const int INF=0x3f3f3f3f;const int MAX_N=50000+5;const int MAX_V=50000+5;const int M=998244353; int n;int a[MAX_N...
2019-08-06 14:34:46
145
原创 2019杭电多校第四场 6621 K-th Closest Distance(主席树查询区间某个范围的个数)
Problem DescriptionYou have an array: a1, a2, , an and you must answer for some queries.For each query, you are given an interval [L, R] and two numbers p and K. Your goal is to find the Kth closes...
2019-08-03 11:37:31
125
原创 2019杭电多校第三场 6606-Distribution of books(树状数组)
Problem Description传送门zz6d likes reading very much, so he bought a lot of books. One day, zz6d brought n books to a classroom in school. The books of zz6d is so popular that K students in the classr...
2019-07-30 16:50:00
213
原创 2019杭电多校第三场 6608 Fansblog(威尔逊定理+miller_rabin素性测试)
Problem Description传送门Farmer John keeps a website called ‘FansBlog’ .Everyday , there are many people visited this blog.One day, he find the visits has reached P , which is a prime number.He thinks ...
2019-07-29 19:08:07
241
原创 Comet OJ - Contest #6双倍快乐(最小费用流)
#include <iostream>#include<stdio.h>#include<math.h>#include<algorithm>#include<string>#include<cstring>#include<queue>#include<map>#include<...
2019-07-29 17:52:30
175
原创 2019杭电多校第三场6611 K Subsequence(最小费用流)
Problem Description传送门Master QWsin is dating with Sindar. And now they are in a restaurant, the restaurant has n dishes in order. For each dish, it has a delicious value ai. However, they can only o...
2019-07-29 17:45:43
340
原创 大视野3884: 上帝与集合的正确用法(欧拉函数||欧拉筛)
Description传送门根据一些书上的记载,上帝的一次失败的创世经历是这样的:第一天, 上帝创造了一个世界的基本元素,称做“元”。第二天, 上帝创造了一个新的元素,称作“α”。“α”被定义为“元”构成的集合。容易发现,一共有两种不同的“α”。第三天, 上帝又创造了一个新的元素,称作“β”。“β”被定义为“α”构成的集合。容易发现,一共有四种不同的“β”。第四天, 上帝创造了新的元素...
2019-07-28 23:33:50
108
原创 2019牛客多校第三场F-Planting Trees(单调队列)
#include<bits/stdc++.h>using namespace std;const int MAX_N=500+5;int n,m;int a[MAX_N+1][MAX_N+1];int b1[MAX_N+1],b2[MAX_N+1];int q1[MAX_N+1],q2[MAX_N+1];void solve(){ int res=0; ...
2019-07-28 19:18:05
281
原创 2019牛客多校第四场J-free(二维最短路)
题目描述Your are given an undirect connected graph.Every edge has a cost to pass.You should choose a path from S to T and you need to pay for all the edges in your path. However, you can choose at most k...
2019-07-28 15:26:56
773
原创 poj2429 GCD & LCM Inverse(pollard_rho大整数分解)
DescriptionGiven two positive integers a and b, we can easily calculate the greatest common divisor (GCD) and the least common multiple (LCM) of a and b. But what about the inverse? That is: given GC...
2019-07-28 13:47:52
239
原创 2019杭电多校第二场hdu6601-Keen On Everything But Triangle(主席树)
Problem DescriptionN sticks are arranged in a row, and their lengths are a1,a2,…,aN.There are Q querys. For i-th of them, you can only use sticks between li-th to ri-th. Please output the maximum ci...
2019-07-28 10:19:56
181
原创 H-小阳的贝壳(差分数组+线段数||树状数组)
题目描述小阳手中一共有 n 个贝壳,每个贝壳都有颜色,且初始第 i 个贝壳的颜色为 coli。现在小阳有 3 种操作:1 l r x:给 [l,r] 区间里所有贝壳的颜色值加上 x 。2 l r:询问 [l,r] 区间里所有相邻贝壳 颜色值的差(取绝对值) 的最大值(若 l=r 输出 0)。3 l r :询问 [l,r]区间里所有贝壳颜色值的最大公约数。输入描述:第一行输入两个正整数 ...
2019-07-18 22:25:05
259
原创 AOJ2170 Marked Ancestor(并查集+离线)
ProblemYou are given a tree T that consists of N nodes. Each node is numbered from 1 to N, and node 1 is always the root node of T. Consider the following two operations on T:M v: (Mark) Mark node ...
2019-07-10 08:58:56
182
原创 poj2010 Moo University - Financial Aid(优先级队列)
DescriptionBessie noted that although humans have many universities they can attend, cows have none. To remedy this problem, she and her fellow cows formed a new university called The University of W...
2019-07-09 10:04:08
246
原创 poj2184 Cow Exhibition(01背包问题)
Description“Fat and docile, big and dumb, they look so stupid, they aren’t muchfun…”-Cows with Guns by Dana LyonsThe cows want to prove to the public that they are both smart and fun. In order to ...
2019-07-08 16:22:12
126
原创 Skyscraper(树状数组的应用)
题目链接:http://codeforces.com/gym/102220/problem/HAt the main street of Byteland, there will be built n skyscrapers, standing sequentially one next to other. If look leftside right, sequence of their he...
2019-07-06 17:26:43
560
原创 Minimum Spanning Tree
题目链接:http://codeforces.com/gym/102220/problem/EMinimum Spanning TreeIn the mathematical discipline of graph theory, the line graph of a simple undirected weighted graph G is another simple undirecte...
2019-06-07 13:16:51
674
原创 Radar Scanner(经典问题)
题目链接:http://codeforces.com/gym/102220/problem/GRadar ScannerThere are
2019-06-05 23:41:54
1114
原创 Balanced Diet(前缀数组)
题目:Taylor is wandering in a milk candy store. The store has m types of sweets and there are n sweets in the store. The i-th sweet has the value of ai, and it is of type bi.Taylor is planning to buy ...
2019-06-02 16:13:36
1905
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人