2 条题解

  • 0
    @ 2024-10-23 20:40:21

    我的可以AC

    #include<bits/stdc++.h>
    using namespace std;
    int main(){
    	freopen("da.in","r",stdin);
    	freopen("da.out","w",stdout);
    	ios::sync_with_stdio(false);
        cin.tie(0);
    	long long n,m,sum[10005]={},ans=0;
    	cin>>n>>m;
    	long long a[25];
    	for(int j=1;j<=n;j++){
    		cin>>a[j];
    	}
    	for(int i=1;i<=m;i++){
    		sum[i]=0;
    		for(int j=1;j<=n;j++){
    			if(i%a[j]==0){
    				sum[i]++;
    			}
    		}
    		ans=max(ans,sum[i]);
    	}
    	cout<<ans;
    	return 0;
    }
    
    
    • 0
      @ 2024-10-23 20:08:14

      其实看看数据范围,就是个暴力枚举。

      #include <bits/stdc++.h>
      using namespace std;
      int n, m;
      int a[25];
      int main()
      {
          freopen("da.in", "r", stdin);
          freopen("da.out", "w", stdout);
          ios::sync_with_stdio(false);
          cin.tie(0);
          cin >> n >> m;
          for (int i = 1; i <= n; i++)
              cin >> a[i];
          int ans = 0;
          for (int i = 1; i <= m; i++)
          {
              int now = 0;
              for (int j = 1; j <= n; j++)
                  if (i % a[j] == 0)
                      now++;
              ans = max(ans, now);
          }
          cout << ans;
          return 0;
      }
      
      • 1

      信息

      ID
      1048
      时间
      1000ms
      内存
      256MiB
      难度
      7
      标签
      递交数
      55
      已通过
      15
      上传者