UVA11526 代码帮交
  • 板块UVA11526 H(n)
  • 楼主xlpg0713
  • 当前回复3
  • 已保存回复3
  • 发布时间2023/5/9 20:36
  • 上次更新2023/10/23 16:14:17
查看原帖
UVA11526 代码帮交
680400
xlpg0713楼主2023/5/9 20:36
//注册失败
#include <bits/stdc++.h>
using namespace std;
int t,n,k,l;
signed main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	cin >> t;
	while(t --){
		cin >> n; k = n, l = 1;
		float xh = 0.5f * n, tmp = n;
		double xxh = 0.5 * n, ttmp;
		int i = *(int*)&tmp;
		i = 0x1fbd1df5 + (i >> 1);
		ttmp = *(float*)&i;
		ttmp = ttmp / 2 + xxh / ttmp;
		ttmp = ttmp / 2 + xxh / ttmp;
		n = ttmp / 2 + xxh / ttmp;
		long long res = 0;
		while(l <= n){
			int r = k / (k / l);
			res += 1ll * (r - l + 1) * (k / l);
			l = r + 1;
		}
		printf("%lld\n", 2*res - 1ll*n*n);
	}
	return 0;
}
2023/5/9 20:36
加载中...