void factor(ll n,int id)
{
    for(int i=0;prime[i]<=sqrt(n) and i<SZ(prime);i++)
    {
        if(n%prime[i]==0)
        {
            int cnt=0;
            while(n%prime[i]==0)
            {
                cnt++;
                n/=prime[i];
            }
            if(id==2){v.pb(mp(prime[i],cnt));lprime++;}
            else if(id==0) {a1[prime[i]]=cnt;aprime++;}
            else if(id==1) {b1[prime[i]]=cnt;bprime++;}
        }
    }

    if(n>1)
    {
        if(id==2){v.pb(mp(n,1));lprime++;}
        else if(id==0) {a1[n]=1;aprime++;}
        else if(id==1) {b1[n]=1;bprime++;}
    }
}
Пример #2
0
int main ()
{
    srand (time (0));

    //freopen (NAME".in", "r", stdin);
    //freopen (NAME".out", "w", stdout);

    scanf ("%d %d", &n, &k);

    for (int i = 0; i < n; i++)
    {
        int x;
        scanf ("%d", &x);
        a.pb (mp (x, i + 1));
    }

    sort (a.begin (), a.end (), cmp);
    int curr = a [n - 1].frs - a [0].frs;

    while (curr > 1 && k > 0)
    {
        a [n - 1].frs--;
        a [0].frs++;
        ans.pb (mp (a [n - 1].snd, a [0].snd));
        k--;
        sort (a.begin (), a.end (), cmp);
        curr = a [n - 1].frs - a [0].frs;
    }

    printf ("%d %d\n", curr, (int) ans.size ());

    for (int i = 0; i < (int) ans.size (); i++)
        printf ("%d %d\n", ans [i].frs, ans [i].snd);

    return 0;
}