Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save mob5566/d5936e69191325ed72f1 to your computer and use it in GitHub Desktop.
Save mob5566/d5936e69191325ed72f1 to your computer and use it in GitHub Desktop.
10176 - Ocean Deep! - Make it shallow!!
/**
* Tittle: 10176 - Ocean Deep! - Make it shallow!!
* Author: Cheng-Shih, Wong
* Date: 2015/04/17
*/
// include files
#include <iostream>
#include <cstdio>
#include <cstring>
#include <string>
using namespace std;
// definitions
#define FOR(i,a,b) for( int i=(a),_n=(b); i<=_n; ++i )
#define clr(x,v) memset( x, v, sizeof(x) )
typedef long long ll;
// declarations
// functions
// main function
int main( void )
{
ll box[20];
ll rmd;
int ss;
string str;
char buf[105];
// input
while( scanf( "%s", buf )==1 ) {
str = buf;
// solve
while( str[str.size()-1] != '#' ) {
scanf( "%s", buf );
str += buf;
}
str.pop_back();
clr( box, 0 );
ss = str.size()-1;
FOR( i, 0, ss ) {
if( str[i]=='1' )
++box[(ss-i)%17];
}
FOR( i, 0, 16 )
box[i] %= 131071;
rmd = 0;
FOR( i, 0, 16 )
rmd = (rmd+box[i]*(1LL<<i))%131071;
// output
if( rmd ) puts("NO");
else puts("YES");
}
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment