5 条题解
-
1TMR(只因{鸡}N太M) (TMR) LV 6 @ 2023-5-21 18:33:57
#include<iostream> #include<stdio.h> #include<string.h> #include<queue> #include<math.h> #include<vector> #include<algorithm> #include<iomanip> #include<stack> #include<cmath> using namespace std; bool pdss(int x){ bool flag=1; for(int i=2;i<=sqrt(x);i++){ if(x%i==0){ flag=0; break; } } return flag; } int main(){ int n; cin>>n; if(pdss(n)==1&&n>1)cout<<"Yes"; else cout<<"No"; }
-
12023-4-22 12:17:07@
#include<iostream> #include<cmath> using namespace std; int main() { int n; bool sum=1; cin>>n; for(int i=2;i<=sqrt(n);i++){ if(n%i0) { sum=0; break; } } if(sum1&&n>1)cout<<"Yes"; else cout<<"No"; return 0; }
-
12021-11-29 22:19:26@
注意n=1时要特判
n = int(input()) ok=1 for i in range(2,n): if i*i>n: break elif n%i==0: print("No") ok=0 break if(ok and n!=1): print('Yes') if n==1: print('No')
-
02023-5-21 18:20:24@
import math n=int(input()) zhishu=True if n==1: print("No") elif n==2 or n==3: print("Yes") elif n>3: i=3; while(i<=int(math.sqrt(n))+1): if n%i==0: print("No") zhishu=False break i+=2; if zhishu: print("Yes")
-
-22021-12-11 22:13:41@
import math n=int(input()) zhishu=True if n==1: print("No") elif n==2 or n==3: print("Yes") elif n>3: i=3; while(i<=int(math.sqrt(n))+1): if n%i==0: print("No") zhishu=False break i+=2; if zhishu: print("Yes")
- 1
信息
- ID
- 1366
- 时间
- 1000ms
- 内存
- 128MiB
- 难度
- 7
- 标签
- 递交数
- 570
- 已通过
- 111
- 上传者