UVa 10176 Ocean Deep ! - Make it shallow !! (模性质)

http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=24&page=show_problem&problem=1117


思路和UVa 11344是一样的,只不过那题是10进制,这题是2进制。


完整代码:

/*0.019s*/

#include<cstdio>

int main()
{
	int mod;
	char ch;
	while (~(ch = getchar()))
	{
		mod = ch & 15;
		while ((ch = getchar()) != '#')
		{
			if (ch == 10) continue;
			mod = ((mod << 1) + (ch & 15)) % 131071;
		}
		puts(mod ? "NO" : "YES");
		getchar();
	}
	return 0;
}

你可能感兴趣的:(C++,ACM,uva)