自定义博客皮肤VIP专享

*博客头图:

格式为PNG、JPG,宽度*高度大于1920*100像素,不超过2MB,主视觉建议放在右侧,请参照线上博客头图

请上传大于1920*100像素的图片!

博客底图:

图片格式为PNG、JPG,不超过1MB,可上下左右平铺至整个背景

栏目图:

图片格式为PNG、JPG,图片宽度*高度为300*38像素,不超过0.5MB

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+

Linfanty的博客

ACM的路上 继续前行

  • 博客(37)
  • 收藏
  • 关注

原创 Educational Codeforces Round 129 (Rated for Div. 2) D. Required Length

Educational Codeforces Round 129 (Rated for Div. 2) D. Required Length

2022-05-25 16:05:06 165 1

原创 Educational Codeforces Round 122 C. Kill the Monster

i64 cm = (hm + d - 1) / d; i64 mc = (h + dm - 1) / dm; if (cm <= mc) { (怪物的血量 + 人的攻击力 - 1)/ 人的攻击力 <= (人的血量 + 怪物的攻击力 - 1) / 怪物的攻击力 std::cout << "YES\n"; return; } if 角色...

2022-02-04 15:44:51 718

原创 逆元求组合数

#pragma comment(linker, "/STACK:1024000000,1024000000")#include &lt;bits/stdc++.h&gt;using namespace std;typedef long long ll;const ll inf = 0x3f3f3f3f3f3f3f3f;#define show(a) cout&lt;&lt;#a&lt;&...

2018-04-15 13:39:44 377

原创 矩阵快速幂

首先把非线性递推式转换为线性递推式∵ (n+1)4 = n4 + 4n3 + 6n2 + 4n + n0∵ F(n+1) = F(n) + 2F(n-1) + (n+1)4∴ F(n+1) = F(n) + 2F(n-1) + n4 + 4n3 + 6n2 + 4n + n0然后我们看下下面的状态转移矩阵作者:徐森威链接:https://www.jianshu.com/p/25eba927d9d...

2018-04-15 13:37:46 243

原创 L2-001. 紧急救援 多条最短路 spfa/dijkstra

#pragma comment(linker, "/STACK:1024000000,1024000000")#include &lt;bits/stdc++.h&gt;using namespace std;typedef long long ll;const ll inf = 0x3f3f3f3f3f3f3f3f;#define show(a) cout&lt;&lt;#a&lt;&...

2018-02-25 22:35:04 542

原创 L1-039 古风排版

去年天梯赛印象最深的一道没写出来的题link:https://www.patest.cn/contests/gplt/L1-039#pragma comment(linker, "/STACK:1024000000,1024000000")#include &lt;bits/stdc++.h&gt;using namespace std;typedef long long ll;const...

2018-02-23 14:55:49 313

原创 L1-011 两个getline ASCII码在0~255之间

// 这题有点意思了 改来改去的 / 其实一点意思都没有#pragma comment(linker, "/STACK:1024000000,1024000000")#include &lt;bits/stdc++.h&gt;using namespace std;typedef long long ll;const ll inf = 0x3f3f3f3f3f3f3f3f;#defin...

2018-02-20 23:17:11 300

原创 L1-006连续因子

#pragma comment(linker, "/STACK:1024000000,1024000000")#include &lt;bits/stdc++.h&gt;using namespace std;typedef long long ll;const ll inf = 0x3f3f3f3f3f3f3f3f;#define show(a) cout&lt;&lt;#a&lt;&...

2018-02-20 17:17:03 435

原创 CF938C Constructing Tests

// 一个n*n的01矩阵,要求每个m*m的矩阵都至少要有一个0,求最大的1的数量. 现在给定1的数量,构造出一组n,m满足要求#pragma comment(linker, "/STACK:1024000000,1024000000")#include &lt;bits/stdc++.h&gt;using namespace std;typedef long long ll;const...

2018-02-18 20:08:50 742

原创 CF932C Permutation Cycle exgcd(Ax+By=N) +构造

Let g(i) be the minimum positive integer j such that f(i, j) = i. We can show such j always exists.For given N, A, B, find a permutation P of integers from 1 to N such that for 1 ≤ i ≤ N, g(i) equals ...

2018-02-17 17:46:49 714

原创 CF模板

#pragma comment(linker, "/STACK:1024000000,1024000000")#include &lt;bits/stdc++.h&gt;using namespace std;typedef long long ll;const ll inf = 0x3f3f3f3f3f3f3f3f;#define show(a) cout&lt;&lt;#a&lt;&...

2018-02-16 22:56:09 260

原创 CF916B Jamie and Binary Sequence 二进制转化问题 字典序用优先队列来维护

/**题意:构造出一个有k个数字的序列,k个数字乘积为n,要求构造出来的序列中最大值尽量小,同时字典序最大思路:先取出二进制的每一位,判断总个数是不是小于等于k,如果大于k则不能构成。通过观察可以发现,每一位的一个可以转换成下一位的两个,因为要使最大位尽可能小,所以如果这一位的所有的个数都可以转换成下一位那么就全部转换过去,如果不能就一个也不要转换,不然会导致字典序损失。然后从最小...

2018-02-16 22:14:59 271

原创 线段树模板

#define maxn 100005#define mid ((l+r)&gt;&gt;1)#define lson rt&lt;&lt;1, l, mid#define rson rt&lt;&lt;1|1, mid+1, r#define ll long longint len[maxn&lt;&lt;2], lazy[maxn&lt;&lt;2], sum[maxn&lt;&lt...

2018-02-15 22:20:21 526

原创 CF 934D 数学 推导多项式展开

给定两个数 p,k,求出一个多项式 f(x) 满足系数均小于 k 且为非负整数,且 f(x)=q(x)(x+k)+p,q(x) 也为一个多项式。 (1≤p≤1018,2≤k≤2000)将多项式 q(x) 展开:f(x)=(qnxn+..+q1x+q0)(x+k)+pf(x)=(kqn+qn−1)xn+..+(kq1+q0)x+(kq0+p) 将多项式 f(x) 展开:anxn+...+a1x+...

2018-02-15 17:08:42 479

原创 翻转的套路题 CF934C

subsequence 子序列 不连续  Input41 2 1 2Output4Input101 1 2 2 2 1 1 2 2 1Output9NoteIn the first example, after reversing [2, 3], the array will become [1, 1, 2, 2], where the length of the longest no...

2018-02-15 13:47:41 344

原创 Kruskal

#include#include#define MAXN 55using namespace std;int f[MAXN];int n,m,cnt;struct Edge{ int from,to,cost;}edge[MAXN * MAXN];int Find(int x){ return x == f[x]?x:f[x] = Find(f[x]);}

2018-02-05 20:54:57 170

原创 FFT模板

//http://codeforces.com/gym/100783/attachments/download/3773/20142015-acmicpc-southwestern-europe-regional-contest-swerc-14-en.pdf//给你n个数,然后再给你一个数k,问这个数是否就是那n个数中的一个,或//者说这个数可以由这n个数中的两个构成(可以是自己*2)//

2018-02-04 17:45:49 209

原创 并查集模板

// #include #include #include using namespace std;typedef long long ll;const int maxn = 1005;int pre[maxn];int find(int x) { return x == pre[x] ? x : pre[x] = find(pre[x]); }void join(in

2018-02-04 17:13:37 243

原创 Codeforces 919D 拓扑排序判环 + 树上 dfs + dp

/*题意:给你一个有向图, 一共有n个节点 , m条边,一条路上的价值为这个路上出现过的某个字符最多出现次数, 现求这个最大价值, 如果价值可以无限大就输出-1。题解:当这个有向图构成一个环的时候就会使得值无限大,所以先用拓扑排序判断一下有没有环,如果有环直接输出-1,如果没有环就再使用树形dp并记忆化存数,来找到最大值。拓扑排序判环+DAG上dp+记忆化搜索状态:dp[i][

2018-02-04 17:08:38 293

原创 Codeforces#459C 917A The Monster 左右括号匹配

#pragma comment(linker, "/STACK:1024000000,1024000000")#include &lt;bits/stdc++.h&gt;using namespace std;typedef long long ll;const int maxn = 1005;#define LOCALint main() { #ifdef LOCAL ...

2018-01-30 22:46:17 608

原创 CodeForces - 915C 字符串

input a b  output: a中经过排列后的最大的数 同时满足比b#include #define rep(i,n) for(int i=0;i<(n);i++)using namespace std;typedef long long ll;typedef pair pii;const int INF=1e9+7;string a,b;int main(){

2018-01-29 03:00:32 542

原创 codeforces484A 二进制 位运算

#include using namespace std;typedef long long ll;const int maxn = 1005;/**题目大意:给定区间l,r,找到一个数x,保证x在区间上,并且要求x的bitcount尽量大的前提下数值尽量小。解题思路:默认x为全1的二进制数,每次从最高为判断,首先我们把L和R拆成二进制数,然后个位对齐,形如下面这样:R:1

2018-01-28 01:30:50 627

原创 状态压缩 位运算

获得 n 的第 i 位的数据(0还是1),判断(n&(1设置 n 的第 i 位为1,n=(n |(1设置 n 的第 i 位为0,n=(n &(~(1设置 n 的第 i 位为0,n= n ^ (1ll 当n为long long 时 注意将1改为1ll 否则会错!!!

2018-01-28 00:41:03 738 2

原创 gym/100812E World of Knights struct vector< pair<ll,ll> > s;

#include typedef long long ll;typedef unsigned long long ull;#define IO ios_base::sync_with_stdio(0),cin.tie(0)using namespace std;#define rep(i,a,b) for(ll i = a; i<=b ;++i)#define per(i,a,b) f

2017-07-18 17:57:54 381

翻译 gym/101086J Smooth Developer DFS遍历各结点

#include #define INF 0x7fffffff#define maxn 1001000#define eps 1e-6#define pi acos(-1.0)#define e 2.718281828459#define mod (int)1e9 + 7;#define IO ios_base::sync_with_stdio(0),cin.tie(0)using

2017-07-14 13:52:09 306

原创 gym/101086 M Stairway to Heaven map set string、int对应 综合应用

#include#include #include typedef long long ll;typedef unsigned long long ull;#define IO ios_base::sync_with_stdio(0),cin.tie(0)using namespace std;#define rep(i,a,b) for(ll i = a; i<=b ;++i)#

2017-07-14 13:39:19 375

原创 #109D Colliders 素数筛 统计质数因子 data[j][ ++data[j][0] ] = prime[i];

#include#include #include #define inf 0x3f3f3f3f#define maxn 100010#define fin freopen("out.txt","r",stdin);#define fout freopen("outtest.txt","w",stdout);#define mem(a) memset(a,0,sizeof(a))#

2017-07-14 13:30:06 450

翻译 gym/101149/ Right Build 有向spfa

#include#include #include #define inf 0x3f3f3f3fconst int maxn = 2e5 + 5;#define fin freopen("out.txt","r",stdin);#define fout freopen("outtest.txt","w",stdout);#define mem(a) memset(a,false,s

2017-07-14 11:31:18 242

翻译 gym/101149/ Of Zorcs and Axes set<pair<int, int > > it->second; it = s.lower_bound( make_pair(u[

#include#include #include #define inf 0x3f3f3f3fconst int maxn = 2e5 + 5;#define fin freopen("out.txt","r",stdin);#define fout freopen("outtest.txt","w",stdout);#define mem(a) memset(a,false,s

2017-07-14 11:28:31 389

翻译 不要62 strstr(str,s)!=NULL sprintf(str,"%d",i) itoa(i,str,10)

杭州人称那些傻乎乎粘嗒嗒的人为62(音:laoer)。杭州交通管理局经常会扩充一些的士车牌照,新近出来一个好消息,以后上牌照,不再含有不吉利的数字了,这样一来,就可以消除个别的士司机和乘客的心理障碍,更安全地服务大众。不吉利的数字为所有含有4或62的号码。例如:62315 73418 88914都属于不吉利号码。但是,61152虽然含有6和2,但不是62连号,所以不属于不吉利数字之列。你

2017-02-15 15:23:52 890

转载 G - Tian Ji -- The Horse Racing

https://vjudge.net/contest/149236#problem/Ghttp://blog.csdn.net/lawrencesgj/article/details/8001638dovebs:动态规划http://blog.csdn.net/u012773338/article/details/29352841NowAndForever:sort(t

2017-02-03 23:34:10 379

翻译 寒假训练(2)——贪心 E - Wooden Sticks

There is a pile of n wooden sticks. The length and weight of each stick are known in advance. The sticks are to be processed by a woodworking machine in one by one fashion. It needs some time, called

2017-02-03 15:34:53 324

原创 数组开小了会TLE

用 double 不用 float

2017-02-01 03:52:01 644

原创 寒假训练(2)——贪心 D - Moving Tables

题目 https://vjudge.net/contest/149236#problem/D首先 scanf时就swap 排序 很方便 for(int j=0; j<N; j++){scanf("%d %d",&begin,&end);if(begin>end) swap(begin,end);for(int k=(begin+1)/2; k<=(end+1)/2;

2017-02-01 03:49:07 489

原创 两个元素的快排 NDU.i

#include#include#include#include#define maxn 26+5using namespace std;char str[maxn];int cnt[maxn];struct Node //struct Node { char name; int num;}node[maxn]; // node [maxn +5 ]

2017-01-07 14:09:20 321

翻译 枚举-生成元3.5Digit generator

#include#include#include#include#define maxn 100005#define mem(a,b) memset((a),(b),sizeof((a)))using namespace std;int main(){int T,n;int ans[maxn];mem(ans,0);for(int m=1;m<maxn;m++){

2017-01-07 14:03:16 241

翻译 环形字符串比较-环状序列3.6circular sequence

#include #include using namespace std; const int N = 150; char s[N], ans[N], c; int t, l; int main() { // scanf ("%d", &t); // while (t--) { scanf ("%s", s);

2017-01-07 14:00:41 1546

空空如也

空空如也

TA创建的收藏夹 TA关注的收藏夹

TA关注的人

提示
确定要删除当前文章?
取消 删除