3 条题解

  • 1
    @ 2024-9-23 12:21:00

    思路

    边取边模。

    时间复杂度:

    O(n)O(n)

    空间复杂度:

    O(1)O(1)

    Code

    #include<bits/stdc++.h>
    using namespace std;
    int n,m=1;
    int main(){
    	cin>>n;
    	if(n==0){cout<<"YES";return 0;}
    	for(int i=1;i<=n;i++){
    		m*=i;
    		m=m%(n+1);
    	}
    	if(m==0) cout<<"YES";
    	else cout<<"NO";
    	return 0;
    }
  • 0
    @ 2024-9-23 12:22:48

    思路

    打表。

    提前算好。

    时间复杂度:

    O(1)O(1)

    空间复杂度:

    O(1)O(1)

    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;
    }
    • -2
      @ 2024-9-18 12:37:02

      O(1)水过

      思路

      暴力出奇迹,打表出省一

      解题方法

      将0!~20!依次除1~21

      复杂度

      时间复杂度:

      O(1)O(1)

      空间复杂度:

      O(1)O(1)

      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
      标签
      递交数
      405
      已通过
      273
      上传者