折线中点

#pragma comment(linker, "/STACK:102400000,102400000")
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<vector>
#include<algorithm>
#include<iostream>
#include<map>
#include<queue>
#include<stack>
#include<string>
#include<functional>
#include<math.h>
//#include<bits/stdc++.h>
using namespace std;
typedef long long lint;
typedef vector<int> VI;
typedef pair<int, int> PII;
typedef queue<int> QI; void makedata() {
freopen("input.txt", "w", stdout);
fclose(stdout);
} double x[], y[]; int main() {
#ifndef ONLINE_JUDGE
freopen("input.txt", "r", stdin);
#endif
//makedata();
//std::ios::sync_with_stdio(0), cin.tie(0);
int n;
scanf("%d", &n);
for (int i = ; i < n; i++) scanf("%lf%lf", &x[i], &y[i]);
double l = ;
for (int i = ; i < n; i++) l += sqrt((x[i] - x[i - ]) * (x[i] - x[i - ]) + (y[i] - y[i - ]) * (y[i] - y[i - ]));
l /= 2.0;
for (int i = ; i < n; i++) {
double tmp = sqrt((x[i] - x[i - ]) * (x[i] - x[i - ]) + (y[i] - y[i - ]) * (y[i] - y[i - ]));
if (l > tmp) l -= tmp;
else {
printf("%.1lf %.1lf\n", x[i - ] + (l / tmp) * (x[i] - x[i - ]), y[i - ] + (l / tmp) * (y[i] - y[i - ]));
break;
}
}
return ;
}

最小先序遍历

#pragma comment(linker, "/STACK:102400000,102400000")
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<vector>
#include<algorithm>
#include<iostream>
#include<map>
#include<queue>
#include<stack>
#include<string>
#include<functional>
#include<math.h>
//#include<bits/stdc++.h>
using namespace std;
typedef long long lint;
typedef vector<int> VI;
typedef pair<int, int> PII;
typedef queue<int> QI; void makedata() {
freopen("input.txt", "w", stdout);
fclose(stdout);
} int a[];
void solve(int l, int r) {
if (l > r) return;
int x = l;
for (int i = l; i <= r; i++) {
if (a[i] < a[x]) x = i;
}
cout << a[x] << endl;
solve(l, x - );
solve(x + , r);
} int main() {
#ifndef ONLINE_JUDGE
freopen("input.txt", "r", stdin);
#endif
//makedata();
std::ios::sync_with_stdio(), cin.tie();
int n;
cin >> n;
for (int i = ; i <= n; i++) cin >> a[i];
solve(, n);
return ;
}

假期计划

#pragma comment(linker, "/STACK:102400000,102400000")
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<vector>
#include<algorithm>
#include<iostream>
#include<map>
#include<queue>
#include<stack>
#include<string>
#include<functional>
#include<math.h>
//#include<bits/stdc++.h>
using namespace std;
typedef long long lint;
typedef vector<int> VI;
typedef pair<int, int> PII;
typedef queue<int> QI; void makedata() {
freopen("input.txt", "w", stdout);
fclose(stdout);
} class AandC {
public:
long long *fac, *inv, *f;
long long mod;
AandC(long long m, int n) {
mod = m;
fac=(long long *)malloc((n) * sizeof(long long));
inv=(long long *)malloc((n) * sizeof(long long));
f=(long long *)malloc((n) * sizeof(long long));
fac[] = fac[] = inv[] = inv[] = f[] = f[] = ;
for (int i = ; i < n; i++) {
fac[i] = fac[i - ] * i % mod;
f[i] = (mod - mod / i) * f[mod % i] % mod;
inv[i] = inv[i - ] * f[i] % mod;
}
}
//choose b from a
long long A(int a, int b) {
return fac[a] * inv[a - b] % mod;
}
long long C(int a, int b) {
return fac[a] * inv[b] % mod * inv[a - b] % mod;
}
};
const lint mod = ;
AandC ac(mod,); int main() {
#ifndef ONLINE_JUDGE
freopen("input.txt", "r", stdin);
#endif
//makedata();
std::ios::sync_with_stdio(), cin.tie();
int n, a, b;
cin >> n >> a >> b;
lint ans = ;
for (int i = ; i < n; i++) {
if (i > b || n - i > a || n - i < ) continue;
ans += (n - i - ) * ac.C(b - , i - ) % mod * ac.C(a - , n - i - ) % mod * ac.A(a, a) % mod * ac.A(b, b) % mod;
ans %= mod;
}
cout << ans << endl;
return ;
}

矩阵深度

[hihocoder][Offer收割]编程练习赛48的更多相关文章

  1. hihocoder [Offer收割]编程练习赛4

    描述 最近天气炎热,小Ho天天宅在家里叫外卖.他常吃的一家餐馆一共有N道菜品,价格分别是A1, A2, ... AN元.并且如果消费总计满X元,还能享受优惠.小Ho是一个不薅羊毛不舒服斯基的人,他希望 ...

  2. hihocoder [Offer收割]编程练习赛61

    [Offer收割]编程练习赛61 A:最小排列 给定一个长度为m的序列b[1..m],再给定一个n,求一个字典序最小的1~n的排列A,使得b是A的子序列. 贪心即可,b是A的子序列,把不在b中的元素, ...

  3. ACM学习历程—Hihocoder [Offer收割]编程练习赛1

    比赛链接:http://hihocoder.com/contest/hihointerview3/problem/1 大概有一个月没怎么打算法了.这一场的前一场BC,也打的不是很好.本来Div1的A和 ...

  4. [Offer收割]编程练习赛48

    题目1 : 折线中点 时间限制:10000ms 单点时限:1000ms 内存限制:256MB 描述 给定平面上N个点P1, P2, ... PN,将他们按顺序连起来,形成一条折线. 请你求出这条折线的 ...

  5. hihocoder offer收割编程练习赛8 C 数组分拆

    思路:(引自bfsoyc的回答:http://hihocoder.com/discuss/question/4160) 动态规划.状态dp[i]表示 前i个数的合法的方案数,转移是 dp[i] = s ...

  6. hihocoder [Offer收割]编程练习赛18 C 最美和弦(dp)

    题目链接:http://hihocoder.com/problemset/problem/1532 题解:一道基础的dp,设dp[i][j][k][l]表示处理到第几个数,当前是哪个和弦错了几次初始x ...

  7. hihoCoder [Offer收割]编程练习赛3 D子矩阵求和

    子矩阵求和 http://hihocoder.com/discuss/question/3005 声明一下: n是和x一起的,m是和y一起的 x是横着的,y是纵着的,x往右为正,y往下为正 (非常反常 ...

  8. hihocoder [Offer收割]编程练习赛52 D 部门聚会

    看了题目的讨论才会做的 首先一点,算每条边(u, v)对于n*(n+1)/2种[l, r]组合的贡献 正着算不如反着算 哪些[l, r]的组合没有包含这条边(u, v)呢 这个很好算 只需要统计u这半 ...

  9. hihocoder [Offer收割]编程练习赛14

    A.小Hi和小Ho的礼物 谜之第1题,明明是第1题AC率比C还要低.题目是求在n个不同重量袋子选4袋,2袋给A,2袋给B,使2人获得重量相同,求问方案数. 我也是一脸懵b...o(n2)暴力枚举发现把 ...

随机推荐

  1. vue使用插槽分发内容slot的用法

    将父组件的内容放到子组件指定的位置叫做内容分发 //在父组件里使用子组件 <son-tmp> <div>我是文字,我需要放到son-tmp组件里面制定的位置</div&g ...

  2. H3C交换机配置学习随笔

    1.交换机配置VLAN vlan 创建VLAN: <h3c>system-view [h3c]vlan 10 删除ID为10的vlan:undo vlan 10 注:任何型号的交换机,都支 ...

  3. 15.5.3 【Task实现细节】状态机的结构

    状态机的整体结构非常简单.它总是使用显式接口实现,以实现.NET 4.5引入的 IAsync StateMachine 接口,并且只包含该接口声明的两个方法,即 MoveNext 和 SetState ...

  4. LA 4327

    Panagola, The Lord of city F likes to parade very much. He always inspects his city in his car and e ...

  5. php第二节课

    基础语法 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3 ...

  6. [luogu2319 HNOI2006] 超级英雄 (匈牙利算法)

    传送门 Description 现在电视台有一种节目叫做超级英雄,大概的流程就是每位选手到台上回答主持人的几个问题,然后根据回答问题的多少获得不同数目的奖品或奖金.主持人问题准备了若干道题目,只有当选 ...

  7. HTML表示RGB颜色的方法

    NAME:red,orange,yellow,green,cyan,blue,purple RGB:rgb(r,g,b) RGBA:rgba(r,g,b,a) r.g.b.a取值范围为:0-255 H ...

  8. canvas实现圆框图片

    作者:issac_宝华链接:http://www.jianshu.com/p/9a6ee2648d6f來源:简书 在html中做圆框图片很容易,只需要简单的 border-radius: 50%; 当 ...

  9. Python列表、集合与字典(3)

    目录 一.列表 二.集合 三.字典 一.列表 1. 列表初识   列表的使用为处理特定顺序排列的数据提供了便利,列表元素可以是字母.数字或者其他信息,同时所加元素之间不存在任何关系.   在Pytho ...

  10. centos 7.2 安装php56-xml

    linux下, 使用thinkphp的模板标签,如 eq, gt, volist defined, present , empty等 标签时, 报错: used undefined function ...