Skip to content

Instantly share code, notes, and snippets.

@cbdavide
Created November 7, 2018 01:58
Show Gist options
  • Save cbdavide/2fbfcaae676bab977b50b0311d00df63 to your computer and use it in GitHub Desktop.
Save cbdavide/2fbfcaae676bab977b50b0311d00df63 to your computer and use it in GitHub Desktop.
UVa 11628 - Another lottery
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define PB push_back
#define endl '\n'
typedef long long ll;
typedef vector<ll> vll;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef vector<int> vi;
int main() {
int n, m, sum, gcd;
while(cin >> n >> m && (n + m)) {
vi A(n);
for(int i=0; i<n; i++)
for(int j=0; j<m; j++) cin >> A[i];
sum = accumulate(A.begin(), A.end(), 0);
for(int i : A) {
gcd = __gcd(i, sum);
printf("%d / %d\n", i / gcd, sum / gcd);
}
}
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment