
STL
躺平平的弱鸡
IT界资深菜鸟。。
展开
-
NYOJ93汉诺塔(三)
题目链接:http://acm.nyist.net/JudgeOnline/problem.php?pid=93用栈模拟就好了。代码:#include #include using namespace std;int p,q;int flag;struct Node{ stack st;}a[5];int fr[105],too[105];vo原创 2016-04-11 22:57:20 · 372 阅读 · 0 评论 -
NYOJ86找球号(一)
题目链接:http://acm.nyist.net/JudgeOnline/problem.php?pid=86这道题两种解法,一个是二分查找,一个是用set。注意:这道题数据不是读到文件尾,超时的小伙伴看过来。 二分: #include #include using namespace std;const int maxn = 1e8;原创 2016-04-11 22:12:16 · 296 阅读 · 0 评论 -
STL set和priority_queue使用方法
set头文件#include using namespace std;申请对象 set s; (T是数据类型)1.s.insert(x):向set中插入一个值2.s.count(x):检查set中有没有x这个值,如果有返回1,如果没有返回03.s.size():返回当前set中元素个数4.s.empty() 判断当前的set是否为空5.s.begin() :返回第一个原创 2016-04-09 21:54:32 · 1096 阅读 · 1 评论 -
NYOJ55懒省事的小明
题目链接:http://acm.nyist.net/JudgeOnline/problem.php?pid=55这个题和石子合并有一定区别,这个是任意两堆都可以合并,所以贪心就好了,每次合并两堆重量最小的,优先队列!!代码:#include #include using namespace std;typedef long long ll;prior原创 2016-04-11 19:03:54 · 802 阅读 · 0 评论 -
NYOJ8一种排序
题目链接:http://acm.nyist.net/JudgeOnline/problem.php?pid=8STL sort的模板题,注意一下输入的时候长和宽的问题。。代码:#include #include using namespace std;struct Node{ int number; int length; int wi原创 2016-04-10 22:35:54 · 238 阅读 · 0 评论 -
NYOJ1112求次数
题目链接:http://acm.nyist.net/JudgeOnline/problem.php?pid=1112用set水了好几遍才过的。。。#include #include #include #include using namespace std;set st;int main(){ int t; scanf("%d",&t);原创 2016-04-13 19:22:34 · 419 阅读 · 0 评论 -
NYOJ991Registration system
题目链接:http://acm.nyist.net/JudgeOnline/problem.php?pid=991还是STL中的set头文件#include using namespace std;声明:set s.如果来了一个字符串a,用s.count(a)判断s中是否存在a,如果不存在a,直接输出OK并用s.insert(a)把a插入到s中,如果存在了,就从a1一直往原创 2016-04-13 18:26:48 · 361 阅读 · 0 评论 -
NYOJ412Same binary weight
题目链接:http://acm.nyist.net/JudgeOnline/problem.php?pid=412思路:从n的二进制中从右往左寻找第一个01,然后将01右边的1全都移到最右边;用的是bitset声明: bitset bt(n) 代表n的二进制存在了bt中,bt[i]上的数字代表n的二进制中的各个数字,bt.to_ulong()是将bt以无符号长整型输出出原创 2016-04-13 17:50:59 · 397 阅读 · 0 评论 -
NYOJ95众数问题
题目链接:http://acm.nyist.net/JudgeOnline/problem.php?pid=95vector不解释。每次要清空vector代码:#include #include #include using namespace std;const int maxn = 1e5;vector ans[maxn + 5];in原创 2016-04-11 23:29:39 · 354 阅读 · 0 评论 -
NYOJ1100WAJUEJI which home strong!
题目链接:http://acm.nyist.net/JudgeOnline/problem.php?pid=1100BFS + 优先队列! 自定义优先级!!!!!代码:#include #include #include using namespace std;typedef struct Node{ int x,y; char c;原创 2016-04-16 19:57:29 · 556 阅读 · 0 评论