- 质因数分解
- 2015-01-24 01:28:33 @
测试数据 #0: Accepted, time = 0 ms, mem = 448 KiB, score = 10
测试数据 #1: Accepted, time = 0 ms, mem = 448 KiB, score = 10
测试数据 #2: Accepted, time = 0 ms, mem = 440 KiB, score = 10
测试数据 #3: Accepted, time = 0 ms, mem = 440 KiB, score = 10
测试数据 #4: Accepted, time = 0 ms, mem = 440 KiB, score = 10
测试数据 #5: Accepted, time = 0 ms, mem = 444 KiB, score = 10
测试数据 #6: TimeLimitExceeded, time = 1014 ms, mem = 436 KiB, score = 0
测试数据 #7: TimeLimitExceeded, time = 1014 ms, mem = 436 KiB, score = 0
测试数据 #8: TimeLimitExceeded, time = 1014 ms, mem = 432 KiB, score = 0
测试数据 #9: TimeLimitExceeded, time = 1014 ms, mem = 436 KiB, score = 0
TimeLimitExceeded, time = 4056 ms, mem = 448 KiB, score = 60
6 条评论
-
痞子熊 LV 7 @ 2017-07-31 18:17:41
从第六组开始数据就会变得异常大,看题要求。
-
2016-11-15 20:48:00@
#include <iostream>
#include <cmath>
using namespace std;bool isPrime(int n)
{
if (n == 1)
return false;
for (int i=2; i<=sqrt(n)+1; i++)
if (n % i == 0 && i < n)
return false;
return true;
}int main()
{
int n;
cin>>n;
int min = 1;
while (!(isPrime(min) && n % min == 0))
min++;
int max = n / min;
cout<<max<<endl;return 0;
} -
2015-12-02 20:44:59@
对比知变态
测试数据 #0: Accepted, time = 0 ms, mem = 612 KiB, score = 10
测试数据 #1: Accepted, time = 0 ms, mem = 616 KiB, score = 10
测试数据 #2: Accepted, time = 0 ms, mem = 616 KiB, score = 10
测试数据 #3: Accepted, time = 0 ms, mem = 612 KiB, score = 10
测试数据 #4: Accepted, time = 0 ms, mem = 612 KiB, score = 10
测试数据 #5: Accepted, time = 0 ms, mem = 612 KiB, score = 10
测试数据 #6: TimeLimitExceeded, time = 1014 ms, mem = 612 KiB, score = 0
测试数据 #7: TimeLimitExceeded, time = 1014 ms, mem = 616 KiB, score = 0
测试数据 #8: TimeLimitExceeded, time = 1014 ms, mem = 612 KiB, score = 0
测试数据 #9: TimeLimitExceeded, time = 1014 ms, mem = 616 KiB, score = 0
TimeLimitExceeded, time = 4056 ms, mem = 616 KiB, score = 60
var
n,i:longint;begin
read(n);
for i:=n-1 downto 2 do
if n mod i=0 then
begin
writeln(i);
break;
end;
end.
测试数据 #0: Accepted, time = 0 ms, mem = 612 KiB, score = 10
测试数据 #1: Accepted, time = 0 ms, mem = 612 KiB, score = 10
测试数据 #2: Accepted, time = 0 ms, mem = 608 KiB, score = 10
测试数据 #3: Accepted, time = 0 ms, mem = 612 KiB, score = 10
测试数据 #4: Accepted, time = 0 ms, mem = 616 KiB, score = 10
测试数据 #5: Accepted, time = 0 ms, mem = 612 KiB, score = 10
测试数据 #6: Accepted, time = 15 ms, mem = 612 KiB, score = 10
测试数据 #7: Accepted, time = 0 ms, mem = 612 KiB, score = 10
测试数据 #8: Accepted, time = 0 ms, mem = 612 KiB, score = 10
测试数据 #9: Accepted, time = 15 ms, mem = 616 KiB, score = 10
Accepted, time = 30 ms, mem = 616 KiB, score = 100
var
n,i:longint;begin
read(n);
for i:=2 to trunc(sqrt(n)) do
if n mod i=0 then
begin
writeln(n div i);
break;
end;
end. -
2015-09-26 18:13:54@
#include <iostream>
using namespace std;int main()
{int n;cin>>n;
for (int i=2;i*i<=n;i++)
if (n%i==0){ cout<<n/i;break;}
return 0;
} -
2015-02-01 12:01:31@
用 O(N)会死,试试O(sqrt (n))
-
2015-01-24 18:12:34@
如果你的代码中有一段是用来判断是否是质数的话,请尝试直接把这段代码去掉
- 1