ICode9

精准搜索请尝试: 精确搜索
  • [Editorial] Codeforces Contest 17262022-09-07 05:30:53

    A. Mainak and Array 显然如果 \([l,r]\) 不包括两端那么就不会对答案有影响,那么直接枚举包括两端的情况即可。 /* author : Gemini date : September 6th, 2022 url : https://codeforces.com/contests/1726/A */ #include<bits/stdc++.h> using namespace std; template<typena

  • 将字符串生成ZPL的Code128Auto编码2022-09-03 18:03:20

    internal string Code128AutoZPL(string planeText) { StringBuilder sb1 = new StringBuilder(); bool isDigit = GetDigitLength(planeText, 0) >= 2; for (int i = 0; i < planeText.Length; i++) { in

  • CF1110E Magic Stones2022-08-16 20:02:42

    题目链接: 洛谷 Codeforces Solution 以前做过这种题,比这题难得多,所以看到就秒了,加强版:[NOIP2021] 方差。 再来推一遍: 如果每次操作 \(a_i\),那么差分数组的变化为: \[d_i=a_i-a_{i-1}=a_{i-1}+a_{i+1}-a_i-a_{i-1}=a_{i+1}-a_i=d_{i+1}\\ d_{i+1}=a_{i+1}-a_i=a_{i+1}-a_{i-1}-a_{i+

  • 2022/8/15 总结2022-08-15 20:04:22

    题单贴贴 A.Begin 这是道结论题。但令人惊奇的是我完全没往这方面想用奇怪的策略做居然得到了 \(\mathtt{80pts}\); Solution 观察样例,再结合一点数学知识,我们可以知道当每一对 \(a\) 和 \(b\) 相差尽可能小的时候,答案有最小值。考虑排序,但 \(min\) 值与 \(max\) 值这一对产生

  • 舞蹈链板子2022-07-23 16:33:33

    #include<bits/stdc++.h> using namespace std; #define rg register inline int read(){ rg char ch=getchar(); rg int x=0,f=0; while(!isdigit(ch)) f|=(ch=='-'),ch=getchar(); while(isdigit(ch)) x=(x<<1)+(x<<3)+(ch^48),ch=getchar(

  • 7.22模拟赛2022-07-22 20:37:13

    目录7.22模拟赛甲国的军队 \((army)\)虚弱 \((weakness)\)萨鲁曼的半兽人 \((orc)\)序列 \((seq)\) 7.22模拟赛 甲国的军队 \((army)\) 简单的贪心,手玩一下就能得出结论 假设现在攻打两个城市 \(1\),\(2\) 先打 \(1\) 的代价为 \(b_1+b_2-(b_1-a_1)=a_1+b_2\) 先打 \(2\) 的代价为

  • 比较纯粹的分块线段树等 DS 趣题2022-07-16 22:38:05

    SP1043 GSS1 要你求一个区间的最大子段和。 那么,显然地,我们可以维护区间最大前缀和和后缀和。 即根据左区间后缀和加上右区间前缀和可以等于最大子段和这个性质。 那么如何维护最大前缀和和最大后缀和呢? 显然一段区间分成两块,最大前缀和有可能是左区间的最大前缀和,也有可能是左

  • CF1093G Multidimensional Queries2022-07-14 22:33:39

    \(\text{Code}\) 分析在 2022暑假集训 #include <cstdio> #include <iostream> #define IN inline using namespace std; const int N = 2e5 + 5, INF = 0x3f3f3f3f; int n, d, a[N][5]; IN void read(int &x) { x = 0; char ch = getchar(); int f = 1; for(

  • [USACO5.1]夜空繁星Starry Night2022-07-06 11:35:01

    原题链接 前言 蓝题祭。。。 题解 本题最大的难点就是判两个星系是否相似,根据数学知识,如果两个星系中的每个点之间的距离之和相等,则可以判断它们 \(similar\)。这样就简单了。 代码 \(1625B\),\(90\) 行。。。真的超长 Code: #include<bits/stdc++.h> using namespace std; void re

  • str.isdigit() 判断是否是数字Ture2022-05-20 23:35:00

    print("""欢迎登录100861.话费查询2.流量查询3.余额查询""")user=input("请输入数字:")#输入数字new_user=user.isdigit()#判断是否时数字if new_user:#如果是数字时,转换下面 user = int(user)#转换 print(user)else:#否则 print("输入错误,请重新输入")

  • Python之isdigit2022-04-24 13:34:56

    Python之isdigit python小工具实现猜数小游戏 #!/bin/python3 # -*- coding: utf-8 -*- while True: age=input('年龄:').strip() if age.isdigit(): age=int(age) if age > 18: print('猜大了') elif age < 18:

  • C-(字符分类函数)汇总2022-04-11 16:00:28

        #define _CRT_SECURE_NO_WARNINGS 1 #include<stdio.h> //#include<string.h> //#include<assert.h> //#include<errno.h> //strerror//把错误码转换为错误信息 //perror//打印错误信息 #include<ctype.h> int main() { char ch = '#';

  • 反悔贪心2022-03-30 11:01:13

    参考好文 就是说反悔贪心有两种,一种反悔堆是需要你手动去把之前的劣解换出来,一种反悔自动机是通过类似网络流反向边一样的办法让你的贪心自动实现反悔。 P2949 贪心的选取大的,如果插不进去就把时间在它前面并且价值在它后面的换出来。为了手动换需要按时间顺序选,同时维护一个小根

  • 字典,判断是否重复,2022-03-25 10:03:18

    asd=[ {'账号': '1231234567', '密码': 'qwer5678909'} ] #放到asd列表里 while True: qw = dict.fromkeys(["账号", "密码"]) zxc=input("账号:")#必须是数字, if zxc.isdigit() and len(zxc)<=11:

  • 带删除并查集 学习笔记2022-03-01 08:01:02

    注意:这里的删除指的是,将 \(u\) 移除集合但是其它点的关系都和移除前一样。 解法 给每个点设立一个虚点,作为他们的双亲节点。delet 的时候直接再新建一个虚点,将 \(u\) 的双亲节点设为 TA 就好了。 代码 #include<bits/stdc++.h> #define rep(i,x,y) for(int i=x;i<=y;++i) #define

  • c++快读快写2022-02-21 12:31:40

    文章目录 快读快写 快读 int read() { int s = 0, f = 1; char ch = getchar(); while(!isdigit(ch)) { if(ch == '-') f = -1; ch = getchar(); } while(isdigit(ch)) { s = s * 10 + ch - '0';

  • #贪心#CF605A Sorting Railway Cars2022-02-17 20:03:43

    题目 一个长度为 \(n\) 的排列,每次可以将一个数移至开头或者结尾,问最少多少次使其升序排列 分析 让数字连续的情况尽量多才能让移出来的次数尽量少, 找到最长的数字连续段,若其长度为 \(len\),那么答案为 \(n-len\) 代码 #include <cstdio> #include <cctype> using namespace std;

  • P2107 小Z的AK计划 题解2022-02-16 19:31:07

    题目传送门 分析 考虑一个贪心,由于 \(x_i\) 呈线性排列,我们一定要保证去到的机房越多越好,所以将 \(x\) 排序,每次前往最近的机房,如果可以 AK 则 AK,累加答案。 代码实现 我相信我的解法一定有漏洞,欢迎各位 dalao 来 hack。 #include <bits/stdc++.h> #define int long long using na

  • 1150: 数数多少个整数 C语言2021-12-02 10:02:06

    1150: 数数多少个整数 时间限制: 1 Sec 内存限制: 128 MB 提交: 7516 解决: 2853 [状态] [讨论版] [提交] [命题人:admin] 题目描述 小明的老师给小明出了一道题目:数数一篇文章出现了多少个数字,请你帮帮他吧。 输入 输入一个字符串,由空格、英文字母、数字组成,以回车结束,长度

  • #2-SAT,平面图#洛谷 3209 [HNOI2010] 平面图判定2021-11-18 19:35:10

    题目传送门 分析 首先一张图是平面图的必要条件为 \(m\leq 3*n-6\), 然后考虑到这题的图存在哈密尔顿回路,也就是说非环边因为跨立形成奇环即为无解 那么直接拆点跑2-SAT就可以了 代码 #include <cstdio> #include <cctype> #define rr register using namespace std; const int N

  • P2613 【模板】有理数取余2021-11-14 20:04:34

    看这个数据范围,就是天王老子来了他也存不下啊。 所以在读入的时候就要对之取余。 介绍一下快速读入: int的快速读入 全文背诵。 inline int getint() { int res=0,ch=getchar(); //ch用来过滤其他字符 while(!isdigit(ch)&&ch!=EOF) ch=getchar(); whi

  • 洛谷 P4753 River Jumping(贪心)2021-11-09 08:31:28

    传送门 解题思路 首先考虑无解的情况: 首尾距离 \(<s\) 第一个石头到 \(0\) 的距离 \(<s\) 或第二个石头到 \(n+1\) 的距离 \(<s\) 存在一个 \(a[i+1]-a[i-1]<s\) 判断完无解的情况,考虑构造答案。 最简单的方法是过去的时候跳1,3,5,7,9,……,m,m+1,回来的时候跳m-1,m-3,……,4,2,

  • P4626 一道水题 II2021-11-08 08:32:16

    Jisoo 大家都知道,对于两个数 \(a,b\)的\(lcm\),只要求去每个质数因数的较大的幂乘起来就行了。然后卡卡时 #include<cstdio> #include<iostream> #include<cstring> #include<iomanip> #include<cmath> #include<stack> #include<algorithm> #include<bitset>

  • CF476D Dreamoon and Sets2021-11-06 08:00:41

    Jisoo 观察样例,知道肯定和六有关系 并且\(gcd(a,b)=gcd(b,a-b)\) 就可以构造了 #include<cstdio> #include<iostream> #include<cstring> #include<iomanip> #include<cmath> #include<stack> #include<algorithm> using namespace std; template<

  • 6278. 数列分块入门 22021-11-05 13:04:48

    Jennie 分块,对于每一个块,排个序 就可以了 #include<cstdio> #include<iostream> #include<cstring> #include<iomanip> #include<cmath> #include<stack> #include<algorithm> #define int long long using namespace std; template<class T&

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

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

ICode9版权所有