摘要: dijkstra算法的大题思路是通过n - 1次迭代,每次迭代把一个点距汇点的最短路确定,当n - 1次循环过后所有点的最短路都已经确定 注意:dijkstra算法只适用于没有负权边的单源最短路 以下是算法的详细步骤 #include <iostream> #include <cstring> #i 阅读全文
posted @ 2022-05-30 11:34 cxy8 阅读(77) 评论(0) 推荐(0)
摘要: #include"bits/stdc++.h" using namespace std; int prime(int x) { if(x<2) return 0; for(int i=2;i*i<=x;i++) { if(x%i==0) return 0; } return 1; } int mai 阅读全文
posted @ 2022-05-07 19:22 cxy8 阅读(17) 评论(0) 推荐(0)
摘要: 不能直接两重循环数据是1e5会超时 这样 #include"bitsdc++.h" using namespace std; const int N=1e5+10; double a[N],s[N]; double ans; int main() { int n; cin>>n; for(int i 阅读全文
posted @ 2022-05-07 18:45 cxy8 阅读(23) 评论(0) 推荐(0)
摘要: #include"bits/stdc++.h" using namespace std; const int N=100010; long long ans,n,p; long long a[N]; int main() { cin>>n>>p; for(int i=0;i<n;i++) cin>> 阅读全文
posted @ 2022-04-26 18:03 cxy8 阅读(35) 评论(0) 推荐(0)
摘要: 说实话这个题审题把我卡了半天,还是我太菜 直接上代码吧 偷个懒用万能库。 #include"bits/stdc++.h" using namespace std; int mp[1010][1010]; int n,m; int dx[8]={1,1,1,0,0,-1,-1,-1},dy[8]={- 阅读全文
posted @ 2022-04-18 23:06 cxy8 阅读(27) 评论(0) 推荐(0)
摘要: #include"bits/stdc++.h" using namespace std; int mp[110][110]; bool vis[110][110]; int dx[4]={1,-1,0,0},dy[4]={0,0,1,-1}; struct point { int x,y; }; i 阅读全文
posted @ 2022-04-16 16:02 cxy8 阅读(25) 评论(0) 推荐(0)
摘要: 1044 火星数字 (20 分) 火星人是以 13 进制计数的: 地球人的 0 被火星人称为 tret。地球人数字 1 到 12 的火星文分别为:jan, feb, mar, apr, may, jun, jly, aug, sep, oct, nov, dec。火星人将进位以后的 12 个高位数字 阅读全文
posted @ 2022-04-15 15:01 cxy8 阅读(43) 评论(0) 推荐(0)
摘要: 题目 1039 到底买不买 小红想买些珠子做一串自己喜欢的珠串。卖珠子的摊主有很多串五颜六色的珠串,但是不肯把任何一串拆散了卖。 于是小红要你帮忙判断一下,某串珠子里是否包含了全部自己想要的珠子?如果是,那么告诉她有多少多余的珠子; 如果不是,那么告诉她缺了多少珠子。 为方便起见,我们用[0-9]、 阅读全文
posted @ 2022-04-12 13:21 cxy8 阅读(16) 评论(0) 推荐(0)
摘要: #include"bits/stdc++.h" using namespace std; int main() { int a,b[105]={0}; long i,n,K; cin>>n; for(i=0;i<n;i++) { cin>>a; b[a]++; } cin>>K; int c[K]; 阅读全文
posted @ 2022-04-11 15:09 cxy8 阅读(16) 评论(0) 推荐(0)
摘要: #include"stdio.h" #include"string.h" int main() { int flag=1; char w[100010],ch[100010]; int a[200]={0}; gets(w); gets(ch); int t1=strlen(w),t2=strlen 阅读全文
posted @ 2022-04-09 22:14 cxy8 阅读(27) 评论(0) 推荐(0)