比赛链接:http://hihocoder.com/contest/hihointerview26

A.排序后枚举两个点,确定一个矩形后二分剩下两个点。

 #include <bits/stdc++.h>
using namespace std; typedef long long LL;
const int maxn = ;
typedef struct Point {
int x, y;
Point() {}
Point(int xx, int yy) : x(xx), y(yy) {}
}Point;
int n;
LL ans;
Point p[maxn]; bool cmp(Point a, Point b) {
if(a.x == b.x) return a.y < b.y;
return a.x < b.x;
} bool bs(int x, int y) {
int ll = , rr = n, mm;
while(ll <= rr) {
mm = (ll + rr) >> ;
if(p[mm].x == x && p[mm].y == y) return ;
else if(cmp(p[mm], Point(x, y))) ll = mm + ;
else rr = mm - ; }
return ;
} int main() {
// freopen("in", "r", stdin);
int x3, y3, x4, y4;
while(~scanf("%d", &n) && n) {
ans = 1000000LL * 1001000LL;
for(int i = ; i < n; i++) {
scanf("%d%d", &p[i].x, &p[i].y);
}
sort(p, p+n, cmp);
for(int i = ; i < n; i++) {
for(int j = i + ; j < n; j++) {
x3 = p[i].x; y3 = p[j].y;
x4 = p[j].x; y4 = p[i].y;
if(bs(x3, y3) && bs(x4, y4)) {
int a = x3 - x4;
int b = y3 - y4;
if((LL)a * b == ) continue;
ans = min(ans, abs((LL)a*b));
}
}
}
printf("%lld\n", ans == 1000000LL * 1001000LL ? - : ans);
}
return ;
}

B.按题要求爆搜

 #include <bits/stdc++.h>
using namespace std; const int maxn = ;
int n;
set<string> ret;
set<string>::iterator it;
int num[maxn];
set<int> pos; int main() {
// freopen("in", "r", stdin);
// freopen("out", "w", stdout);
for(int i = ; i < maxn; i++) num[i] = i;
while(~scanf("%d", &n)) {
ret.clear();
do {
int nn = ( << (n));
for(int i = ; i < nn; i++) {
pos.clear();
int tmp = i;
int cnt = ;
while(tmp) {
if(tmp & ) pos.insert(cnt+);
tmp >>= ; cnt++;
}
string t = "";
bool ex = ;
t += (num[] + '');
int pre = num[];
for(int i = ; i <= n; i++) {
if(ex) break;
if(pos.find(i) != pos.end()) {
t += '-';
pre = -;
}
if(pre > num[i]) {
ex = ;
break;
}
t += (num[i] + '');
pre = num[i];
}
if(!ex) ret.insert(t);
}
// for(int i = 1; i <= n; i++) printf("%d", num[i]);
// printf("\n");
}while(next_permutation(num+, num+n+));
// printf("%d\n", ret.size());
for(it = ret.begin(); it != ret.end(); it++) {
cout << *it << endl;
}
}
return ;
}

C.找到规律后斯特灵数胡搞(好像没必要?)

 #include <bits/stdc++.h>
using namespace std; typedef long long LL;
const int maxn = ;
const LL mod = 1000000007LL;
LL f[maxn], a[maxn];
LL S[maxn][maxn];
int n; LL exgcd(LL a, LL b, LL &x, LL &y) {
if(b == ) {
x = ;
y = ;
return a;
}
else {
LL ret = exgcd(b, a%b, x, y);
LL tmp = x;
x = y;
y = tmp - a / b * y;
return ret;
}
} LL inv(LL a) {
LL x, y;
exgcd(a, mod, x, y);
return (x % mod + mod) % mod;
} LL C(LL n, LL m) {
return f[n] * inv(f[m]) % mod * inv(f[n-m]) % mod;
} LL mul(LL x, LL n) {
LL ret = ;
while(n) {
if(n & ) ret = ret * x % mod;
n >>= ;
x = x * x % mod;
}
return ret;
} int main() {
// freopen("in", "r", stdin);
// freopen("out", "w", stdout);
memset(S, , sizeof(S));
S[][] = ;
for(int p = ; p < maxn; p++) {
for(int k = ; k < maxn; k++) {
S[p][k] = (LL)k * S[p-][k] % mod + S[p-][k-] % mod;
}
}
f[] = ;
for(int i = ; i < maxn; i++) {
f[i] = f[i-] * (LL)i % mod;
}
memset(a, , sizeof(a));
a[] = ; a[] = ;
for(int i = ; i <= ; i++) {
for(int k = ; k <= i; k++) {
a[i] = (a[i] + f[k] * S[i][k] % mod) % mod;
}
}
while(~scanf("%d", &n)) {
printf("%lld\n", a[n]);
}
return ;
}

hihoCoder太阁最新面经算法竞赛17的更多相关文章

  1. Hihocoder 太阁最新面经算法竞赛18

    Hihocoder 太阁最新面经算法竞赛18 source: https://hihocoder.com/contest/hihointerview27/problems 题目1 : Big Plus ...

  2. hihoCoder太阁最新面经算法竞赛15

    hihoCoder太阁最新面经算法竞赛15 Link: http://hihocoder.com/contest/hihointerview24 题目1 : Boarding Passes 时间限制: ...

  3. hihocoder Round #c1(hihoCoder太阁最新面经算法竞赛1 )

    Test链接:https://cn.vjudge.net/contest/231849 选自hihoCoder太阁最新面经算法竞赛1 更多Test:传送门 A:区间求差 给一组区间集合A和区间集合B, ...

  4. hihoCoder太阁最新面经算法竞赛19

    比赛链接:http://hihocoder.com/contest/hihointerview28/problems A. 固定一个方向,两两相邻的点顺时针或逆时针构造三个向量,判断这个点在这个向量的 ...

  5. hihoCoder太阁最新面经算法竞赛18

    比赛链接:http://hihocoder.com/contest/hihointerview27/problems A.Big Plus 模拟水 #include <bits/stdc++.h ...

  6. [HIHO]hihoCoder太阁最新面经算法竞赛7

    题目链接:http://hihocoder.com/contest/hihointerview12 期末完事了,终于有时间成套刷题了.这套题比较简单,难度上感觉和上一套差不多.除了最后一个题是看了讨论 ...

  7. zz 圣诞丨太阁所有的免费算法视频资料整理

    首发于 太阁实验室 关注专栏   写文章     圣诞丨太阁所有的免费算法视频资料整理 Ray Cao· 12 小时前 感谢大家一年以来对太阁实验室的支持,我们特地整理了在过去一年中我们所有的原创算法 ...

  8. [刷题]算法竞赛入门经典 3-12/UVa11809

    书上具体所有题目:http://pan.baidu.com/s/1hssH0KO 题目:算法竞赛入门经典 3-4/UVa11809:Floating-Point Numbers 代码: //UVa11 ...

  9. [刷题]算法竞赛入门经典 3-1/UVa1585 3-2/UVa1586 3-3/UVa1225

    书上具体所有题目:http://pan.baidu.com/s/1hssH0KO(我也是在网上找到的pdf,但不记得是从哪里搜刮到的了,就重新上传了一遍) PS:第一次写博客分享我的代码,不知道我对c ...

随机推荐

  1. 【crunch bang】论坛tint2配置讨论贴

    地址: http://crunchbang.org/forums/viewtopic.php?id=3232

  2. Mysql数据库读写分离配置

    环境模拟 实现读写分离 减轻数据库的负荷 主服务器  master   10.0.0.12 从服务器 slave    10.0.0.66 配置主服务器: 在10.0.0.12服务器操作   创建数据 ...

  3. Openstack的HA解决方案【替换原有的dashboard】

    0. 进入到/etc/haproxy/conf.d/目录下 mv 015-horizon.cfg 150-timaiaas.cfg 将原有的dashboard的ha配置文件做为自己的配置文件. 1. ...

  4. Servlet概念框架

    以 Servlet 3.0 源代码为基础.Servlet 是 Javaweb 应用的基础框架,犹如孙子兵法之于作战指挥官,不可不知. 概念框架 机制: 事件 Event, 监听器 Listener 数 ...

  5. Java中Properties类的使用

    1.properties介绍 java中的properties文件是一种配置文件,主要用于表达配置信息,文件类型为*.properties,格式为文本文件,文件的内容是格式是"键=值&quo ...

  6. Java锁的种类

    转载自:---->http://ifeve.com/java_lock_see/ Java锁的种类以及辨析锁作为并发共享数据,保证一致性的工具,在JAVA平台有多种实现(如 synchroniz ...

  7. Linux下命令行安装WebLogic 10.3.6

    1.创建用户useradd weblogic;创建用户成功linux系统会自动创建一个和用户名相同的分组,并将该用户分到改组中.并会在/home路径下创建一个和用户名相同的路径,比如我们创建的webl ...

  8. 【PHP设计模式 06_GuanChaZhe.php】观察者模式

    <?php /** * [观察者模式] * PHP5中提供了 观察者(observer) 和 被观察者(subject) 的接口 * 在手册搜索:SplSubject (PHP 5 >= ...

  9. HDU 1715 大菲波数

    大菲波数 问题描述 : Fibonacci数列,定义如下: f(1)=f(2)=1 f(n)=f(n-1)+f(n-2)  n>=3. 计算第n项Fibonacci数值. 输入: 输入第一行为一 ...

  10. win7中sql2005 连接其它sql2005服务器,连不上

    1.在管理工具-->高级安全 Windows 防火墙下配置下入站规则,将sql的端口加入里面,关闭防火墙并没有把这个给关闭掉 2 .Sql Server Browser 启用3.客户端协议 tc ...