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]*);
} }

卡特兰数的推导公式:

杭电oj2064、2067、2068、2073、2076-2078、2080、2083-2085-LMLPHP

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]);
} }
05-11 13:23