QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#317513#8167. Yet Another Simple Math Problemucup-team197#WA 0ms3600kbC++14634b2024-01-29 03:26:102024-01-29 03:26:10

Judging History

你现在查看的是最新测评结果

  • [2024-01-29 03:26:10]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3600kb
  • [2024-01-29 03:26:10]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define fi first
#define se second
ll n;
string aespa="TTPC";
string s[4];
ll m[4];
const int N=1e6+5;
ll f1[N],f2[N];
ll tot[N],acc[N];
ll ord[N];
ll g1,g2,gg;
ll gcd(ll x,ll y){
	if(y==0) return x;
	return gcd(y,x%y);
}
int main(){
	ios::sync_with_stdio(false);cin.tie(0);
	int t;cin >> t;
	while(t--){
		ll n;cin >> n;
		ll l=0,r=1e9;
		while(l!=r){
			ll mid=(l+r+1)/2;
			if(mid*mid<=n) l=mid;
			else r=mid-1;
		}
		ll ans=(l-1)*(l-1);
		ll frog=n-l*l;
		if(frog>=l) ans+=2*l+1;
		else ans+=2*frog;
		cout << ans << '\n';
	}
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 0
Wrong Answer
time: 0ms
memory: 3600kb

input:

3
6
1
101

output:

6
0
83

result:

wrong answer 1st words differ - expected: '4', found: '6'