UVa-11809 - Floating-Point Numbers
2015-02-26 23:07
423 查看
参考了http://blog.csdn.net/xyqcl/article/details/40011009
[code]#include<iostream> #include<cstdio> #include<cmath> using namespace std; int main() { double aa[15][35]={}; int bb[15][35]={}; for(int m=0;m<=9;m++) { for(int e=1;e<=30;e++) { double tc=1-pow(2,-m-1); long long td=pow(2,e)-1; double t=log(tc)/log(10)+td*log(2)/log(10); bb[m][e]=t; aa[m][e]=pow(10,t-bb[m][e]); } } char s[30]={}; while(cin>>s&&s[0]-'0') { double a; int b; s[17]=' '; sscanf(s,"%lf %d",&a,&b); for(int m=0;m<=9;m++) for(int e=1;e<=30;e++) if(fabs(aa[m][e]-a)<1e-6&&b==bb[m][e]) cout<<m<<" "<<e<<endl; } }
相关文章推荐
- UVA - 11809 Floating-Point Numbers
- UVA 11809 Floating-Point Numbers
- uva 11809 - Floating-Point Numbers(浮点数)
- UVa 11809 Floating-Point Numbers
- UVA 11809 - Floating-Point Numbers【浮点数】
- UVA 11809 Floating-Point Numbers(暴力)
- UVa11809-Floating-Point Numbers
- UVA-11809 Floating-Point Numbers
- UVA 11809 Floating-Point Numbers
- uva - 11809 - Floating-Point Numbers
- UVA - 11809 Floating-Point Numbers
- UVa 11809 Floating-Point Numbers (浮点数)
- UVA 11809 - Floating-Point Numbers
- Uva - 11809 - Floating-Point Numbers
- uva 11809 Floating-Point Numbers
- UVA11809 - Floating-Point Numbers
- Uva - 11809 - Floating-Point Numbers
- 【习题 3-12 UVA - 11809】Floating-Point Numbers
- UVa 11809 Floating-Point Numbers
- UVA - 11809 Floating-Point Numbers