【题目描述】
传送门
【题目分析】
终于把这道题做完了,之前一直连题意都看不懂。实在不行上网找了一下大佬的博客,看懂题意后自己写,发现读入很难处理,就又学习了一下大佬的读入方法,用的是C++里面的sstream,很巧妙。
主要就是一个打表。因为数据情况很少而且给定,所以打表就能解决。
还需要注意用到两边取对数,因为阶码部分的位数很大,根本不可能存下。
【AC代码】
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<algorithm>
#include<iostream>
#include<cmath>
#include<climits>
#include<queue>
#include<vector>
#include<set>
#include<map>
#include<sstream>
using namespace std;typedef long long ll;
const int INF=0x3f3f3f3f;
const int MAXN=35;
const double EPS=1e-6;
double A;
int B;int rnk[MAXN][MAXN];
int tot=0;
struct node
{int M,E;ll B;double A;
}a[MAXN*MAXN];ll quick_pow(ll a,ll b)
{ll ret=1;while(b){if(b%2) ret*=a;a*=a;b/=2;}return ret;
}const double LOG2=log10(2.0);void init()
{for(int i=0;i<=9;i++){for(int j=1;j<=30;j++){int tmp=quick_pow(2,1+i);double x=log10(tmp-1)-log10(tmp);double y=x+(quick_pow(2,j)-1)*LOG2;a[tot].M=i; a[tot].E=j;a[tot].B=(ll)(y);a[tot].A=pow(10,y-a[tot].B);tot++;}}
}int main()
{init();string in;while(cin>>in && in!="0e0"){for(string::iterator i=in.begin();i!=in.end();i++){if(*i=='e'){*i=' ';break;}}stringstream ss(in);ss>>A>>B;for(int i=0;i<tot;i++){if(fabs(a[i].A-A)<EPS && a[i].B==B){printf("%d %d\n",a[i].M,a[i].E);break; }}}return 0;
}