- 判断 n 是否为质数 [1]
CE*114514
- 2023-12-12 19:33:27 @
啊啊啊啊要疯了
3 comments
-
经开一中2026届11班关泽瑞 LV 6 @ 2023-12-12 20:06:05
很难吗???????????????????????????????????????????????
-
2023-12-12 20:05:15@
#include <bits/stdc++.h> using namespace std; bool zhi(int n)//自定义判断质数函数 { if(n==1)return false; for(int i=2;i<n;i++) { if(n%i==0&&n!=i)return false; } return true; } int main() { int a; cin>>a; if(zhi(a)==true)cout<<"YES"; else cout<<"NO"; return 0; }
-
2023-12-12 20:03:59@
so
- 1
Information
- ID
- 571
- Time
- 1000ms
- Memory
- 256MiB
- Difficulty
- 7
- Tags
- # Submissions
- 325
- Accepted
- 80
- Uploaded By