L_0_Forever_LF的专栏

一个热爱OI的OIer

hdu5752 2016 Multi-University Training Contest 3 Sqrt Bo 解题报告

应号召.........又水了一发博客


题意大概是说,给你一个数n<=10^100,问你要多少次向下取整的开根才能使他变成1,如果超过5次就输出TAT



看完觉得挺水的,事实上确实不难

打个表,看哪些值是1-5次向下取整的开根能取到1的极限,然后判一下大小就没问题了

(判大小打错了卡我好久.........毕竟蠢)


#include<set>
#include<map>
#include<deque>
#include<queue>
#include<stack>
#include<cmath>
#include<ctime>
#include<vector>
#include<string>
#include<bitset>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<climits>
#include<complex>
#include<iostream>
#include<algorithm>
#define LL long long
using namespace std;

const int maxn = 110000;
int zero[maxn] = { 4,2,9,4,9,6,7,2,9,5 },len;
LL num[5] = {1,3,15,255,65535};
char st[maxn];

int count(  )
{
	LL tmp = 0;
	for( int i=0;i<len;i++ )
	{
		( tmp *= 10 ) += st[i]-'0';
	}
	if( tmp == 0 ) return 6;
	for( int i=0;i<5;i++ )
		if( tmp <= num[i] ) return i;
	return 5;
}

int main()
{
	while( scanf("%s",st) != EOF )
	{
		len = strlen( st );
		if( len > 10 ) printf("TAT\n");
		else if( len < 10 ) 
		{
			int  tmp = count();
			if( tmp > 5 ) printf("TAT\n");
			else printf("%d\n",tmp);
		}
		else
		{
			bool v = true;
			for( int i=0;i<len;i++ )
			{
				if( st[i]-'0' > zero[i] )
				{
					v = false;
					break;
				}
				if( st[i]-'0' < zero[i] ) break;
			}
			if( v )
			{
				int  tmp = count();
				if( tmp > 5 ) printf("TAT\n");
				else printf("%d\n",tmp);
			}
			else printf("TAT\n");
		}
	}
	
	return 0;
}


阅读更多
版权声明:...............转载说一声并注明出处qaq............... https://blog.csdn.net/L_0_Forever_LF/article/details/52353183
文章标签: C++ 多校 乱搞
上一篇hdu 5730 2016 Multi-University Training Contest 1 Shell Necklace 解题报告
下一篇快速傅里叶变换 FFT 板子
想对作者说点什么? 我来说一句

没有更多推荐了,返回首页

关闭
关闭