Created
November 7, 2018 01:58
-
-
Save cbdavide/2fbfcaae676bab977b50b0311d00df63 to your computer and use it in GitHub Desktop.
UVa 11628 - Another lottery
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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