Run ID 作者 问题 语言 测评结果 分数 时间 内存 代码长度 提交时间
129126 刘国洋 求素数 C++ 编译错误 0 0 MS 0 KB 462 2024-01-26 16:21:17

Tests(0/0):


方法1:常规遍历 #include <stdio.h> int main() { int i, no; unsigned long counter = 0; for (no = 2; no <= 1000; no++) { for (i = 2; i < no; i++) { counter++; if (no % i == 0) break; } //如果最终的i==no,说明一定是质数 if (no == i) printf("%d\n", no); } printf("乘除运算的次数:%lu\n", counter); return 0; }


测评信息: