上一页 1 ··· 167 168 169 170 171 172 173 174 175 ··· 182 下一页
摘要: 普通的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 阅读全文
posted @ 2011-03-01 09:30 undefined2024 阅读(239) 评论(0) 推荐(0)
摘要: 简单的考察输入输出的题。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 += 阅读全文
posted @ 2011-03-01 08:13 undefined2024 阅读(223) 评论(0) 推荐(0)
摘要: spfa算法可以用栈代替队列,入栈时注意判断是否已在栈中。开始以为是要找最长路,其实是要找最短路。View Code #include <iostream>#include <cstdio>#include <cstdlib>#include <cstring>using namespace std;#define maxn 30005#define maxm 150005struct Edge{ int v, w, next;}edge[maxm];int n, m, head[maxn], mystack[maxn], edgenum, to 阅读全文
posted @ 2011-02-28 15:07 undefined2024 阅读(432) 评论(0) 推荐(0)
摘要: BFS,因为这题是4位数,所以要判断是不是素数只需要100以下的素数,先生成100以下素数表。View Code #include <iostream>#include <cstdlib>#include <cstring>#include <cstdio>#include <queue>using namespace std;struct item{ int num[4];} a, b;int prime[100], primenum, cost[10000];int toint(item &a){ int ans = 0; 阅读全文
posted @ 2011-02-28 14:23 undefined2024 阅读(685) 评论(0) 推荐(0)
摘要: 我们只注意各队比分之和,认为一场比赛会如果战平则总和+2否则总和+3。所以我们只要输出3 * n - sum就可以了。View Code #include <iostream>#include <cstdio>#include <cstdlib>#include <cstring>using namespace std;int main(){ //freopen("D:\\t.txt", "r", stdin); int n, t; while (scanf("%d%d", &t 阅读全文
posted @ 2011-02-28 12:38 undefined2024 阅读(194) 评论(0) 推荐(0)
上一页 1 ··· 167 168 169 170 171 172 173 174 175 ··· 182 下一页