/// Raihan Ruhin /// CSE, Jahangirnagar University. /// Dhaka-Bangladesh. /// id: raihanruhin (topcoder / codeforces / codechef / uva / uvalive), 3235 (lightoj) /// mail: raihanruhin@ (yahoo / gmail / facebook) /// blog: ruhinraihan.blogspot.com #include<bits/stdc++.h> using namespace std; #define SET(a) memset(a,-1,sizeof(a)) #define CLR(a) memset(a,0,sizeof(a)) #define PI acos(-1.0) #define MOD 1000000007 #define MX 100010 long long calcLcm(long long a, long long b) { return a*b/__gcd(a, b); } int main() { ios_base::sync_with_stdio(0);cin.tie(0); int tc, kk=1, n, m, x, y, a, b, c, arr[12]; string s; cin>>tc; while(tc--) { cin>>n; cin>>arr[0]; long long lcm = arr[0]; for(int i=1;i<n;i++) { cin>>arr[i]; lcm = calcLcm(lcm, arr[i]); } long long denominator = 0; for(int i=0;i<n;i++) denominator+=(lcm/arr[i]); long long numerator = lcm * n; long long gcd = __gcd(numerator, denominator); cout<< "Case "<<kk++<<": "<< numerator/gcd<<"/"<<denominator/gcd<<"\n"; } return 0; }
Friday, 11 September 2015
UVA 12068 Harmonic Mean (UVALive 3288, Regionals 2005 >> Asia - Dhaka)
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment