Sunday, October 23, 2016

UVA 11879 - Multiple of 17

#include<bits/stdc++.h>
#define sf scanf
#define pf printf
#define LL long long
using namespace std;
int main()
{
   ios_base::sync_with_stdio(false);
   string num="";
   while(cin >> num && num!="0"){
    int temp = 0;
    for (int i = 0; i < num.length(); ++i)
    {
        temp = temp*10 + num[i]-'0';
        temp%=17;
        //cout << temp << ' ';
    }
    temp == 0 ? cout<<1<<'\n':cout<<0<<'\n';
   }

return 0;
}

No comments:

Post a Comment