摘要: Dijkstra算法_ ** 时隔多月,我又回来了!**_ 今天下午久违的又学了会儿算法,又重新学习了一遍Dijkstra,这是第三次重新学习Dijkstra(*以前学的都忘完了>_<*). 废话先不bb,上代码。 #include<bits/stdc++.h> using namespace st 阅读全文
posted @ 2019-12-03 23:09 Luoha 阅读(548) 评论(0) 推荐(0) 编辑
摘要: 好多天没碰代码了,感觉忘得差不多了,没有学习感觉罪恶深重,从今天起开始补题啊啊! 简单零一背包,套模板就行。 阅读全文
posted @ 2019-09-07 15:31 Luoha 阅读(166) 评论(0) 推荐(0) 编辑
摘要: int isprime(int n) { if(n<=3) return n>1; int k; k=sqrt(n); if(n%6!= 1 && n%6!=5) return 0; for(int i=5;i<=k;i+=6) { if(n%i==0 || n%(i+2)==0) return 0; } return 1; } 阅读全文
posted @ 2019-09-02 20:26 Luoha 阅读(132) 评论(0) 推荐(0) 编辑
摘要: The input contains N natural (i.e. positive integer) numbers ( N <= 10000 ). Each of that numbers is not greater than 15000. This numbers are not nece 阅读全文
posted @ 2019-08-15 22:48 Luoha 阅读(255) 评论(0) 推荐(0) 编辑
摘要: Given a number N, you are asked to count the number of integers between A and B inclusive which are relatively prime to N. Two integers are said to be 阅读全文
posted @ 2019-08-15 22:29 Luoha 阅读(185) 评论(0) 推荐(0) 编辑
摘要: Now you get a number N, and a M-integers set, you should find out how many integers which are small than N, that they can divided exactly by any integ 阅读全文
posted @ 2019-08-15 22:02 Luoha 阅读(180) 评论(0) 推荐(0) 编辑
摘要: 要求(A/B)%9973,但由于A很大,我们只给出n(n=A%9973)(我们给定的A必能被B整除,且gcd(B,9973) = 1)。 模板题,现在给你模板: AC代码: 以上。 阅读全文
posted @ 2019-08-14 22:32 Luoha 阅读(123) 评论(0) 推荐(0) 编辑
摘要: 度熊手上有一本字典存储了大量的单词,有一次,他把所有单词组成了一个很长很长的字符串。现在麻烦来了,他忘记了原来的字符串都是什么,神奇的是他竟然记得原来那些字符串的哈希值。一个字符串的哈希值,由以下公式计算得到: H(s)=∏i≤len(s)i=1(Si−28) (mod 9973)H(s)=∏i=1 阅读全文
posted @ 2019-08-14 22:11 Luoha 阅读(247) 评论(0) 推荐(0) 编辑
摘要: 简述: 每个大于一的正整数都可以分为多个质数的积 20:->2*2*5 60:->2*2*3*5 计算过程: 从第一个质数2开始,把n中所有2的因数除掉,再除下一个,除到最后必为1. 阅读全文
posted @ 2019-08-12 21:24 Luoha 阅读(257) 评论(0) 推荐(0) 编辑
摘要: 午时刷题,难甚,遂小憩于桌上,惊醒,于梦中有所得,虽大声曰:吾已得tarjan之奥秘! 关于tarjan算法,其实就是一个递归加并查集的应用。 大致代码: 由以上代码可以看出,tarjan实际上就是并查集与dfs的结合,其最核心的部分就是dfs那部分 只要理解了dfs()的内容,就能理解tarjan 阅读全文
posted @ 2019-08-08 23:33 Luoha 阅读(198) 评论(0) 推荐(0) 编辑