题意:给一个小于1的小数,输出该小数的二进制表示,如果是无限的输出NO
思路:知道小数二进制的转换后直接,大数乘法xjb模拟就是了
AC代码:
#include "iostream"#include "string.h"#include "stack"#include "queue"#include "string"#include "vector"#include "set"#include "map"#include "algorithm"#include "stdio.h"#include "math.h"#define ll long long#define bug(x) cout<<<" "<<"UUUUU"< M;string Multiply(string s,int x){ reverse(s.begin(),s.end()); int cmp=0; for(int i=0;i >t; while(t--){ cin>>ch; s=ch+2; ans[0]='0',ans[1]='.'; int l=1,flag=0; if(s[s.size()-1]!='5') flag=1; M.clear(); while(s.size()>0){ int ha=BKDRHash(s); if(M[ha] || flag){ flag=1; break; } M[ha]=1; int l0=s.size(); s=Multiply(s,2); int l1=s.size(); int f=0; for(int i=0; i