ENG  RUSTimus Online Judge
Online Judge
Problems
Authors
Online contests
About Online Judge
Frequently asked questions
Site news
Webboard
Links
Problem set
Submit solution
Judge status
Guide
Register
Update your info
Authors ranklist
Current contest
Scheduled contests
Past contests
Rules
back to board

Discussion of Problem 1053. Pinocchio

why did I have CE??!
Posted by Bushtruk Vyacheslav 14 Feb 2003 16:26
 On my computer program works correclty, but I had three CE to #1053
problem.Quastion is a word - "why":-(( ?
 I supposed problem in <math.h> or <stdlib.h> file.

Program COD::
#include <stdio.h>
#include <math.h>
#include <stdlib.h>

int NOD(int i1,int i2){
  if(i1==i2)return i1;
  int del=1,c1,c2;
  while(1){
    c1=i1; c2=i2;
    if(fmod(c1,del)!=0)break;
    if(fmod(c2,del)!=0)break;
      del++;
  };
  del--;
  return del;
};

void main(){
  int mas[999];
  int q1;
  scanf("%i",&q1);
  for(int i=0;i<q1;i++){
    scanf("%i",&mas[i]);
    if(mas[i]==1){ printf("%i",1); exit(1); }
  }
  q1=1;
  while(mas[q1]!=0){
    mas[0]=NOD(mas[0],mas[q1]); q1++;
    if(mas[0]==1){ printf("%i",1); exit(1); }
  }
  printf("%i",mas[0]);
};