对数据大于一万的就筛到该数的平方根
#include <stdbool.h>
#include <stdio.h>
#include<math.h>
#define LL long long
#define IN freopen("in.txt", "r", stdin)
#define OUT freopen("out.txt", "w", stdout)
#define scan(x) scanf("%d", &x)
#define sqr(x) (x) * (x)
#define f(i, a, b) for (int i = a; i <= b; i++)
#define pn(x) printf("%d\n", x)
#define pr1(x) printf("Case %d: ", x)
#define pn1(x) printf("Case %d:\n", x)
#define pr2(x) printf("Case #%d: ", x)
#define pn2(x) printf("Case #%d:\n", x)
#define lowbit(x) (x & (-x))
#define MAXN 200000001
int prime[10000000];
bool vis[MAXN];
int cnt = 0;
void Euler_prime(int n)
{
vis[1] = 1;
for (int i = 2; i <= n; ++i)
{
if (!vis[i])
prime[cnt++] = i;
for (int j = 0; j < cnt; ++j)
{
if (i * prime[j] > n) //判断是否越界
break;
vis[i * prime[j]] = 1; //筛数
if (i % prime[j] == 0)
break;
}
}
}
int main()
{
int n,x;
scan(n);
if(n>10000){
x = (int)sqrt(n);
}
else
x = n;
Euler_prime(x);
f(i, 0, cnt)
{
if (n % prime[i] == 0)
{
printf("%d", n/prime[i]);
return 0;
}
}
return 0;
}