Timus : 1243 (Divorce of the Seven Dwarfs)



// http://acm.timus.ru/problem.aspx?space=1&num=1243
// Tag: mod

#include <stdio.h>
#include <queue>
using namespace std;

int main(int argc, char *argv[])
{
	char a [50 + 5]; scanf ("%s", a);

	queue <int> q;

	for ( int i = 0; a [i]; i++ )
	{
		q.push (a [i] - '0');
	}

	int mod = 0;

	while ( !q.empty () )
	{
		mod *= 10;
		mod += q.front ();
		q.pop ();

		mod %= 7;
	}

	printf ("%d\n", mod);
	
	return 0;
}
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s