【链接】 我是链接,点我呀:)

【题意】

在这里输入题意

【题解】

$A*10^B = temp[M]*2^{2^E-1}$
两边取一下对数
得到
$lg_A+B = lg_{temp[M]} + (2^E-1)*lg_2$
这样就不至于算不出来啦。
打个表就好
防止爆精度。
加个long double.

【代码】

#include <bits/stdc++.h>
using namespace std; string s;
long double two[20];
long double temp[20];
long long temp2[70];
long double ans[100][100]; int main(){
#ifdef LOCAL_DEFINE
freopen("F:\\c++source\\rush_in.txt", "r", stdin);
#endif
two[1] = 0.5;
for (int i = 2;i <= 12;i++){
two[i] = two[i-1]*0.5;
}
temp[0] = two[1];
for (int i = 1;i <= 9;i++) temp[i] = temp[i-1] + two[i+1]; temp2[0] = 1;
for (int i = 1;i <= 30;i++) temp2[i] = temp2[i-1] * 2; for (int i = 0;i <= 9;i++){
double M = temp[i];
for (int j = 1;j <= 30;j++){
ans[i][j] = log10(M) + (temp2[j]-1)*log10(2);
}
} while (cin >> s){
int len = s.size();
for (int i = 0;i < len;i++) if (s[i]=='e') s[i] = ' ';
long double A;
long long B;
stringstream ss(s);
ss >> A >> B;
if (A==0 && B==0) break;
double temp = log10(A)+B;
bool fi = false;
for (int i = 0;!fi && i <= 9;i++)
for (int j = 1;!fi && j <= 30;j++)
if (fabs(ans[i][j]-temp)<1e-6){
printf("%d %d\n",i,j);
fi = true;
}
}
return 0;
}

【习题 3-12 UVA - 11809】Floating-Point Numbers的更多相关文章

  1. 最小正子序列(序列之和最小,同时满足和值要最小)(数据结构与算法分析——C语言描述第二章习题2.12第二问)

    #include "stdio.h" #include "stdlib.h" #define random(x) (rand()%x) void creat_a ...

  2. uva 10712 - Count the Numbers(数位dp)

    题目链接:uva 10712 - Count the Numbers 题目大意:给出n,a.b.问说在a到b之间有多少个n. 解题思路:数位dp.dp[i][j][x][y]表示第i位为j的时候.x是 ...

  3. UVA 10539 - Almost Prime Numbers(数论)

    UVA 10539 - Almost Prime Numbers 题目链接 题意:给定一个区间,求这个区间中的Almost prime number,Almost prime number的定义为:仅 ...

  4. UVA 11809 - Floating-Point Numbers

    数学太渣了,这道题反复参考了大神的博客,算是看懂了吧.博客原文  http://blog.csdn.net/crazysillynerd/article/details/43339157 算是个数学题 ...

  5. 【每日一题】 UVA - 11809 Floating-Point Numbers 阅读题+取对数处理爆double

    https://cn.vjudge.net/problem/UVA-11809 题意:很长orz 题解:算一下输入范围,发现用double是读不进来的,在这里wa了半天,(double 1e300  ...

  6. UVA 11481 - Arrange the Numbers 数学

    Consider this sequence {1, 2, 3, . . . , N}, as a initial sequence of first N natural numbers. You ca ...

  7. 【UVA - 136】Ugly Numbers(set)

    Ugly Numbers Descriptions: Ugly numbers are numbers whose only prime factors are 2, 3 or 5. The sequ ...

  8. UVA 10539 - Almost Prime Numbers 素数打表

    Almost prime numbers are the non-prime numbers which are divisible by only a single prime number.In ...

  9. comparison of floating point numbers with equality operator. possible loss of precision while rounding values

    double值由外部传入 private void Compare(double value) { string text; ) //小数位后保留2位 { //小数点后保留2位小数 text = st ...

随机推荐

  1. spring set注入

    上篇文章说到了构造器注入.可是有时候构造器注入并非非常好用,如今来看下set注入. 构造器注入博客地址:http://blog.csdn.net/luckey_zh/article/details/4 ...

  2. es6 --- var const let

    var  const   let  区别 今天第一次遇到const定义的变量,查阅了相关资料整理了这篇文章.主要内容是:js中三种定义变量的方式const, var, let的区别. 1. const ...

  3. Elasticsearch之REST

    REST 简介-定义 REST (REpresentation State Transfer)描述了一个架构样式的网络系统,比如 web 应用程序.它首次出现在 2000 年 Roy Fielding ...

  4. Exercise : Self-Taught Learning

    First, you will train your sparse autoencoder on an "unlabeled" training dataset of handwr ...

  5. 玲珑学院 1014 Absolute Defeat

    SAMPLE INPUT 3 2 2 2 1 1 5 1 4 1 2 3 4 5 4 10 3 1 2 3 4 SAMPLE OUTPUT 1 0 15 前缀和,每个元素都判断一下. #include ...

  6. at&&atq&&atrm---定时任务

    at放在 ls /var/spool/at/ 目录下 At的配置文件/etc/at.deny和/etc/at.allow 如果deny单独存在,则是deny以为的所有用户都可以使用at命令 如果all ...

  7. Java表单设计器orbeon点滴

    包含表单设计器和运行展现 一个完整的应用 页面部分都是使用XML和XHTML进行服务端的组合出来的,具体逻辑有些复杂 设计器缺少一个最常用的:repeat,如果需要只能手动编写代码(参考官方文档步骤有 ...

  8. View_01_LayoutInflater的原理、使用方法

    View_01_LayoutInflater的原理.使用方法 本篇博客是郭神博客Android视图状态及重绘流程分析,带你一步步深入了解View(一)的读书笔记的笔记. LayoutInflater简 ...

  9. AsyncTask源代码翻译

    前言: /** <p>AsyncTask enables proper and easy use of the UI thread. This class allows to perfor ...

  10. 重建一些被PHP7废弃的函数,

    <?php if(!function_exists('ereg')) { function ereg($pattern, $subject, &$matches = []) { retu ...