90 Wrong Answer
foo.cc: In function 'int main()': foo.cc:24:10: warning: format '%d' expects argument of type 'int*', but argument 2 has type 'long long int*' [-Wformat=] 24 | scanf("%d",&n); | ~^ ~~ | | | | | long long int* | int* | %lld foo.cc:24:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result] 24 | scanf("%d",&n); | ~~~~~^~~~~~~~~ foo.cc: In function 'int jjs(int)': foo.cc:20:9: warning: 'maxx' may be used uninitialized in this function [-Wmaybe-uninitialized] 20 | return maxx; | ^~~~
# | 状态 分数 | 耗时 | 内存占用 |
---|---|---|---|
#1 | Wrong Answer 0 | 1ms | 376 KiB |
#2 | Accepted 10 | 1ms | 376 KiB |
#3 | Accepted 10 | 1ms | 376 KiB |
#4 | Accepted 10 | 1ms | 376 KiB |
#5 | Accepted 10 | 1ms | 376 KiB |
#6 | Accepted 10 | 1ms | 380 KiB |
#7 | Accepted 10 | 1ms | 376 KiB |
#8 | Accepted 10 | 1ms | 504 KiB |
#9 | Accepted 10 | 1ms | 248 KiB |
#10 | Accepted 10 | 1ms | 376 KiB |
代码
#include<iostream>
#include<cmath>
using namespace std;
long long n;
bool js(int x)
{
if(x<=1)
return -1;
for(int i=2;i<=sqrt(x);i++)
if(x%i==0)
return false;
return true;
}
int jjs(int x)
{
int maxx;
for(int i=2;i<=x;i++)
if(x%i==0 && js(x/i))
maxx=max(maxx,x/i);
return maxx;
}
int main()
{
scanf("%d",&n);
printf("%d",jjs(n));
return 0;
}
信息
- 递交者
- 题目
- DJKS1060 最大质因子
- 比赛
- 等级考试一级阶段测试
- 语言
- C++ 11 (O2)
- 递交时间
- 2023-11-5 21:24:10
- 评测时间
- 2023-11-5 21:24:10
- 分数
- 90
- 总耗时
- 7ms
- 峰值内存
- 504 KiB