Cod sursa(job #1488427)

Utilizator CidanielCraciun Ioan Daniel Cidaniel Data 18 septembrie 2015 22:17:14
Problema Pairs Scor 0
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.74 kb
#include <iostream>
#include <fstream>
using namespace std;
ifstream f ("Pairs.in");
ofstream g ("Pairs.out");
long n, i, v[100000], j, k, x, y, S;
int main()
{
    f>>n;
    for (i=0; i<n; i++)
        f>>v[i];
    for (i=0; i<n; i++)
        for (j=i+1; j<n; j++)
            {
                if (v[i]!=v[j])
                    {
                        x=v[i];
                        y=v[j];
                        while (x!=y)
                            if (x>y)
                                x=x-y;
                            else
                                y=y-x;
                        if (x==1)
                            k++;
                    }}

    g<<k;
    f.close();
    g.close();
    return 0;
}