3 条题解

  • 1
    #include<bits/stdc++.h>
    using namespace std;
    const int N=1e3+10;
    int t,n;
    bool a[N];
    int main()
    {
        cin>>t;
        a[3]=1;
        a[7]=1;
        for(int i=4;i<=100;i++)
        {
        	for(int j=1;j<i;j++)
        	{
        		if(a[j]==1 && (j+3==i || j+7==i) )
        		{
        			a[i]=1;
        		}
        	}
        }
        while(t--)
        {
        	cin>>n;
        	if(a[n])
        	{
        		cout<<"YES\n";
        	}
        	else
        	{
        		cout<<"NO\n";
        	}
        }
    }
    

    递推

    • 1
      @ 2023-5-13 6:40:16

      身为蒟蒻只能用枚举(心碎)

      #pragma GCC optimize(2)
      #include<iostream>
      #include<iomanip>
      #include<stdio.h>
      #include<math.h>
      #include<string>
      #include<string.h>
      #include<sstream>
      #include<algorithm>
      #include<fstream>
      #include<stdlib.h>
      #include<time.h>
      #define IOS ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
      using namespace std;
      typedef long long ll;
      const int N=1e5+10;
      const int INF=0x3f3f3f3f;
      int n,x;
      bool check(int x){
      	for(int i=0;i*3<=x;i++){
      		int j=(x-i*3)/7;
      		if(i*3+j*7==x)return true;
      	}
      	return false;
      }
      int main(){
      	IOS;
      	cin>>n;
      	while(n--){
      		cin>>x;
      		if(check(x))cout<<"YES\n";
      		else cout<<"NO\n";
      	}
      	return 0;
      }
      
      • 0
        @ 2023-12-9 13:43:26

        最短代码 通过枚举发现只有1,2,4,5,8,11 不能装下; 直变水题

        #include <iostream>//#2303,12.2,2023
        #include <cmath>
        #include <iomanip>
        using namespace std;
        int n,m,ans,num;
        int main()
        {
            cin>>n;
            for(int i=1;i<=n;i++)
            {
                cin>>m;
                if(m==1||m==2||m==4||m==5||m==8||m==11)
                    cout<<"NO"<<endl;
                else
                    cout<<"YES"<<endl;
            }
        
        return 0;
        
        }
        
        • 1

        信息

        ID
        2303
        时间
        1000ms
        内存
        256MiB
        难度
        8
        标签
        递交数
        623
        已通过
        97
        上传者