acm
Forever_Young_L
这个作者很懒,什么都没留下…
展开
-
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 · 148 阅读 · 0 评论 -
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 · 126 阅读 · 0 评论 -
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 · 204 阅读 · 0 评论 -
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 · 245 阅读 · 0 评论 -
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 · 169 阅读 · 0 评论 -
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 · 223 阅读 · 0 评论 -
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 · 763 阅读 · 0 评论 -
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 · 259 阅读 · 0 评论 -
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 · 136 阅读 · 0 评论 -
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 · 177 阅读 · 0 评论 -
(扩展欧拉定理)
#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 · 198 阅读 · 0 评论 -
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 · 220 阅读 · 0 评论 -
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 · 119 阅读 · 0 评论 -
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 · 202 阅读 · 0 评论 -
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 · 229 阅读 · 0 评论 -
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 · 644 阅读 · 0 评论 -
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 · 1888 阅读 · 0 评论 -
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 · 118 阅读 · 0 评论 -
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 · 232 阅读 · 0 评论 -
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 · 165 阅读 · 0 评论 -
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 · 539 阅读 · 0 评论 -
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 · 250 阅读 · 0 评论 -
大视野3884: 上帝与集合的正确用法(欧拉函数||欧拉筛)
Description传送门根据一些书上的记载,上帝的一次失败的创世经历是这样的:第一天, 上帝创造了一个世界的基本元素,称做“元”。第二天, 上帝创造了一个新的元素,称作“α”。“α”被定义为“元”构成的集合。容易发现,一共有两种不同的“α”。第三天, 上帝又创造了一个新的元素,称作“β”。“β”被定义为“α”构成的集合。容易发现,一共有四种不同的“β”。第四天, 上帝创造了新的元素...原创 2019-07-28 23:33:50 · 99 阅读 · 0 评论 -
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 · 330 阅读 · 0 评论 -
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 · 169 阅读 · 0 评论 -
Radar Scanner(经典问题)
题目链接:http://codeforces.com/gym/102220/problem/GRadar ScannerThere are原创 2019-06-05 23:41:54 · 1101 阅读 · 0 评论