- #include<bits/stdc++.h>
- using namespace std;
- int main()
- {
- int a,b,score=0;
- vector<int> y;
- cin>>a>>b;
- int c[a][b];
- for(int i=0;i<a;i++)
- {
- for(int j=0;j<b;j++)
- {
- cin>>c[i][j];
- }
- }
- for(int i=0;i<a;i++)
- {
- int u=INT_MIN;
- for(int j=0;j<b;j++)
- {
- if(c[i][j]>=u)
- {
- u=c[i][j];
- }
- }
- y.push_back(u);
- score+=u;
- }
- int n=0;
- cout<<score<<endl;
- for(int i=0;i<y.size();i++)
- {
- if(score%y[i]==0)
- {
- if(n!=0)
- {
- cout<<" ";
- }
- cout<<y[i];
- n++;
- }
- }
- if(n==0)
- cout<<"-1";
- }
複製代碼 |