5 条题解
-
0
思路
直接按照题目模拟即可。
但是,19!爆了int,不太确定是否爆了long long,所以就用__int128存了。
注意:__int128不支持输入输出,只能在64位编译器中使用,且是gcc/g++自带的类型。
时间复杂度:
空间复杂度:
Code
#include<bits/stdc++.h> using namespace std; int main(){ int n; __int128 sum=1; cin>>n; for(int i=2;i<=n;i++)sum*=i; if(sum%(n+1)==0)cout<<"YES"; else cout<<"NO"; return 0; }
-
0
思路
暴力出奇迹,打表出省一
解题方法
一边判断一边走
复杂度
全是判断包是O(1)
时间复杂度:
空间复杂度:
Code
#include<bits/stdc++.h> using namespace std; int main(){ int a; cin>>a; if(a==1)cout<<"NO"; else if(a==2)cout<<"NO"; else if(a==3)cout<<"NO"; else if(a==4)cout<<"NO"; else if(a==6)cout<<"NO"; else if(a==10)cout<<"NO"; else if(a==12)cout<<"NO"; else if(a==16)cout<<"NO"; else if(a==18)cout<<"NO"; else cout<<"YES"; return 0; }
-
-5
O(1)水过
思路
暴力出奇迹,打表出省一
解题方法
将0!~20!依次除1~21
复杂度
时间复杂度:
空间复杂度:
Code
#include<bits/stdc++.h> using namespace std; string s[20]={"YES","NO","NO","NO","NO", "YES","NO","YES","YES","YES", "NO","YES","NO","YES","YES", "YES","NO","YES","NO","YES"}; int main() { int n; cin>>n; cout<<s[n]<<endl; return 0; }
- 1
信息
- ID
- 54
- 时间
- 1000ms
- 内存
- 512MiB
- 难度
- 1
- 标签
- 递交数
- 443
- 已通过
- 290
- 上传者