你的QQ多少级了? (二分)swust oj#533

以前写的二分比较,但为了撑博客数豁出去了。。。!

#include <stdio.h>
int erfen(int t)
{
	return t*t+t*4; 
}
int main()
{
	long long t;
	while(scanf("%lld",&t)!=EOF&&t!=0)
	{
		int a=0,b=t;
		while(a<b)
		{
			int mid=(a+b)/2;
			if(erfen(mid)>t)
			b=mid;
			else 
			a=mid+1;
		}
		printf("%lld\n",a-1);
		printf("%d %d %d\n",(a-1)/16,(a-1)%16/4,(a-1)%16%4);
	}
	return 0;
}

题目出处

发布了24 篇原创文章 · 获赞 2 · 访问量 471

猜你喜欢

转载自blog.csdn.net/chineseherofeng/article/details/104672556