Cod sursa(job #2650340)

Utilizator Stefan_PiscuPiscu Stefan Constantin Stefan_Piscu Data 18 septembrie 2020 14:32:55
Problema Pascal Scor 100
Compilator cpp-64 Status done
Runda Arhiva de probleme Marime 0.56 kb
#include <bits/stdc++.h>
using namespace std;

ifstream fin("pascal.in");
ofstream fout("pascal.out");

int main()
{
  int n, d;
  fin>>n>>d;
  int sol=0, bnd=n/2;
  int e[7]={0};
  for(int i=1;i<=bnd;++i){
    int x=i;
    while(x%2==0) x/=2, e[2]--;
    while(x%3==0) x/=3, e[3]--;
    while(x%5==0) x/=5, e[5]--;
    x=n-i+1;
    while(x%2==0) x/=2, e[2]++;
    while(x%3==0) x/=3, e[3]++;
    while(x%5==0) x/=5, e[5]++;
    e[4]=e[2]/2, e[6]=min(e[2], e[3]);
    if(e[d]>0) sol+=2;
  }
  if((n%2==0)&&(e[d]>0)) sol--;
  fout<<sol;
  return 0;
}