acm每一步
pig2687
这个作者很懒,什么都没留下…
展开
-
PAT (Advanced Level) Practice 甲级 顶级题目
PTA顶级甲级乙级原创 2022-03-30 13:00:46 · 629 阅读 · 0 评论 -
Prime Independence质数
将质数利用二分图求解最大独立集A set of integers is called prime independent if none of its member is a prime multiple of another member. An integer a is said to be a prime multiple of b if,a = b x k (where k is a prime [1])So, 6 is a prime multiple of 2, but 8 is not.原创 2022-01-28 10:16:56 · 517 阅读 · 0 评论 -
“图灵杯”
图灵杯F题-第二大数双指针模拟更新一遍区间范围内的ansconst int N = 1e4 + 10;#define int long longint a[N];signed main(){ int n; scanf("%d", &n); for (int i = 0; i < n; i++) cin >> a[i]; int sum = 0; for(int i = 0;i&l原创 2022-01-17 10:24:51 · 325 阅读 · 0 评论 -
第十六届 商汤杯
Problem E. 最后的轻语输入文件: standard input输出文件: standard output时间限制: 1 second空间限制: 2048 megabytes小钾在背单词。在本题中,我们认为单词是仅由小写字母构成的字符串。在背完一个单词 s 后,小钾尝试将这个单词拼写出来。由于记忆不牢,小钾可能会忘记要拼写的下一个字母是什么,这时他会选择从头开始拼写这个单词。如果小钾成功拼写出了完整的 s,这时为了加深记忆,他也会选择从头开始拼写这个单词。小钾可以任意次尝试拼写 s,并原创 2022-01-16 09:59:54 · 583 阅读 · 0 评论 -
Nearest Beautiful Number
F1.F2. Nearest Beautiful Number #739 (Div. 3)F2. Nearest Beautiful Number time limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputIt is a complicated version of problem F1. The difference between them is t原创 2021-09-29 16:15:35 · 95 阅读 · 0 评论 -
Polycarp and String Transformation(字符串)
E. Polycarp and String Transformation#739 (Div. 3)E. Polycarp and String TransformationPolycarp has a string s. Polycarp performs the following actions until the string s is empty (t is initially an empty string):he adds to the right to the string t the原创 2021-09-28 10:40:41 · 246 阅读 · 0 评论 -
D. Make a Power of Two
D. Make a Power of Two #739 (Div. 3)D. Make a Power of TwoYou are given an integer n. In 1 move, you can do one of the following actions:erase any digit of the number (it’s acceptable that the number before the operation has exactly one digit and after原创 2021-09-27 19:58:50 · 158 阅读 · 0 评论 -
Book(拓扑排序,dp,优先队列)
C. BookYou are given a book with n chapters.Each chapter has a specified list of other chapters that need to be understood in order to understand this chapter. To understand a chapter, you must read it after you understand every chapter on its required l原创 2021-09-26 21:00:49 · 304 阅读 · 0 评论 -
Consecutive Sum(字典树求异或和)
Consecutive SumLittle Jimmy is learning how to add integers. As in decimal the digits are 0 to 9, it makes a bit hard for him to understand the summation of all pair of digits. Since addition of numbers requires the knowledge of adding digits. So, his mot原创 2021-09-24 20:46:09 · 153 阅读 · 0 评论 -
Anagram Groups(字典树)
Anagram GroupsWorld-renowned Prof. A. N. Agram’s current research deals with large anagram groups. He has just found a new application for his theory on the distribution of characters in English language texts. Given such a text, you are to find the large原创 2021-09-24 19:27:23 · 553 阅读 · 0 评论 -
B - Longest Prefix
B - Longest Prefix很水的一道题,结果自己没有读懂题,就是求a和b的最大可能前缀,b可以随意更改字母位置#include<bits/stdc++.h>using namespace std;const int N = 1e5+10;char a[N],b[N]; //两个字符vector<int>num; //存放b中的每个字母数量typedef long long LL;int main(){ std::ios::sync_wi原创 2021-06-09 11:40:52 · 50 阅读 · 0 评论 -
图的基本存储的基本方式四
图的基本存储的基本方式四Description解决图论问题,首先就要思考用什么样的方式存储图。但是小鑫却怎么也弄不明白如何存图才能有利于解决问题。你能帮他解决这个问题么?Input多组输入,到文件结尾。每一组第一行有一个数n表示n个点。接下来给出一个n*n的矩阵 表示一个由邻接矩阵方式存的图。矩阵a中的元素aij如果为0表示i不可直接到j,1表示可直接到达。之后有一个正整数q,表示询问次数。接下来q行每行有一个询问,输入两个数为a,b。注意:点的编号为0~n-1,2<=n<=5原创 2021-06-06 19:31:33 · 69 阅读 · 0 评论 -
前缀和和差分
今天搞了搞前缀和和差分的操作,感觉还是很棒的,这个唯一的不足就是不可以修改前缀和:一维前缀和int a[N];int tr[N];void insert(int i,int t){ tr[i]=tr[i-1]+t;}int main(){ int n,m; cin>>n>>m; for(int i=1; i<=n; i++) cin>>a[i]; for(int i=1; i<=n; i原创 2021-06-03 21:33:50 · 36 阅读 · 0 评论 -
树状数组板子
今天写一下树状数组的板子其实这就是一种可以区间修改和计算数字大小的操作#include<bits/stdc++.h>using namespace std;int a[110000];int tr[110000];int n;int lowbit(int x){ return x&-x;} //lowbit函数就是求最后有几个0void add(int x,int t){ for(int i=x; i<=n; i+=lowbit(i))原创 2021-06-02 22:08:58 · 44 阅读 · 0 评论 -
求循环节Power Strings
Power StringsDescriptionGiven two strings a and b we define ab to be their concatenation. For example, if a = “abc” and b = “def” then ab = “abcdef”. If we think of concatenation as multiplication, exponentiation by a non-negative integer is defined in t原创 2021-05-31 18:45:26 · 79 阅读 · 0 评论 -
bLue的文件查找器
bLue的文件查找器DescriptionbLue 的电脑里存了各种各样的文件,随着文件越来越多,查找文件也成了一个麻烦事。现在,他想要查找所有指定格式(扩展名)的文件,不过他并不会使用文件管理器自带的搜索功能,所以他想求你写一个文件查找器,来帮他查找所有指定格式的文件。Input输入数据有多组(数据组数不超过 100),到 EOF 结束。对于每组数据:第一行输入一个整数 n (1 <= n <= 100) 和一个长度不超过 5 的字符串 ex,分别表示文件夹内的文件数量和要查找的原创 2021-05-31 16:44:26 · 97 阅读 · 0 评论 -
最大子段和之分治递归法
最大子段和之分治递归法Description给定n(1<=n<=50000)个整数(可能为负数)组成的序列a[1],a[2],a[3],…,a[n],求该序列如a[i]+a[i+1]+…+a[j]的子段和的最大值。当所给的整数均为负数时定义子段和为0,依此定义,所求的最优值为: Max{0,a[i]+a[i+1]+…+a[j]},1<=i<=j<=n。 例如,当(a[1],a[2],a[3],a[4],a[5],a[6])=(-2,11,-4,13,-5,-2)时,最大子段原创 2021-05-29 09:59:26 · 330 阅读 · 0 评论 -
计算n因数个数
最近好多人都在搞模板,跟风一下long long qiu(long long n){ long long res=0; long long t=sqrt(double(n)); for(long long i=1; i<=t; i++) res+=(n/i); return 2*res-t*t;}算是比较完整的一个求和公式题目传送口1题目传送口2都是类似题目,求因数个数和思想就是,先对于n==1,2,4,16这种sqrt(n)特殊的情原创 2021-05-23 10:11:17 · 371 阅读 · 0 评论 -
希尔排序
数据结构实验之排序六:希尔排序Description我们已经学习了各种排序方法,知道在不同的情况下要选择不同的排序算法,以期达到最好的排序效率;对于待排序数据来说,若数据基本有序且记录较少时, 直接插入排序的效率是非常好的,希尔排序就是针对一组基本有序的少量数据记录进行排序的高效算法。你的任务是对于给定的数据进行希尔排序,其中增量dk=n/(2^k)(k=1,2,3……)Input连续输入多组数据,每组输入数据的第一行给出一个正整数N(N <= 10000),随后连续给出N个整数表示待排序关键原创 2021-05-12 21:05:19 · 52 阅读 · 0 评论 -
BFS
bfs今天终于知道什么叫bfs了,太不容易了,感受很多,感觉有很多不一样int jx[] = {0, 1, 0, -1};int jy[] = {1, 0, -1, 0};//作为下一步可以走的改变char a[3333][3333];//每一步是否可以走,到达struct node { int x, y, step;} p[100000], t, f;//申请一个结构体存放步数和bool vis[3333][3333];//是否之前曾经遍历过int n, m;void bfs(i原创 2021-03-31 19:44:58 · 65 阅读 · 0 评论 -
v分
#include#include#include#includeint tree[20];int n,m;int lowbit(int x){return x&(-x);}void add(int k,int val){while(k<=n){tree[k]+=val;k+=lowbit(k);}}void add(int k,int val){while(k<=n){tree[k]+=val;k=k+lowbit(k);}}int原创 2021-03-26 21:24:51 · 281 阅读 · 0 评论 -
原码反码补码
今天听学长讲了一下树的问题发现和原码反码和补码还是关系很大的原码:原码其实比较好理解,其第一位是符号位,后面的数字正负数是一样的例如:+1:0001-1:1001反码:正数的反码和原码一样,负数的反码就是将原码除符号位以外取反例如:+1:0001-1:1110补码:正数的补码就是本身,负数的补码就是将原码除符号位以外取反+1(即将其反码+1)例如:+1:0001-1:1111希望记住了,这在使用 lowbit时候是非常重要的...原创 2021-03-26 20:08:48 · 224 阅读 · 0 评论 -
四舍五入方法
四舍五入方法总结方法一:例子:如果要保留3位小数,可以先将原来小数乘1000再+0.5再除以1000.0#include<stdio.h>int main(){ double a; scanf("%lf",&a); a=(int)(a*1000+0.5)/1000.0; printf("%.3f",a);}要注意此法在除回原数时要加上一位小数,不然会整除至整数。导致只能输出整数部分。方法二:math.h存在一个round函数可以四舍五入原创 2021-03-17 17:51:08 · 646 阅读 · 0 评论 -
zognjie
今天通过做题,感受颇多,自己对知识的掌握基本没有,水平很低,连按位运算的符号都不知道啥意思,还是很打击人的,但是这是没有办法的,自己必须通过自己的努力去改变自己,争取早日和别人一个起跑线。按位运算一:&按位与作为题目中出现来说,其含义为将数字转化为二进制以后,如果两个数字在该位置上都是1,即为1。即5&7=0101&0111=0101=5;负数的按位与按照其补码的形式进行操作还是比较好理解的,但具体是什么意思如何使用自己还是不明白,这是自己很难受的一个地方。按位运算二:|原创 2021-03-20 20:17:08 · 68 阅读 · 0 评论 -
尺取法
最近自己没事干刷了一道题目,据说使用了一种名字叫做尺取法的方法自己思考过后感觉它的思想较为简单于是将它记录下来题目给出了N个正整数(10 <N <100 000)的序列,每个正整数均小于或等于10000,并给出了一个正整数S(S <100 000 000)。 编写程序以查找序列中连续元素的子序列的最小长度,其总和大于或等于S。输入第一行是测试用例的数量。 对于每个测试用例,程序必须从第一行读取数字N和S,并以一个间隔将其分隔开。 序列号在测试用例的第二行中给出,以间隔分隔。 输入原创 2021-03-19 21:03:12 · 189 阅读 · 0 评论 -
快速乘与快速幂
今天本来打算整理学长昨天讲的问题,结果下午…不多说了,快上正经事知识点一:快速幂在介绍快速幂之前我们先引进一个取模方法例题:求A^B的最后三位数表示的整数。 说明:A^B的含义是“A的B次方”对此问题我们不难直接进行for循环将A累乘B次,但当A与B足够大时,我们也会发现它会爆数,因此#define LL long longLL fun2(LL a,LL b){ LL sum; for(int i=0;i<b;i++) { sum=sum*a;原创 2021-03-19 19:15:37 · 89 阅读 · 0 评论 -
J - Smallest Difference
J - Smallest DifferenceYou are given an array a consists of n elements, find the maximum number of elements you can select from the array such that the absolute difference between any two of the chosen elements is ≤ 1.InputThe first line contains an in原创 2021-03-17 21:20:52 · 60 阅读 · 0 评论 -
J - Smallest Difference
J - Smallest DifferenceYou are given an array a consists of n elements, find the maximum number of elements you can select from the array such that the absolute difference between any two of the chosen elements is ≤ 1.InputThe first line contains an in原创 2021-03-23 10:19:54 · 77 阅读 · 0 评论