ural 1011 Conductors
来源:互联网 发布:星际皆知我爱你百度云 编辑:程序博客网 时间:2024/05/18 20:50
题意:(差点没看懂题目。。。囧)前面那个好像是说那句话有两种理解。。。一种是。。。售票员在公共汽车上裸奔?还有一种是。。。。?。。。(无关紧要- -)
给精确到0.01的p和q,求最小的i,使得存在整数x,i*p < x < i*q。
思路:(这道题我WA了好多次我会说麽。。。)我还是不晓得怎么弄精度的东西。。。希望高人指点啊。。。我的做法是。。。由于p和q是精确到0.01,我就把p和q都扩大到100倍。。。这样就没有浮点误差了吧干!剩下的就好说了。。。
#include <cstdio>#include <cstring>#include <cstdlib>int p, q;int solve(){int l, h;for (int i = 1; i <= 10000; ++ i){l = i*p;h = i*q-1;if (l/10000 != h/10000) return i;}return 10000;}bool isdigit(char c) { return (c>='0' && c<='9'); }int func(){char data[10];scanf("%s",data);int ret=0, i;for (i = 0; data[i]!='.'&&data[i]!='\0'; ++ i) ret = ret*10 + data[i]-'0';ret *= 100;if (strlen(data)-i == 2) ret += (data[i+1]-'0')*10;else if (strlen(data)-i == 3) ret += (data[i+1]-'0')*10 + data[i+2]-'0';return ret;}void input(){p = func();q = func();}int main(){input();printf("%d\n", solve());system("pause");}
- ural 1011 Conductors
- URAL 1011 Conductors
- URAL 1011|Conductors|暴力
- [解题报告]Ural 1011 Conductors
- ural 1011. Conductors 打表
- 1011. Conductors
- URAL1011:Conductors
- URAL1011 - Conductors - 水题
- 水题Conductors URAL1011
- ironic multi conductors realization
- URAL 1011(枚举)
- URAL
- 【ural】
- URAL
- URAL
- URAL
- URAL
- URAL
- 第五次课后作业
- 两个DropDownList的联动-----ASP.NET
- 免安装版mysql使用
- ural 1008 Image Encoding
- 浅谈问题解决模型
- ural 1011 Conductors
- Win7系统下利用U盘安装Ubuntu_12.04实现双系统教程
- 深入理解Java内存模型(三)——顺序一致性
- 开归档的数据库,使用append 插入是否该表可以不写日志?
- 2013年微软智在未来暑期实习生招聘部分考题
- 项目四
- 疑问
- activity启动之应用侧分析
- C语言--------------字符串小程序练习(一)