Cod sursa(job #382060)

Utilizator attila3453Geiszt Attila attila3453 Data 12 ianuarie 2010 17:26:21
Problema Factorial Scor 20
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.47 kb
#include <cstdio>
long long p, t;
int main(){
  freopen("fact.in", "r", stdin);
  freopen("fact.out", "w", stdout);
  scanf("%d", &p);
  if (p==0)
    printf("1");
  else{
    t=p+1;
    p=p-p/6-p/31-p/156-p/781-p/3906-p/19531-p/97656-p/488281-p/2441406-p/12207031-p/61035156-p/305175781;
    t=t-t/6-t/31-t/156-t/781-t/3906-t/19531-t/97656-t/488281-t/2441406-t/12207031-t/61035156-t/305175781;
    if (t==p)
	  printf("-1"); 
    else
	  printf("%lld", p*5);
  }
}