AcWing 795. 前缀和 #include <bits/stdc++.h> using namespace std; const int N=1e6+10; int a[N],S[N]; int main(){ int n,m; scanf("%d%d",&n,&m); for(int i=1 ...
AcWing 796. 子矩阵的和 #include <bits/stdc++.h> using namespace std; const int N=1e3+10; int a[N][N],S[N][N]; int main(){ int n,m,q; scanf("%d%d%d",&n,&m,& ...
/* 给出一个不多于5位的正整数 要求:(1)求出它是几位数; (2)分别输出每一位数字 (3)按照逆序*/ #include <stdio.h> #include <string.h> int main(){ char str[50]; scanf("%s",str); int i=0,count ...
分类:
其他好文 时间:
2020-07-27 23:53:11
阅读次数:
96
Segmentation fault in Linux 段错误应该就是访问了不可访问的内存,这个内存要么是不存在的,要么是受系统保护的。 SIGSEGV是在访问内存时发生的错误,它属于内存管理的范畴 SIGSEGV是一个用户态的概念,是操作系统在用户态程序错误访问内存时所做出的处理 当用户态程序访问 ...
分类:
其他好文 时间:
2020-07-27 13:59:13
阅读次数:
71
题意: 给定一个序列ai,问序列中其他数中有多少个数是它的约数 思路: 暴力求法会超时。O(n²) 最优解:先储存每个数的个数,遍历x,每个x的倍数加上x的个数 注:最后每个数的答案要-1(减去本身) Code: #pragma GCC optimize(3) #pragma GCC optimiz ...
步骤: 1.首先要找到所有居民愿意花钱最多的 那个房子。 题目中用到lx,ly数组,是为了同时调节两个数组,使得权值和最大。 或者说当要松弛的时候使得 本来最大的矛盾权值和 尽可能的损失小一些来得到 满足条件的最大权值和! 2.(lx[x]+ly[y]-w[x][y]=0)条件下进行匈牙利算法。 # ...
分类:
其他好文 时间:
2020-07-27 09:27:42
阅读次数:
64
##题面 Problem Description There are n cities and m bidirectional roads in Byteland. These cities are labeled by 1,2,…,n, the brightness of the i-th cit ...
分类:
其他好文 时间:
2020-07-27 09:21:33
阅读次数:
88
//判断输入的数字是否可以构成一棵树 //前一个数是后一个的父亲节点,树的定义:有且仅有一个总根节点,根节点到其他任意节点路径唯一,每个节点只能被其根指向,入度只能为1 #include <stdio.h> #include <string.h> #define maxn 10002 int in[ ...
分类:
其他好文 时间:
2020-07-27 09:18:05
阅读次数:
68
题意:一个人有两个字符串A和B,两个字符串具有相同的长度n$(|A| = |B| = n)$,包含前20个小写字符('a'到't')。每一次操作,这个人可以选择A字符串中字符相同的字母,然后从中选择一些位置,并把这些位置的字母变大。求字符串A变到字符串B的最少操作次数。 分析:我们可以贪心地进行操作 ...
分类:
其他好文 时间:
2020-07-26 23:12:06
阅读次数:
78
#第一种做法(21分) #include <iostream> #include<stdio.h> #include<iomanip> int main() { int input,need; //input代表月饼种类 ,need代表市场需要吨数 scanf("%d %d",&input,&nee ...
分类:
其他好文 时间:
2020-07-24 22:06:42
阅读次数:
73