Problem Type : Number Theory
#include<iostream>
#include<cstring>
using namespace std;
int main()
{
string s,s1="0";
int i,j,k,len,m,sum;
while(true)
{
cin >> s;
if(s==s1)
break;
len = s.length();
m=0;
for(i=0; i<len; i++)
{
sum = m*10 + s[i]-48;
m = sum%17;
}
if(m==0)
{
cout << "1" <<endl;
}
else
{
cout << "0" <<endl;
}
s.clear();
}
}
#include<iostream>
#include<cstring>
using namespace std;
int main()
{
string s,s1="0";
int i,j,k,len,m,sum;
while(true)
{
cin >> s;
if(s==s1)
break;
len = s.length();
m=0;
for(i=0; i<len; i++)
{
sum = m*10 + s[i]-48;
m = sum%17;
}
if(m==0)
{
cout << "1" <<endl;
}
else
{
cout << "0" <<endl;
}
s.clear();
}
}
No comments:
Post a Comment