求条(问)abc361f WA on #32
  • 板块学术版
  • 楼主Walrus
  • 当前回复0
  • 已保存回复0
  • 发布时间2024/7/7 13:39
  • 上次更新2024/7/7 13:41:50
查看原帖
求条(问)abc361f WA on #32
908424
Walrus楼主2024/7/7 13:39

我也看到有其他人 WA 这个点,听说是卡精度,所以 sqrtl 和 sqrt 有什么区别?

#include <bits/stdc++.h>
#define rep(i, j, k) for(int i = j; i <= k; ++i)
#define inf 0x3fffffff
#define pb push_back
#define PII pair<int, int>
#define fir first
#define sec second
#define int long long

using namespace std;
const int N = 2e5 + 5;

int n, k, flag, ans;
set<int> st;

inline int read() {
	int x = 0, f = 1;
	char c = getchar();
	while(!isdigit(c)) c = getchar();
	while(isdigit(c)) x = x * 10 + c - '0', c = getchar();
	return x;
}

void write(int x) {
	if(x > 9) write(x / 10);
	putchar(x % 10 + '0');
}

signed main() {
	ios::sync_with_stdio(0);
	cin.tie(nullptr), cout.tie(nullptr);

	n = read(); st.insert(1);
	long long l = cbrt(n) + 1, r = sqrt(n);
	
	rep(i, 2, l) {
		__int128 x = i * i;
		if(x > n) break;
		rep(j, 2, n) {
			x *= i;
			if(x > n) break;
			if(!st.count(x)) ++ans, ans -= (int)sqrtl(x) * (int)sqrtl(x) == x;
			st.insert(x);
		}
	}
	write((int)sqrt(n) + ans);
}
2024/7/7 13:39
加载中...