链家模拟笔试第二题,求最小的第n个质数通过率为0

代码如下:
#include <stdio.h>
#include <iostream>
#include <math.h>
using namespace std;
bool isprime(long a)
{
	for (long i = 2; i <= sqrt(a); i++)
	{
		if (a%i == 0)
			return false;
	}
	return true;
}

int main()
{
	long n;
	while (cin >> n)
	{
		long result;
		long times = 0;
		for (long i = 2; times < n; i++)
		{
			if (isprime(i))
				times++;
			if (times == n)
				result = i;
		}
		cout << result << endl;
	}
	return 0;
}
不知道是哪里错了,求高人指点!!!本地可以通过,但是提交上去就是0%。难道链家的系统有什么潜规则吗?
全部评论
我的也是,不知道为什么
点赞 回复 分享
发布于 2017-08-31 16:48
一样,不知道什么原因,本地没问题
点赞 回复 分享
发布于 2017-08-31 16:19
这种写法。。不会超时吗,。。
点赞 回复 分享
发布于 2017-08-31 15:52

相关推荐

05-01 22:41
中南大学 Java
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客企业服务