杭电oj2064、2067、2068、2073、2076-2078、2080、2083-2085
2064 汉诺塔III
#include<stdio.h> int main(){
int n,i;
_int64 s[];
while(~scanf("%d",&n)){
s[] = ;
for(i=;i<=n;i++){
s[i] = *s[i-] + ;
}
printf("%I64d\n",s[n]);
} }
2067 小兔的棋盘
#include<stdio.h> int main(){
int n,i,k,j=;
_int64 s[] = {};
s[] = ;s[] = ;
for(i=;i<=;i++){
for(k=;k<i;k++){
s[i] += s[k]*s[i--k];
}
}
while(~scanf("%d",&n)){
if(n==-){break;} printf("%d %d %I64d\n",++j,n,s[n]*);
} }
卡特兰数的推导公式:
2068 RPG的错排
#include<stdio.h>
_int64 c(int a,int b){
_int64 mul1=,mul2=,i;
for(i=a;i>;i--){
mul1 *= i;
mul2 *= b;
b--;
}
return mul2/mul1;
} int main(){
int n,i;
_int64 s[],sum;
s[] = ;s[] = ;
for(i=;i<;i++){
s[i] = (i-)*(s[i-]+s[i-]);
}
while(~scanf("%d",&n)){
if(n==){break;}
sum = ;
for(i=;i<=n/;i++){
sum += c(i,n)*s[i];
}
printf("%I64d\n",sum); } }
2073 无限的路
#include<stdio.h>
#include<math.h>
double len(int x,int y){
int i,j;
double len = ,l;
double t = sqrt();
for(i=;i<x+y;i++){
len = len + t*i;
}
for(i=;i<x+y;i++){
len = len + sqrt(i*i+(i+)*(i+));
}
len = len + t*x;
return len;
} int main(){
int n,x1,y1,x2,y2;
while(~scanf("%d",&n)){
while(n--){
scanf("%d %d %d %d",&x1,&y1,&x2,&y2); printf("%.3lf\n",fabs(len(x2,y2)-len(x1,y1)));
}
} }
2076 夹角有多大(题目已修改,注意读题)
#include<stdio.h>
#include<math.h> int main(){
int n;
double h,m,s,anh,anm,an;
while(~scanf("%d",&n)){
while(n--){
scanf("%lf %lf %lf",&h,&m,&s);
if(h>){h = h-;}
anh = (h+(m+s/)/)*;
anm = (m+s/)*;
an = fabs(anh - anm);
if(an>){an = -an;}
printf("%d\n",(int)an);
}
} }
2077 汉诺塔IV
#include<stdio.h>
#include<math.h> int main(){
int n,i,m;
_int64 s[];
s[] = ;
s[] = ;
for(i=;i<;i++){
s[i] = s[i-]* + ;
}
while(~scanf("%d",&n)){
while(n--){
scanf("%d",&m);
printf("%I64d\n",s[m-]*+);
}
} }
2078 复习时间
#include<stdio.h>
#include<math.h> int main(){
int t,n,m,s[],i,j,temp,min;
while(~scanf("%d",&t)){
while(t--){
scanf("%d %d",&n,&m);
for(i=;i<=n;i++){
scanf("%d",&s[i]);
}
for(i=;i<=n;i++){
for(j=i+;j<=n;j++){
if(s[i]<s[j]){
temp = s[i];
s[i] = s[j];
s[j] = temp;
}
}
} printf("%d\n",(-s[n])*(-s[n]));
}
}
}
2080 夹角有多大II
#include<stdio.h>
#include<math.h>
#define PI 3.1415926 int main(){
int n;
double x1,x2,y1,y2,m,t;
while(~scanf("%d",&n)){
while(n--){
scanf("%lf %lf %lf %lf",&x1,&y1,&x2,&y2);
m = x1*x2 + y1*y2;
t = sqrt((x1*x1+y1*y1)*(x2*x2+y2*y2));
printf("%.2lf\n",acos(m/t)/PI*);
}
}
}
抄公式就完事了
2083 简易版之最短距离
#include<stdio.h>
#include<math.h> int main(){
int n,m,i,j,s[],temp,d;
while(~scanf("%d",&n)){
while(n--){
scanf("%d",&m);
for(i=;i<m;i++){
scanf("%d",&s[i]);
}
for(i=;i<m;i++){
for(j=i;j<m;j++){
if(s[i]>s[j]){
temp = s[i];
s[i] = s[j];
s[j] = temp;
}
}
}
d = ;
for(i=;i<m;i++){
d += abs(s[i] - s[m/]);
}
printf("%d\n",d);
}
}
}
2084 数塔
#include<stdio.h>
int max(int a,int b){
if(a>b){return a;}
else{return b;}
} int main(){
int s[][];
int dp[][];
int c,n,i,j;
while(~scanf("%d",&c)){
while(c--){
scanf("%d",&n);
for(i=;i<=n;i++){
for(j=;j<=i;j++){
scanf("%d",&s[i][j]);
}
}
for(i=n;i>;i--){
for(j=;j<=i;j++){
if(i==n){
dp[i][j] = s[i][j];
}else{
dp[i][j] = max(s[i][j]+dp[i+][j],s[i][j]+dp[i+][j+]);
}
}
}
printf("%d\n",dp[][]);
}
}
}
2085 核反应堆
#include<stdio.h> int main(){
int n,i;
_int64 h[],l[];
h[] = ;l[]=;
while(~scanf("%d",&n)){
if(n==-){break;}
for(i=;i<=n;i++){
h[i] = h[i-]* + l[i-]*;
l[i] = h[i-] + l[i-];
}
printf("%I64d, %I64d\n",h[n],l[n]);
} }
杭电oj2064、2067、2068、2073、2076-2078、2080、2083-2085的更多相关文章
- 杭电ACM题单
杭电acm题目分类版本1 1002 简单的大数 1003 DP经典问题,最大连续子段和 1004 简单题 1005 找规律(循环点) 1006 感觉有点BT的题,我到现在还没过 1007 经典问题,最 ...
- 杭电acm习题分类
专注于C语言编程 C Programming Practice Problems (Programming Challenges) 杭电ACM题目分类 基础题:1000.1001.1004.1005. ...
- 杭电ACM题目分类
基础题: 1000.1001.1004.1005.1008.1012.1013.1014.1017.1019.1021.1028.1029.1032.1037.1040.1048.1056.1058. ...
- 【转】杭电ACM试题分类
注:网上搜的 第一篇 1001 这个就不用说了吧1002 简单的大数1003 DP经典问题,最大连续子段和1004 简单题1005 找规律(循环点)1006 感觉有点BT的题,我到现在还没过1007 ...
- 杭电OJ分类
基础题:1000.1001.1004.1005.1008.1012.1013.1014.1017.1019.1021.1028.1029.1032.1037.1040.1048.1056.1058.1 ...
- 杭电oj题目分类
基础题:1000.1001.1004.1005.1008.1012.1013.1014.1017.1019.1021.1028.1029.1032.1037.1040.1048.1056.1058.1 ...
- 杭电ACM2076--夹角有多大(题目已修改,注意读题)
杭电ACM2076--夹角有多大(题目已修改,注意读题) http://acm.hdu.edu.cn/showproblem.php?pid=2076 思路很简单.直接贴代码.过程分析有点耗时间. / ...
- acm入门 杭电1001题 有关溢出的考虑
最近在尝试做acm试题,刚刚是1001题就把我困住了,这是题目: Problem Description In this problem, your task is to calculate SUM( ...
- 杭电acm 1002 大数模板(一)
从杭电第一题开始A,发现做到1002就不会了,经过几天时间终于A出来了,顺便整理了一下关于大数的东西 其实这是刘汝佳老师在<算法竞赛 经典入门 第二版> 中所讲的模板,代码原封不动写上的, ...
随机推荐
- scrapy之分布式
分布式爬虫 概念:多台机器上可以执行同一个爬虫程序,实现网站数据的分布爬取. 原生的scrapy是不可以实现分布式爬虫? a) 调度器无法共享 b) 管道无法共享 工具 scrapy-redis组件: ...
- stark组件(7):增加分页功能
效果图: 分页部分代码: # 1.分页处理 all_count = self.model_class.objects.all().count() query_params = request.GET. ...
- POJ:2385-Apple Catching(dp经典题)
Apple Catching Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 14311 Accepted: 7000 Descr ...
- 17 rest-framework框架的基本组件
序列化 创建一个序列化类 简单使用 开发我们的Web API的第一件事是为我们的Web API提供一种将代码片段实例序列化和反序列化为诸如json之类的表示形式的方式.我们可以通过声明与Django ...
- Spring---加载配置文件的几种方法(org.springframework.beans.factory.BeanDefinitionStoreException)
Spring中的几种容器都支持使用xml装配bean,包括:XmlBeanFactory ,ClassPathXmlApplicationContext ,FileSystemXmlApplicati ...
- 关于 package.json 和 package-lock.json 文件说明
package.json 在 Node.js 中,模块是一个库或框架,也是一个 Node.js 项目.Node.js 项目遵循模块化的架构,当我们创建了一个 Node.js 项目,意味着创建了一个模块 ...
- laravel5.5事件广播系统
目录 1. 定义广播事件 1.1 广播名称 1.2 广播数据 1.3 广播队列 1.4 广播条件 2. 频道授权 2.1 定义授权路由 2.2 定义授权回调 3. 对事件进行广播 3.1 可以使用ev ...
- 《Cracking the Coding Interview》——第17章:普通题——题目1
2014-04-28 21:45 题目:就地交换两个数,不使用额外的变量. 解法:没说是整数,我姑且先当整数处理吧.就地交换可以用加法.乘法.异或完成,其中乘法和加法都存在溢出问题.三种方法都不能处理 ...
- USACO Section2.3 Zero Sum 解题报告 【icedream61】
zerosum解题报告----------------------------------------------------------------------------------------- ...
- LightGBM的并行优化--机器学习-周振洋
LightGBM的并行优化 上一篇文章介绍了LightGBM算法的特点,总结起来LightGBM采用Histogram算法进行特征选择以及采用Leaf-wise的决策树生长策略,使其在一批以树模型为基 ...