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

that's seem easy but why I got WA
Posted by TheBlaNK 27 Feb 2002 22:53
#include <stdio.h>
#include <ctype.h>
int main()
{
 long num=0,k,v,max=1;
 char ch;
 ch=getchar();
  while(ch!=EOF)
    {
     if(isdigit(ch)) v=ch-'0';
     else v=ch-'A'+10;
     num+=v;
     if(v>max) max=v;
     ch=getchar();
    }
  for(k=max;k<36;k++)
   if(num%k==0) break;
  if(k<36) printf("%ld",k+1);
  else printf("No solution.");
 return 0;
}
There may be other characters (e.g. spaces , returns) too. Good luck!
Posted by MadPsyentist/Sam 28 Feb 2002 03:39
> #include <stdio.h>
> #include <ctype.h>
> int main()
> {
>  long num=0,k,v,max=1;
>  char ch;
>  ch=getchar();
>   while(ch!=EOF)
>     {
>      if(isdigit(ch)) v=ch-'0';
>      else v=ch-'A'+10;
>      num+=v;
>      if(v>max) max=v;
>      ch=getchar();
>     }
>   for(k=max;k<36;k++)
>    if(num%k==0) break;
>   if(k<36) printf("%ld",k+1);
>   else printf("No solution.");
>  return 0;
> }
that make me got WA over 10 times .thank you very P'Sam I've got accept
Posted by TheBlaNK 1 Mar 2002 17:18
> > #include <stdio.h>
> > #include <ctype.h>
> > int main()
> > {
> >  long num=0,k,v,max=1;
> >  char ch;
> >  ch=getchar();
> >   while(ch!=EOF)
> >     {
> >      if(isdigit(ch)) v=ch-'0';
> >      else v=ch-'A'+10;
> >      num+=v;
> >      if(v>max) max=v;
> >      ch=getchar();
> >     }
> >   for(k=max;k<36;k++)
> >    if(num%k==0) break;
> >   if(k<36) printf("%ld",k+1);
> >   else printf("No solution.");
> >  return 0;
> > }
Here is your mistake
Posted by Imran Yusubov 18 Dec 2008 11:55
NOT EOF BUT '\n'
#include <stdio.h>
#include <ctype.h>
long num=0,v,max=1,k;
char ch;

int main()
{

ch=getchar();

do
{
if(isdigit(ch)) v=ch-48;
else v=ch-55;
num+=v;
if(v>max) max=v;
ch=getchar();
}
while(ch!='\n');

if(max==0)
printf("2");
else
{
for(k=max;k<36;k++)
if(num%k==0)
break;

if(k<36)
printf("%ld",k+1);
else
printf("No solution.");
}
return 0;
}