Thursday, April 28, 2016

Published April 28, 2016 by with 0 comment

UVA 11879 : Multiple of 17 - solution

#include<cstdio>
#include<string.h>
using namespace std;

int main()
{
    char n[111];
    while (scanf("%s",n)!=EOF)
    {
        int l=strlen(n);
        if (l==1 && n[0]=='0') return 0;
        int r=0;
        for (int i=0;i<l;i++)
        {
            r=r*10+n[i]-'0';
            r=r%17;
        }
        if (r==0) printf("1\n");
        else printf("0\n");
    }
    return 0;
}
      edit

0 comments:

Post a Comment