1 条题解

  • 2
    @ 2024-11-21 20:14:26
    #include <bits/stdc++.h>
    #define int long long
    using namespace std;
    const int N = 100 + 10;
    const int INF = 0x3f3f3f3f;
    int n , m , sum;
    int a [N] [N];
    int dfs (int n , int m)
    {
    	int k = a [n] [m];
    	if (k % 15 == 0)
    	{
    		a [n] [m] = 0;
    		return k;
    	} 
    	return 0;
    }
    signed main()
    {
    	    cin >> n >> m;
    	    for (int i = 1; i <= n; i++)
    	        for (int j = 1; j <= m; j++)
    	            cin >> a [i] [j];
    	    for (int i = 1; i <= n; i++)
    	    {
    	    	sum += dfs (i , 1);
    	    	sum += dfs (i , m);
    		}
    		for (int i = 1; i <= m; i++)
    		{
    			sum += dfs (1 , i);
    			sum += dfs (n , i);
    		}
    	    cout << sum;   
    		return 0;
    }
    
    • 1

    计算矩阵边缘能被3和5整除的数字之和

    信息

    ID
    3102
    时间
    1000ms
    内存
    256MiB
    难度
    2
    标签
    递交数
    40
    已通过
    8
    上传者