Uva 10929 - You can say 11


 #include <iostream>
#include <cstdio>
#include <cstring>
#include <map>
#include <string>
#include <vector>
#include <cmath>
#include <cctype>
#include <sstream>
#include <set>
#include <list>
#include <stack>
#include <queue>
#include <algorithm>
#define sf scanf
#define pf printf
#define sfint scanf ("%d %d",&a,&b)
#define sfl scanf ("%ld %ld",&a,&b)
#define sfll scanf ("%lld %lld",&a,&b)
#define sfd scanf ("%lf %lf",&a,&b)
#define sff scanf ("%f %f",&a,&b)
#define LL long long
#define L long
#define nl puts("")
#define N 10000
#define MOD 10000000007
#define pb push_back
#define pi acos(-1.0)
#define sz size()
#define gc getchar ()
#define ps push
#define clr clear
#define bn begin()
#define ed end()

using namespace std;

int main()
{
    string s;

    while (cin >> s and s!="0")
    {
       int r=0;
       bool f = false, yes = false;

       for (int i=0;i<s.size();i++)
       {
           r = (s[i]-'0') + (r*10);

           if (r/11 != 0)
           {
               f = true;
           }

           if (f)
           {
               //continue;
               r%=11;
           }

           else
           {
               r%=11;
           }
       }

       if (r == 0)
       {
           yes = true;
       }

       if (yes) cout << s << " is a multiple of 11." << endl;
       else cout << s << " is not a multiple of 11." << endl;

       f = yes = false;
    }

    return 0;
}

Comments

Popular posts from this blog

SPOJ-CMG - Collecting Mango

LightOJ 1009 - Back to Underworld

LeetCode Palindrome Number