摘要:
简单题View Code #include <iostream>#include <cstdio>#include <cstdlib>#include <cstring>using namespace std;int main(){ //freopen("D:\\t.txt", "r", stdin); int t; scanf("%d", &t); while (t--) { int a, b, c; scanf("%d%d%d", &a, & 阅读全文
摘要:
spfa,说是边的价值=承重*单位价,实际上就是把到达每个结点所需经过的边的单位价之和乘以结点重量之积加起来即可。所以我们就是要让到达每个结点经过的边的单位价格之和最小。这就变成了最短路问题。这道题用栈超时,用队列能过。所以以后用spfa还是用队列的好。View Code #include <iostream>#include <cstdio>#include <cstdlib>#include <cstring>using namespace std;#define maxn 150005struct Edge{ int v, w, next; 阅读全文
摘要:
普通的n^2的筛法居然比线性筛法快,不知道以后该用哪个了……View Code #include <iostream>#include <cstdio>#include <cstdlib>#include <cstring>using namespace std;#define maxn 1000000bool prime[maxn];int main(){ //freopen("D:\\t.txt", "r", stdin); memset(prime, true, sizeof(prime)); for 阅读全文
摘要:
简单的考察输入输出的题。View Code #include <iostream>#include <cstdio>#include <cstdlib>#include <cstring>using namespace std;int main(){ //freopen("D:\\t.txt", "r", stdin); int n, s; scanf("%d%d", &n, &s); s--; for (int i = 1; i <= n; i++) { s += 阅读全文