05 2022 档案
摘要:dijkstra算法的大题思路是通过n - 1次迭代,每次迭代把一个点距汇点的最短路确定,当n - 1次循环过后所有点的最短路都已经确定 注意:dijkstra算法只适用于没有负权边的单源最短路 以下是算法的详细步骤 #include <iostream> #include <cstring> #i
阅读全文
摘要:#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
阅读全文
摘要:不能直接两重循环数据是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
阅读全文