4 条题解

  • 3
    @ 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;
    }
  • 1
    @ 2025-1-11 11:21:44

    思路

    暴力出奇迹,打表出省一

    解题方法

    一边判断一边走

    复杂度

    全是判断包是O(1)

    时间复杂度:O(1)O(1)

    空间复杂度: O(1)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;
    }
    
    • 1
      @ 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;
      }
      • -5
        @ 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
        标签
        递交数
        430
        已通过
        283
        上传者