摘要: 如果1可以变换到2,2可以变换到3,那么1可以变换到3,这可以用Floyd算法,要注意一点的是,其它数不可以变换到零,而零可以变到其它数, 我的高精度算法一开始是错的,我的做法会导致进位的数也乘了s,在最后要处理carry,但要记得carry/10,不然会成死循环 #include<iostream 阅读全文
posted @ 2025-02-18 22:30 郭轩均 阅读(1) 评论(0) 推荐(0) 编辑
摘要: #include<iostream> using namespace std; int d[120][120]; int w[10020]; int main(){ int n,m; cin>>n>>m; for(int i=1;i<=m;i++)cin>>w[i]; for(int i=1;i<= 阅读全文
posted @ 2025-02-18 20:28 郭轩均 阅读(2) 评论(0) 推荐(0) 编辑
摘要: 这道题要注意初始化w数组为最大值,并且w[1]=0;有负环的话输出YES,没有输出NO; #include<iostream> #include<queue> #include<vector> using namespace std; const int N=3000+5; struct node{ 阅读全文
posted @ 2025-02-18 20:13 郭轩均 阅读(3) 评论(0) 推荐(0) 编辑
摘要: 迪杰斯特拉算法就是每次寻找与与原点最近的点然后更新与它相连的点,要注意的是传入起始点时不需要标记它,因为需要它扩展到其他点,只有当一个点出队时才需要标记它,因为后入队的同一个点可能距离更小 #include<iostream> #include<queue> #include<vector> #de 阅读全文
posted @ 2025-02-18 20:10 郭轩均 阅读(1) 评论(0) 推荐(0) 编辑
摘要: 这道题,没想到可以把启动机器时间对后面的影响分离出来,这样第i个物品处理完的时间就是处理前面i个物品的时间总和 #include<iostream> #define int long long using namespace std; const int N=1e6; int f[N]; int c 阅读全文
posted @ 2025-02-18 15:19 郭轩均 阅读(1) 评论(0) 推荐(0) 编辑
摘要: 注意不要把q[h+1]写成q[h-1]; #include<iostream> using namespace std; #define int long long const int N=4*1e6+200; int f[N]; int s[N]; int c[N]; int q[N]; doub 阅读全文
posted @ 2025-02-18 14:33 郭轩均 阅读(1) 评论(0) 推荐(0) 编辑
摘要: 斜率优化dp最重要的就是写正确关系式并且找对x,y,k,b; f[i]=f[j]+(i-(j+1)+sum[i]-sum[j+1-1]-l)^2 减的是j+1,因为求的是j+1到i; f[i]=f[j]+(s[i]+i-(s[j]+j)-(l+1))^2; 令pi=s[i]+i,pj=s[j]+j, 阅读全文
posted @ 2025-02-18 13:53 郭轩均 阅读(2) 评论(0) 推荐(0) 编辑
点击右上角即可分享
微信分享提示