UVA-11809
来源:互联网 发布:安卓游戏编程教程 编辑:程序博客网 时间:2024/06/16 05:23
水题。。理解题意之后打表输出即可。
然后题目大意就是帮你复习一遍计算机内部浮点数储存方式,像我这种还没学习过的人看题目真是看的云里雾里= =。
另:小数精度问题,在判别前记得要加0.5。
Solution:
#include <algorithm>#include <iostream>#include <utility>#include <cstring>#include <cstdlib>#include <cstdio>#include <sstream>#include <deque>#include <string>#include <vector>#include <cmath>#include <stack>#include <queue>#include <map>#include <set>using namespace std;#define mm(a,i) memset(a, i, sizeof(a));#define LL long long#define Mod 1000000007#define SC_C(s) scanf("%c", &s)#define SC(a) scanf("%d", &a)#define SCC(a,b) scanf("%d %d", &a, &b)#define SCCC(a,b,c) scanf("%d %d %d", &a, &b, &c)#define FXA(i,a,n) for(i=a; i<n; i++)#define FDA(i,a,n) for(i=a; i>n; i++)#define FXDA(i,a,n) for(i=a; i<=n; i++)#define FDDA(i,a,n) for(i=a; i>=n; i++)#define FXB(i,a,n) for(i=a; i<n; i--)#define FDB(i,a,n) for(i=a; i>n; i--)#define FXDB(i,a,n) for(i=a; i<=n; i--)#define FDDB(i,a,n) for(i=a; i>=n; i--)#define PF(n) printf("%d\n", n);#define PFF(n,m) printf("%d %d\n", n, m);#define PFFF(x,y,z) printf("%d %d %d\n", x, y, z);#define PF_Case(i) printf("Case %d:\n",i);#define PF_C(i) printf("%c:\n",i);#define PF_L(x) printf("%I64d\n",x);#define IN freopen("D:\\in.txt","r",stdin);#define ENT printf("\n");#define MAX(a,b) a>b?a:b#define MIN(a,b) a<b?a:b int maxx = 999999999; a<b?a:bint maxx = 999999999;int minn = -999999999;bool flag;int i,j,k,T,ans,sum,m,n,cnt;double stdm[12], a=0.0;int b=0;const double sett = 1e-13;bool read() { string s; if(!(cin>>s) || s=="0e0") return false; s[17]=' '; stringstream ss(s); ss>>a>>b; return true;}void solve(){ long double k,l; int m=0,e=0; for(int i=0;i<12;i++){ k = a/stdm[i]; l = log2((log10(k)+b)*log2(10.0)+1); e = (int)floor(l+0.5); if(fabs(e-l)<sett){ m=i; break; } } cout<<m<<" "<<e<<endl; return ;}int main(){ #ifndef ONLINE_JUDGE IN #endif // ONLINEJUDGE for(int i=0;i<12;i++) stdm[i]=1-pow(0.5,i+1); while(read()){ solve(); } return 0; 0;}
0 0
- uva 11809
- UVA-11809
- UVA 11809
- UVa 11809 浮点数
- UVa 11809 (math)
- uva
- UVA
- UVA
- UVA
- uva
- UVA
- UVA
- UVA
- UVA
- UVA
- UVA
- UVA
- UVA
- Android事件总线 Otto框架使用
- UVA 10129 Play on Words
- hdoj1711(KMP模板题)Number Sequence
- 【codeforces】601A—— The Two Routes
- uva 10641 dp
- UVA-11809
- jdk安装 系统找不到文件C:\ProgramData\Oracle\Java\javapath\java.exe
- DOM节点操作
- Thinking in Java --日志初步学习
- @DBRef---------------springMVC
- JVM-java内存区域与内存溢出异常
- bfs转弯问题
- poj1837
- 如何判断只能是数字,英文字母和中文 及获取androidmanifest.xml中meta-data的配置