POJ 1607
题意
在桌边放卡片,最多能超出桌边的距离
思路
画张图比较容易理解.
#include <iostream>
#include <iomanip>
#include <stdio.h>
using namespace std;
int main(){
int n;
double overhang = 0;
while(cin>>n){
cout<<"card"<<" overhang"<<endl;
for(int i = 1;i<=n;i = i+1){
overhang += 1.0/i;
}
overhang = overhang/2;
printf("%d %.3f\n", n, overhang);
}
return 0;
}
网友评论