/ Randle /

记录详情

Accepted


  
# 状态 耗时 内存占用
#1 Accepted 3ms 312.0 KiB
#2 Accepted 2ms 308.0 KiB
#3 Accepted 1ms 320.0 KiB
#4 Accepted 1ms 316.0 KiB
#5 Accepted 1ms 316.0 KiB
#6 Accepted 1ms 316.0 KiB
#7 Accepted 1ms 312.0 KiB
#8 Accepted 1ms 308.0 KiB
#9 Accepted 1ms 316.0 KiB
#10 Accepted 1ms 316.0 KiB

代码

#include<bits/stdc++.h>
using namespace std;
long long f(long long n)
{
	long long l=0,r=0x7fffffff,mid,s,p;	
	while(l!=r){
		mid=(l+r)/2;
		s=(long long)mid*(mid+1)/2;
		if(s*2-1<n)l=mid+1;
		else r=mid;
	}
	s=1ll*l*(l+1)/2;
	p=l*2-1;
	if(s*2-1-l>=n)p--;
	return p;
}
int main()
{
	long long n;
	cin>>n;
	cout<<f(n);
	return 0;
}

信息

递交者
类型
递交
题目
整除 T2
题目数据
下载
语言
C++
递交时间
2017-10-05 14:44:52
评测时间
2017-10-05 14:44:52
评测机
分数
100
总耗时
19ms
峰值内存
320.0 KiB