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 1104. Don’t Ask Woman about Her Age

why i always got access_violation?help
Posted by zhi 1 Mar 2002 21:00
This is my program.What is the problem with my program?Please tell me.
Thank you!
#include<iostream.h>
#include<string.h>
#include<stdlib.h>
char* str;
int f(char* s){
  char max='0';

  for(long  lop=0;s[lop]!='\0';lop++)
      if(s[lop]>max)max=s[lop];
      if(max<'2')return 2;
      if(max<='9')return int(max-'0'+1);
      return int(max-'A'+11);
      }
int num(char s){
     if(s<='9')return int(s-'0');
     return int(s-'A'+10);
     }

void main(){
 str=new char[950010];
 cin>>str;
 long l;
 for(l=0;str[l]!='\0';l++)if(l>=950010)exit(1);
 int lop;
 unsigned long h;
 unsigned long temp;
 for(int k=f(str);k<=36;k++)
 {
     temp=0;
     h=0;
   int y=l%5;
   if(y!=0)
      for(lop=0;lop<y;lop++)
    {
    temp=temp*k;
    temp+=num(str[h]);
    h++;
        if(h==l) break;
    }
    while(h!=l)
      {
    temp=temp%(k-1);
    for(lop=0;lop<5;lop++)
      {
        temp=temp*k;
        temp+=num(str[h]);
        h++;
            if (h==l) break;
      }
      }
    if(temp%(k-1)==0){cout<<k<<endl;exit(1);}
 }
cout<<"No solution."<<endl;
}
it needn't keep all number in array
Posted by TheBlaNK 2 Mar 2002 23:48
it needn't keep all number in array
if u know
 (m+n)%k = ((m%k)+(n%k))%k
Could you say it more clearly? I can't understand.
Posted by Koala 26 Jul 2002 17:09
> it needn't keep all number in array
> if u know
>  (m+n)%k = ((m%k)+(n%k))%k