ACM—算法
水上诗人
一滴水只有放进大海里才永远不会干涸,一个人只有当他把自己和集体事业融合在一起的时候才能最有力量
展开
-
扩展欧几里德 ———求解不定方程
来源:http://www.cnblogs.com/void/archive/2011/04/18/2020357.html刚开始接触欧几里德解不定方程的时候,对于方程 ax + by = gcd(a, b)一定有解很纠结,非常纠结,它为什么就一定有解,为什么??!!后来看了好些个(对,就是很多)博客,也就慢慢释然了,人家说有解就有解了,不服你就买本数论去学呀,学个几十年搞懂了再回来敲代码啊,人家...转载 2017-08-29 16:40:26 · 448 阅读 · 0 评论 -
HDU 2669 Romantic(扩展欧几里德裸题)
裸的扩展欧几里德解不定方程,话不多说,看代码中间#include #include using namespace std; int x, y, c, r; int exgcd(int a, int b, int &x, int &y)//知道扩展欧几里德此处不难写,裸模版; { if(b == 0) { x = 1; y = 0;原创 2017-08-29 17:15:03 · 254 阅读 · 0 评论 -
light oj 1003—拓扑排序
题意:即找所给字符串组成的饮料名是否组成环 涉及知识: 1、链表 2、拓扑排序 3、STL 中 map、stack的应用(当然也可以自己实现,不太建议,当然没事儿写来练手当然行) 详细注释见代码:#include #include #include #include #include #include #include using namespace std; ///链表存图 typ原创 2018-01-25 17:53:41 · 167 阅读 · 0 评论 -
light 1007
区间内逐个用欧拉函数求scoreTLE卡, 用了筛选法 WA卡, 用了long long WA又卡,最后又在网上看了看unsigned过了 #include #include #include using namespace std; typedef unsigned long long ULL; int in[100010][2]; ULL score[5000010]; void sco原创 2018-01-27 11:39:07 · 184 阅读 · 0 评论