
acm
acm
Cot287
这个作者很懒,什么都没留下…
展开
-
萌新训练赛(1)
萌新训练赛(1)原创 2022-08-27 22:27:38 · 734 阅读 · 0 评论 -
牛客练习赛101
个人自用原创 2022-07-19 22:00:15 · 187 阅读 · 1 评论 -
P1048 [NOIP2005 普及组] 采药
今天开始记录题解哈哈哈#include<bits/stdc++.h>using namespace std;struct object{ int time; int value;};vector<object> bag;int dp[110][1001];//i 物品 j 时间int main(){ int t,n; cin>>t>>n; for(int i=0;i<n;i++){ ...原创 2022-03-30 21:28:27 · 128 阅读 · 0 评论 -
P1046 [NOIP2005 普及组] 陶陶摘苹果
#include<bits/stdc++.h>#define ll long longusing namespace std;struct ans{ int head; int teil;};int main(){#ifdef LOCAL freopen("data.in","r",stdin); freopen("data.out","w",stdout);#endif // LOCAL int apple[10]; for(int i=0;.原创 2022-04-01 13:05:39 · 161 阅读 · 0 评论 -
P5656 【模板】二元一次不定方程 (exgcd)
先给出代码再说细节吧#include<bits/stdc++.h>using namespace std;#define ll long long#define LOCALll exgcd(ll a,ll b,ll &x,ll &y){//ax+by=gcd(a,b) if(b==0){ x=1;y=0; return a; } //x1=y2 y1=x1-(a/b)*y2 ll d=exgcd(.原创 2022-04-02 23:22:35 · 452 阅读 · 0 评论 -
P1720 月落乌啼算钱(斐波那契数列)
#include<bits/stdc++.h>#define ll long longusing namespace std;ll f[50]={0,1,1,2,3,5};//fibonacciint main(){ int n; cin>>n; if(n<=5)printf("%.2lf",(double)f[n]); else { for(int i=6;i<=n;i++) f[i]=f.原创 2022-03-31 20:41:53 · 104 阅读 · 0 评论 -
[洛谷]CF1660B Vlad and Candies
#include<bits/stdc++.h>#define ll long longusing namespace std;int main(){#ifdef LOCAL freopen("data.in","r",stdin); freopen("data.out","w",stdout);#endif // LOCAL int T; scanf("%d",&T); for(int t=0;t<T;t++){ int n;.原创 2022-04-01 21:28:22 · 693 阅读 · 2 评论 -
SP27561 GDCOFTI - Greatest Common Divisor Of Three Integers
#include<bits/stdc++.h>using namespace std;#define ll long long//#define LOCALint main(){#ifdef LOCAL freopen("data.in","r",stdin); freopen("data.out","w",stdout);#endif // LOCAL ll a,b,c; cin>>a>>b>>c; co.原创 2022-04-02 11:21:36 · 777 阅读 · 0 评论 -
数学专题——整数分解与筛法
分析首先分析题目,经过时间t,青蛙A可以走x+mt,青蛙B可以走y+nt,那么两只青蛙要想相遇,有x+mt=y+nt+kL,也就是说(m-n)t=y-x+kL.下面记n-m=v x-y=s,即s=vt+Lk(关于k,t的不定方程)时间复杂度这个时候考虑t的取值使上式成立,如果那么只用对t遍历,如果找到t了就直接输出(这是当然的),如果vt-s模L的余数构成了一个循环(不包含零)那就显然不行输出impossible(这里可以证明是一定要遍历L/gcd(L,v)次的),因为考虑t1,t原创 2022-04-02 20:55:53 · 766 阅读 · 0 评论 -
P1029 [NOIP2001 普及组] 最大公约数和最小公倍数问题
#include<bits/stdc++.h>using namespace std;#define ll long long//#define LOCALint main(){#ifdef LOCAL freopen("data.in","r",stdin); freopen("data.out","w",stdout);#endif // LOCAL int a,b; cin>>a>>b; int pq=b/a,c.原创 2022-04-02 12:03:11 · 138 阅读 · 0 评论 -
数论笔记《算法导论》
练习的题解会慢慢给出(最近要准备比赛好忙)基础数论首先是一些规定记号和基本结论下面这个31.4在后面证明中有多次的引用(这个结论是理所当然的,但很容易错)下面的定理也就是著名的裴蜀(贝祖)定理1.上述q的取法是很常见的,也就是让a=qs+m(m为a除s的余数)2.对于证明第4行,由于a mod s<s,如果a mod s为一个不为0的数,那么就和s是a,b的线性组合集的最小正元素矛盾(等于0当然可以啦,毕竟0不是正数)我又把...原创 2022-04-12 12:27:00 · 276 阅读 · 0 评论 -
P1049 [NOIP2001 普及组] 装箱问题
#include<bits/stdc++.h>using namespace std;int v[40];int dp[40][20010];int main(){ int V,n; cin>>V>>n; for(int i=0;i<n;i++) scanf("%d",&v[i]); for(int j=v[0];j<=V;j++) dp[0][j]=v[0]; f.原创 2022-03-30 23:00:30 · 73 阅读 · 0 评论 -
[洛谷]CF1660A Vasya and Coins
Vasya decided to go to the grocery store. He found in his walletaacoins of11burle andbbcoins of22burles. He does not yet know the total cost of all goods, so help him find outss(s>0s>0): theminimumpositive integer amount of money hecann...原创 2022-04-01 20:57:48 · 371 阅读 · 0 评论 -
XD4YTCB2021招生选拔赛
A-盛夏!海岛?大冒险!#include<bits/stdc++.h>#define ll long longusing namespace std;ll qmul(ll a,ll b,ll mod){//a*b mod mod ll ans=0; while(b){ if (b&1)ans=(ans+a)%mod; b>>=1; a=a<<1%mod; } retur原创 2022-04-20 15:07:35 · 256 阅读 · 0 评论 -
数组栈、队列和stl笔记(过几天就写完了)
牛客竞赛语法入门班数组栈、队列和stl习题A-老子的全排列呢解法一:神仙 ------> next_permutation();(还有prev_permutation();)用法:如果存在下一个字典序则返回true,否则返回false#include<bits/stdc++.h>using namespace std;#define ll long long//输出1-8的全排列int main(){ int a[]={1,2,3,4,5,6,7,8原创 2022-04-07 22:36:30 · 167 阅读 · 0 评论 -
P1060 [NOIP2006 普及组] 开心的金明
#include<bits/stdc++.h>using namespace std;struct ob{ int heavy; int value;};vector<ob> val;int dp[25][30000];int main(){ int V,n,p; cin>>V>>n; for(int i=0;i<n;i++){ int a,b; cin>>.原创 2022-03-30 23:48:04 · 101 阅读 · 0 评论 -
乘法逆元笔记(等以后遇到例题再加,现在就6道^_^)
拓展欧几里得求逆元求从1-n中mod p的逆元ll exgcd(ll a,ll b,ll &x,ll &y){//ax+by=gcd(a,b) if(b==0){ x=1;y=0; return a; } //x1=y2 y1=x1-(a/b)*y2 ll d=exgcd(b,a%b,x,y); ll t=x; x=y; y=t-a/b*y; return d;}int main(原创 2022-04-03 08:54:33 · 2211 阅读 · 0 评论 -
uva 1584 环状序列
#include<bits/stdc++.h>#define ll long longusing namespace std;struct ans{ int head; int teil;};int main(){#ifdef LOCAL freopen("data.in","r",stdin); freopen("data.out","w",stdout);#endif // LOCAL int t; cin>>t; while(.原创 2022-04-01 22:45:56 · 134 阅读 · 0 评论 -
P5020 [NOIP2018 提高组] 货币系统
ps:这题开始文件重定向忘记删了 全WA 吓死我了#include<bits/stdc++.h>using namespace std;struct ob{ int heavy; int value;};vector<ob> val;int dp[100][25010];//前i个货币可以表示的面值int T,n,sys[110];bool is_exp[110],page[25010];//判断第i个货币是否可以被前面的货币表示int main原创 2022-03-31 19:32:02 · 231 阅读 · 0 评论 -
P1226 【模板】快速幂||取余运算
#include<bits/stdc++.h>#define ll long longusing namespace std;ll qmul(ll x,ll y,ll p){//x*y mod p ll ans=0; x%=p; y%=p;//减小规模 while (y){ if(y&1==1)ans=(ans+x)%p; y>>=1; x=x<<1%p; } ret.原创 2022-03-31 21:11:06 · 74 阅读 · 0 评论 -
河南省第十三届ICPC大学生程序设计竞赛
A-祝融传火暴力直接秒就行#include<bits/stdc++.h>using namespace std;int A[1010][1010];int main(){ int n,m,a,b; cin>>n>>m; for(int i=0;i<n;i++) for(int j=0;j<m;j++) scanf("%d",&A[i][j]); cin>&原创 2022-04-13 22:08:05 · 212 阅读 · 0 评论 -
关于一道题引发的惨案
Ruri 遇到了两个函数:f(x)表示大于 x的最小的质数。g(x,y) 表示x!包含因子 y的个数。Ruri 想知道对于一个给定 (x,y) 对,g(f(x),y) 的大小。输入描述:第一行一个整数 T(T<=),表示询问组数。后面 T 行为两个正整数 x,y(1≤x≤1e16,2≤y≤1e9)输出描述:T 行,每行一个整数,g(f(x),y)g(f(x),y)g(f(x),y) 的大小。答案对 998244343 取模。#include<bits/stdc++..原创 2022-04-13 22:21:42 · 272 阅读 · 0 评论 -
CF Deletive Editing
水题 感觉没什么好说的,代码里有部分注释#include<bits/stdc++.h>#define ll long longusing namespace std;int main(){ int T; cin>>T; while(T--){ string s,t; cin>>s>>t; vector<int> pos; int p=t.size()-..原创 2022-04-13 20:29:33 · 481 阅读 · 0 评论 -
Educational Codeforces Round 123 (Rated for Div. 2)
首先是都用了的快读快些写inline int read(){ char ch=getchar();int s=0,w=1; while(ch<48||ch>57){if(ch=='-')w=-1;ch=getchar();} while(ch>=48&&ch<=57){s=(s<<1)+(s<<3)+ch-48;ch=getchar();} return s*w;}inline void wri..原创 2022-04-12 20:02:22 · 348 阅读 · 0 评论 -
动态规划专讲
[牛客]被3整除的子序列给你一个长度为50的数字串,问你有多少个子序列构成的数字可以被3整除,答案对1e9+7取模解析:首先对其子问题进行解决,前i个元素所构成的序列有几个子序列mod 3的余数分别是0,1,2,那么推广到i+1,考虑第i+1个元素1.若单取s[i+1],则dp[i+1][s[i+1]%3]++;2.不取s[i+1],则余数与前面的子序列相同3.取前面的子序列以及s[i+1]下面给出代码#include<bits/stdc++.h>usin原创 2022-04-08 19:41:07 · 860 阅读 · 0 评论 -
面向对象程序设计笔记 继承与派生
继承继承是使代码可以复用的重要手段,也是面向对象程序设计的核心思想之一。简单的说,继承是指一个对象直接使用另一对象的属性和方法。C++ 中的继承关系就好比现实生活中的父子关系,继承一笔财产比白手起家要容易得多,原始类称为基类,继承类称为派生类,基类是对派生类的抽象,派生类是对基类的具体化。它们是类似于父亲和儿子的关系,所以也分别叫父类和子类。而子类又可以当成父类,被另外的类继承。派生类的声明方式声明派生类的一般格式为:class 派生类名:继承方式 基类名{派生类新增加的成员};继承方原创 2022-05-16 15:53:42 · 809 阅读 · 0 评论 -
面向对象程序设计笔记
1.构造函数与析构函数如果不存在其他的初始化语句,在创建第一个对象时,所有的静态数据都会被初始化为零。定义分成两部分,一是静态变量的初始化,二是静态函数的定义。静态变量的初始化不能在类的定义中,但是可以在类的外部通过使用范围解析运算符::来重新声明静态变量从而对它进行初始化。而定义静态函数,那就与定义实例函数一样了。静态成员的访问有以下两种方法: 使用类型名::静态成员格式访问;(可以将其看做是一个全局变量,只不过变量名要带上类型名::的前缀) 通过对象访问;(可.原创 2022-04-26 16:39:24 · 1547 阅读 · 0 评论 -
模拟、枚举、贪心(一)
A-[NOIP2007]字符串的展开1B-[NOIP2017]时间复杂度2C-[NOIP2010]机器翻译#include<bits/stdc++.h>using namespace std;int dict[110],pas[1010];int main(){ int m,n,cnt=0; cin>>m>>n; for(int i=0;i<n;i++)cin>>pas[i]; for(i.原创 2022-04-23 21:08:33 · 1166 阅读 · 0 评论 -
树状数组
树状数组原创 2022-05-18 15:05:14 · 339 阅读 · 1 评论 -
第十八届西南科技大学ACM程序设计竞赛
B-为欢几何超级水题#include<bits/stdc++.h>using namespace std;int n;string s;int main(){ cin>>n; while(n--){ cin>>s; cout<<s[0]; } return 0;}M-劝君终日酩酊醉,酒不到刘伶坟上土简单模拟#include<bits/st..原创 2022-05-15 09:33:21 · 410 阅读 · 0 评论 -
概率与期望
1.多重集排列多重集概念多重集排列例题-擅长解密的小红同学原创 2022-05-14 09:12:08 · 246 阅读 · 0 评论 -
数学笔记1
一些符号复数复数类的实现class Complex{ public: double real,image; Complex(double r,double i):real(r),image(i){}; void Print(){ if(image>=0) cout<<real<<"+"<<image<<"i"<<endl; else cout<<real<<image&l原创 2022-05-14 07:54:32 · 116 阅读 · 0 评论 -
模拟例题集
牛牛的数列(牛牛的数列 (nowcoder.com) )细节在注释里#include<bits/stdc++.h>using namespace std;int a[100010];vector < pair<int,int> > b;int main(){ ios::sync_with_stdio(false); cin.tie(0); cout.tie(0); int n,l=0,r=0,maxn=0;.原创 2022-04-25 21:14:30 · 103 阅读 · 0 评论 -
前缀和、差分
前缀和、差分原创 2022-07-18 22:21:56 · 161 阅读 · 0 评论 -
二分查找(binary_search)
整数二分bs1,bs2分别对应两种需要查找的不同位置bs1:查找最后一个trueint bs(int a[],int l,int r){//binary_search while(l<r){ int mid=l+r>>1; if(check(mid))l=mid; else r=mid-1; } return l;}bs1:查找第一个falseint bs(int a[],..原创 2022-04-23 13:06:43 · 175 阅读 · 0 评论 -
矩阵快速幂
模板struct Matrix{ ll a[2][2]; Matrix operator *(const Matrix & b){ Matrix c={0,0,0,0};//注意初始c for(int i=0;i<2;i++) for(int j=0;j<2;j++) for(int k=0;k<2;k++) c.a[i][j]=(c原创 2022-04-21 19:44:03 · 80 阅读 · 0 评论