#include<iostream>
#include <bits/stdc++.h>
#include<set>
#include<algorithm>
using namespace std;
int main(){
    ios::sync_with_stdio(0);
    cin.tie(0);
    int te;
    cin>>te;
    for(int i = 1; i <= te; i++){
        int limit; cin>>limit;
        int length; cin>>length;

        int primes[length+1];
        int products[length];
        for(int j = 0; j<length; j++){
            cin>>products[j];
        }
        for(int j = 0; j<length-1; j++){
            primes[j] = products[j]/(__gcd(products[j], products[j+1]));
        }
        primes[length-1] = __gcd(products[length-2], products[length-1]);
        primes[length] = products[length-1]/__gcd(products[length-2], 
products[length-1]);
        int dup[length+1];
        copy(primes, primes+length+1, dup);
        sort(dup, dup+length+1);
        set<int> s(dup, dup+length+1);
        int alpha[26];
        copy(s.begin(), s.end(), alpha);
        string decode = "";
        for(int j =0; j<=length; j++){
            decode += char(65+distance(alpha,find(alpha, alpha+26, 
primes[j])));
        }
        cout<<"Case #"<<i<<": "<<decode<<endl;
    }
}

-- 
You received this message because you are subscribed to the Google Groups 
"Google Code Jam" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/google-code/589fdab6-6c5c-4c53-ae49-0a34cff4857e%40googlegroups.com.

Reply via email to