7 条题解
-
1
//这题目有点坑,是输出YE5或N0 #include <iostream> using namespace std; int main() { int n;//创建一个储存那个数的变量 cin>>n; int b=2;//看b是不是n的因数 int z=0;//记录状态 for (int i=1;i<=n-2;i++) { if (n%b!=0)//如果b不是n的因数 { b+=1; z=0;//状态为零 } else { z=1;//如果b是n的因数,状态为1 break;//别忘了结束循环 } } if (n==1 || n==2)//处理一下特殊情况 cout<<"N0"; else if(z==0)//状态为0,就是质数 cout<<"YE5"; else if(z==1)//状态为1,就是合数 cout<<"N0"; return 0; }//这输出谁定的?站出来!保证不揍你!
-
0
是ys5 和 n0啊!!! 谁出的题啊
#include<iostream> #include<iomanip> #include<cmath> using namespace std; int main() { int n,s=0; cin>>n; if (n==1) { cout<<"N0"; s+=1; } for (int i=2;i<n;i++) { if (n%i==0) { cout<<"N0"; s+=1; break;///防止超时 } if (i*i>n) { break;///防止超时*2 } } if (s==0) { cout<<"YE5"; } return 0; }
- 1
信息
- ID
- 173
- 时间
- 1000ms
- 内存
- 256MiB
- 难度
- 7
- 标签
- 递交数
- 499
- 已通过
- 121
- 上传者