A. (a, b)-Tower 当指数大于模数的时候用欧拉定理递归计算,否则直接暴力计算. #include<cstdio> #include<algorithm> #include<cmath> #include<string> #include<iostream> using namespace std; typedef long long LL; int pw(int x,int y,int mod){ int ret=1; for(int…
A. Passage 枚举两个点,看看删掉之后剩下的图是否是二分图. #include <bits/stdc++.h> using namespace std ; const int MAXN = 205 ; vector < int > G[MAXN] ; int vis[MAXN] , col[MAXN] ; int n ; int dfs ( int u ) { for ( int i = 0 ; i < G[u].size () ; ++ i ) { int v =…
A. Avengers, The 留坑. B. Black Widow 将所有数的所有约数插入set,然后求mex. #include<bits/stdc++.h> using namespace std; typedef long long LL; typedef pair<int,int>pi; const int mod=1e9+7; int n,i,x; set<int>T; inline void add(int n){ for(int i=1;i<=n…
A. Nanoassembly 首先用叉积判断是否在指定向量右侧,然后解出法线与给定直线的交点,再关于交点对称即可. #include<bits/stdc++.h> using namespace std; const int Maxn=300020; typedef long long LL; typedef pair<int,int>pi; struct P{ double x,y; P(){x=y=0;} P(double _x,double _y){x=_x,y=_y;}…
V for Vendetta V字仇杀队 复仇者V 安迪·沃卓斯基 and Larry Wachowski 思想,是最强大的武器.因为,世界上的独裁政府,有一个共同特点就是推行洗脑和愚民政策. 经典台词: We are told to remember the idea,not the man. Because man can fail.He can be cought,he can be killed and forgotten. But you cannot kiss an idea. Yo…
Going from u to v or from v to u? Time Limit: 2000MS Memory Limit: 65536K Description In order to make their sons brave, Jiajia and Wind take them to a big cave. The cave has n rooms, and one-way corridors connecting some rooms. Each tim…
Going from u to v or from v to u? Time Limit: 2000MS Memory Limit: 65536K Total Submissions: 17089 Accepted: 4590 Description In order to make their sons brave, Jiajia and Wind take them to a big cave. The cave has n rooms, and one-way corridors…
题目链接:http://www.lightoj.com/volume_showproblem.php?problem=1019 题目大意:Tanvir想从节点1的位置走到节点n的位置, 输出最短距离, 如果不存在输出"Impossible". 解题思路:dijkstra模版题 代码如下: #include<bits/stdc++.h> using namespace std; typedef long long LL; const int INF = 0x3f3f3f3f;…
In the C++ STL, the vector size() function return size_t, which is unsigned int, not int. So imagine this, define an empty vector<int> v, and v.size() should be 0, and you have a for loop, and has an end condition is v.size() - 1, which is 429496729…
1. 概述 三种类型的System V IPC:System V 消息队列.System V 信号量.System V 共享内存区 System V IPC在访问它们的函数和内核为它们维护的信息上共享许多类似点.本章讲述所有这些共同属性. 下图汇总了所有System V IPC 函数 2. key_t键.ftok函数 头文件sys/types.h把数据类型key_t定义为一个整数,通常是一个至少32位的整数 #include <sys/ipc.h> key_t ftok (const char…
System V消息队列是Open Group定义的XSI,不属于POSIX标准.System V IPC的历史相对很早,在上个世70年代后期有贝尔实验室的分支机构开发,80年代加入System V的系统内核中,后来商用UNIX系统基本都加入了System V IPC的功能. System V消息队列相对于POSIX消息队列的区别主要是: POSIX消息队列的读操作总是返回消息队列中优先级最高的最早消息,而对于System V消息队列可以返回任意指定优先级(通过消息类型)的消息. 当向一个空消息…