ICode9

精准搜索请尝试: 精确搜索
  • 头文件2021-05-02 16:02:19

    其他代码中省略 #include <bits/stdc++.h> using namespace std; #define For(i,x,y) for(int i=x;i<=y;++i) #define mem(a,x) memset(a,x,sizeof a) #define PB push_back #define MP make_pair #define fi first #define se second typedef long long LL; typedef unsign

  • LCA — 欧拉序 + ST表2021-04-10 21:36:14

    LCA — 欧拉序+ST表 \(O(n\log n)\) 预处理,\(O(1)\) 询问​。 \(lca(x,y)=\) 欧拉序中最早出现的 \(x\) 和 \(y\) 中间深度最浅的点。 Luogu P3379 #include <bits/stdc++.h> using namespace std; const int N=500010; inline int read(){ int x=0;bool f=false;char ch=getchar

  • #Multi-SG#BZOJ 2940 [POI2000] 条纹2021-04-06 12:03:12

    题目 有\(n\)个格子,可以选择三种长度的线段覆盖,不能重叠, 无法覆盖者为负,问先手是否必胜,\(n\leq 10^3\) 分析 考虑选择一个位置覆盖则该局面分成两个局面, 直接求出SG函数不为0先手必胜即可 代码 #include <cstdio> #include <cctype> #define rr register using namespace std; i

  • #Multi-SG#HDU 5795 A Simple Nim2021-04-05 20:32:09

    题目 有\(n\)堆石子,每次可以从一堆中取出若干个或是将一堆分成三堆非空的石子, 取完最后一颗石子获胜,问先手是否必胜 分析 它的后继还包含了分成三堆非空石子的SG函数,找规律可以发现 \[SG[x]=\begin{cases}0,x=0\\x-1,x=8k(k\in N^*)\\x+1,x=8k+7(k\in N)\\x,otherwise\end{cases}

  • #SG函数#HDU 1848 Fibonacci again and again2021-04-05 20:03:22

    题目 分析 可取状态只能是斐波那契数,求出SG函数 然后判断三个数sg函数异或和不为0先手必胜 代码 #include <cstdio> #include <cctype> #define rr register using namespace std; const int p[15]={1,2,3,5,8,13,21,34,55,89,144,233,377,610,987}; const int N=1011; int sg[N

  • 每日codingame小游戏练习[2021.4.03](python入门学习)2021-04-04 20:31:47

    题目描述 无文字描述,看实例写代码。 Test 1: InputOutput1Hello World!0 Test 2: InputOutput21337 5p3k 15 c0015pr34d 7h3 w0rd!116 Test 3: InputOutput2abcd1234a1b2c3d444 Test 4: InputOutput2xxxxxxxxxx1111111111010 题目分析 题目很简单,先输入将要输入的行数,然后计算每

  • C. Crazy Diamond(思维+构造)2021-03-25 22:01:31

    https://codeforces.com/problemset/problem/1148/C 思路:发现1和n比较特殊,通过1和n作为中转站每次把数字在这里转。 <=n/2的要在左边的数字先和n换,再换到1. <=n/2的在右边的先和1换,再和n换,再和i换。 >=n/2+1同理 #include<iostream> #include<vector> #include<queue> #includ

  • python 关于 join()方法2021-03-08 19:05:38

    join() 方法 Python join() 方法用于将序列中的元素以指定的字符连接生成一个新的字符串。 join 语法 str.join(sequence) 实例 >>> x = "as323lfaj342l3g4" # 定义 x 字符串 >>> " ".join([i for i in x if i.isdigit()]) # 提取其中数字并在它们之间用空格隔开 以上代码执行

  • 线性筛素数2021-03-06 21:33:38

    Luogu P3383线性筛素数 #include<iostream> #include<cstdio> #include<cstdlib> #define maxn 100000010 using namespace std; template<typename T> inline void read(T &x){ x=0; bool flag=0; char c=getchar(); for(;!isdigit(c);c=get

  • #笛卡尔树#洛谷 3793 由乃救爷爷2021-03-05 20:02:33

    题目 询问区间最大值,所有数据随机生成 分析 建一棵笛卡尔树,实际上常数不大可过 代码 #include <cstdio> #include <cctype> #define rr register using namespace std; typedef unsigned uit; typedef unsigned long long ull; const int N=20000011; int n,m,a[N]; ull ans; in

  • CSP-J2019 加工零件2021-03-03 04:32:13

    2019 CSP 普及组的 T4,直接讲思路吧。 先假设每个点到点1只有唯一路径,那么我们有: 若 L<该路径长度 ,则对这个点的答案必定是"No"。 若 L>=该路径长度 且 奇偶性与该路径长度相同,则对这个点的答案为"Yes",否则为"No"。 令这个唯一路径为最短路,则我们只需要知道每个点到点1的奇最短路

  • 树状数组2021-02-14 23:04:15

    #include<iostream> #include<cstdio> #include<cstdlib> #define maxn 500010 using namespace std; template<typename T> inline void read(T &x){ x=0; bool flag=0; char c=getchar(); for(;!isdigit(c);c=getchar()) if(c=='-

  • P5985 [PA2019] Muzyka pop2021-02-07 20:33:37

    考虑有一棵包含了 \([0,m]\) 所有数的 \(01\ Trie\),有一种暴力 \(DP\):设 \(f(x,l,r)\) 表示将 \(a_l,a_{l+1}\dots a_r\) 分配给 \(Trie\) 树上 \(x\) 子树内的最大值。发现若 \(x\) 子树是满二叉树,则同一深度这样的 \(x\) 都是等价的,只有 \(m\) 所在的那一条链不是这样。因此状态

  • [转载] Python字符串isdecimal() isdigit()isnumeric()等判断方法的区分。2021-02-07 13:01:40

    参考链接: Python 字符串String | isidentifier 在Python中,字符串的操作是非常基础而且用途也极为广泛,学会字符串的操作,会让你节省许多不必花费的时间,下面简单介绍下Python中字符串is判断方法的区分。  首先要提一点,字符串的所有方法都有返回值,这些操作不会改变原有的字符串。 

  • 2021-02-032021-02-03 20:01:36

    题目 #include<iostream> using namespace std; namespace{ template<typename T> inline void read(T &s){ T f=1;s=0;char ch=getchar(); for(;!isdigit(ch);ch=getchar()) if(ch=='-') f=-1; for(;isdigit(ch);ch=getchar()) s=(s<<

  • 基数排序板子2021-02-01 19:04:42

    基数排序板子 noip好像t4还有20分是这个 另外,挑排(松排)是把基数U设为 \(2^8\) 卡进cache,需要卡常的话可以试试 #include<bits/stdc++.h> using namespace std; const int N = 1e5+200,U=65536,L=16; #define FOR(i,a,b) for(int i=a;i<=b;++i) #define ROF(i,a,b) for(int i=a;i>=b

  • Python isdigit()方法2021-01-30 12:04:57

    描述 Python isdigit() 方法检测字符串是否只由数字组成。 语法 isdigit()方法语法: 1 str.isdigit() 参数 无。 返回值 如果字符串只包含数字则返回 True 否则返回 False。 实例 以下实例展示了isdigit()方法的实例: 1 2 3 4 5 6 7 #!/usr/bin/pyt

  • [题解]CF1475F Unusual Matrix2021-01-26 20:35:54

    题目大意:给定一个 \(n*n\) 的 \(01\) 矩阵,每次操作可以选择一行或者一列,整体 \(xor\) \(1\) ,求经过无限多次操作,能否变为目标矩阵 我们发现,每一行或每一列至多被操作一次,且如果某一列或某一列的操作确定,整个矩阵的操作就确定 所以枚举第一列是否被操作,获得整个矩阵的操作方法,再带

  • [模板]ST表2020-12-30 16:35:20

       模板,不解释了. #include <algorithm> #include <cstdio> #include <cstring> #include <iostream> #include <cmath> using namespace std; int n, m, f[100010][20]; inline int read() { int x = 0, f = 1; char ch = getchar();

  • 1413 C语言合法标识符2020-12-20 16:32:11

    题目描述 输入一个字符串,判断其是否是C的合法标识符。 输入 输入一个长度不超过50的字符串。 输出 如果输入数据是C的合法标识符,则输出"yes",否则,输出“no”。 样例输入 8fixafghgjhjhjyuyuyyuyuyu 样例输出 no #include <stdio.h> #include <stdlib.h> #include <string.h> #

  • Java 密码验证2020-12-10 22:32:24

    public class PasswordValid { public static void main(String[] args) { String password = "fgdfaaA1"; System.out.println(valid4(password)); } //密码只能由大写字母,小写字母,数字构成 public static boolean valid1(String password

  • luoguP4310 绝世好题2020-12-04 13:35:33

    题面点这里 题面简述: 给定一个长度为 $ n $ 的数列 $ a_i $ ,求 $ a_i $ 的一个最长子序列 $ b_i $ (假设长度为 $ m $ ),满足 $ b_{i} $ & $ b_{i+1} ≠ 0 ( 1 \leq i < k ) $ 。 数据范围:$ 1 \leq n \leq 10^5 , 1 \leq a_i \leq 10^9 $ 。 题解: 有一个朴素的想法就是设 $ f_i $ 表

  • 1124考试总结2020-11-26 06:31:31

    1124考试总结 T1 ​ 题目大意 : ​ n 点 m 边无向图,每点度数至多为 3,边容量为 1,求任意两点间最大流之和。\(n <= 3000, m <= 4500\) ​ ​ Tarjan求边双 + 并查集 + 哈希. ​ 首先可以想到是不可以任选两个点然后跑一边网络流的, 那么我们发现每个点的度数很小, 我们可以考虑从度

  • 1113考试总结2020-11-14 06:31:29

    1113考试总结 T1 ​ 题目大意: ​ 随机生成一个特殊的 n 个节点的有向图,每个节点有且仅有一条出边,已知生成该图时,每个点的出边指向每个点(包括自己)的概率是相同的, 现在要你求出该有向图的 弱连通分量的期望个数。你只需要给出该期望值以 乘以 \(n ^ n\) 对 并对 \(998244353\) 取模

  • P3226 [HNOI2012]集合选数 状压DP2020-10-30 09:01:37

    题意: 题面 分析: 我们发现每个数 \(n\) 是否被选,只与 \(\frac{n}{3},\frac{n}{2},2n,3n\) 有关,那么我们考虑建一张表,表上每一行按照 \(\times 3\) 的方式递增,每一列按照 \(\times 2\) 的方式递增,那么对于同一张表,任意上下左右相邻的数都是不能选的,那么这样的表一共有 \(n-\frac{n}{

专注分享技术,共同学习,共同进步。侵权联系[81616952@qq.com]

Copyright (C)ICode9.com, All Rights Reserved.

ICode9版权所有