Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /**
- * 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;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement