[c] poj1003 hangover
2015-08-24 23:54
260 查看
http://poj.org/problem?id=1003
水题,不说啥了
#include<iostream>
#include<stdio.h>
using namespace std;
int main()
{
int n=400;
double a[400]={0};
double x=2.0;
for(int i=1;i<n;i++){
a[i]+=a[i-1]+1.0/x;
x+=1.0;
}
double s;
while(cin>>s){
if(s<0.001) break;
for(int i=0;i<n;i++){
if(s<a[i]){
printf("%d card(s)\n",i);
break;
}
}
}
return 0;
}
水题,不说啥了
#include<iostream>
#include<stdio.h>
using namespace std;
int main()
{
int n=400;
double a[400]={0};
double x=2.0;
for(int i=1;i<n;i++){
a[i]+=a[i-1]+1.0/x;
x+=1.0;
}
double s;
while(cin>>s){
if(s<0.001) break;
for(int i=0;i<n;i++){
if(s<a[i]){
printf("%d card(s)\n",i);
break;
}
}
}
return 0;
}
相关文章推荐
- wordpress第一天
- leetcode: (171) Excel Sheet Column Number
- Set a static file on django
- 服务程序中侦测用户logon和logoff消息
- Go web之旅(路由篇)
- Google Alphabet
- Dragon Balls 3635 (并查集求深度) 好题
- Round A APAC Test 2016 Problem A. Googol String
- STL - vector algorithm
- google hosts google翻译ip
- 杭电3635-Dragon Balls-并查集之路径压缩
- django RESTful研究一环境搭建和理解RESTful
- UVA 11971 Polygon 多边形(连续概率)
- 第一个基于Django的页面: Hello World
- django model filter 条件过滤,及多表连接查询、反向查询
- go 的 time ticker 设置定时器
- Django项目 实例 日记
- Algorithms—235.Lowest Common Ancestor of a Binary Search Tree
- Django 文件下载功能
- 搭建GoldenGate的单向复制环境