###### tags: `APCS` `c++` # 題解 zerojudge c295: APCS-2016-1029-2最大和 ```cpp= #include<bits/stdc++.h> using namespace std; int main(){ ios_base::sync_with_stdio(0); cin.tie(0);cout.tie(0); int n,m,k,xi; cin>>n>>m; int s=0; int ans[n]; for(int i=0;i<n;i++){ k=0; for(int j=0;j<m;j++){ cin>>xi; k=max(k,xi); } s+=k; ans[i]=k; } cout<<s<<"\n"; int c=0; vector<int>o; for(int i=0;i<n;i++){ if(s%ans[i]==0) o.push_back(ans[i]); } if(o.empty()) cout<<-1; else{ for(int i=0;i<o.size()-1;i++){ cout<<o[i]<<" "; } cout<<o[o.size()-1]; } } ```
×
Sign in
Email
Password
Forgot password
or
By clicking below, you agree to our
terms of service
.
Sign in via Facebook
Sign in via Twitter
Sign in via GitHub
Sign in via Dropbox
Sign in with Wallet
Wallet (
)
Connect another wallet
New to HackMD?
Sign up