Cod sursa(job #1984327)

Utilizator mihai2003LLL LLL mihai2003 Data 24 mai 2017 15:39:49
Problema Pascal Scor 0
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.94 kb
#include <fstream>
using namespace std;
const int NMAX = 5000005;
char p2[NMAX],p3[NMAX],p5[NMAX];
int x[7];
ifstream in("euclid.in");
ofstream out("euclid.out");
int main()
{
    int r,d,s=0;
    in>>r>>d;
    for(int i=1;i<=r;i++){
        if(i%2==0)
            p2[i]=p2[i/2]+1;
        if(i%3==0)
            p3[i]=p3[i/3]+1;
        if(i%5==0)
            p5[i]=p5[i/5]+1;
    }
   // for(int j=2;j<6;j++){
        for(int i=1;i<=r;i++){
            //if(j==2 || j==4)
                x[2]=x[2]+p2[r-i+1]-p2[i];
            //if(j==3)
                x[3]=x[3]+p3[r-i+1]-p3[i];
            //if(j==5)
                x[5]+=p5[r-i+1]+p5[i];
                if(d==6)
                    if(min(x[2],x[3])>0)
                        s++;
                    else;
                else
                    if(d==4)
                        s+=(x[2]/2>0);
                    else
                        s+=(x[d]>0);
        }
    //}
   out<<s;
    return 0;
}