Advertisement
Guest User

Untitled

a guest
May 26th, 2015
253
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.93 KB | None | 0 0
  1. /**
  2. * Tittle: 10176 - Ocean Deep! - Make it shallow!!
  3. * Author: Cheng-Shih, Wong
  4. * Date: 2015/04/17
  5. */
  6.  
  7. // include files
  8. #include <iostream>
  9. #include <cstdio>
  10. #include <cstring>
  11. #include <string>
  12.  
  13. using namespace std;
  14.  
  15. // definitions
  16. #define FOR(i,a,b) for( int i=(a),_n=(b); i<=_n; ++i )
  17. #define clr(x,v) memset( x, v, sizeof(x) )
  18.  
  19. typedef long long ll;
  20.  
  21. // declarations
  22.  
  23.  
  24. // functions
  25.  
  26.  
  27. // main function
  28. int main( void )
  29. {
  30. ll box[20];
  31. ll rmd;
  32. int ss;
  33. string str;
  34. char buf[105];
  35.  
  36. // input
  37. while( scanf( "%s", buf )==1 ) {
  38. str = buf;
  39. // solve
  40. while( str[str.size()-1] != '#' ) {
  41. scanf( "%s", buf );
  42. str += buf;
  43. }
  44.  
  45. str.pop_back();
  46.  
  47. clr( box, 0 );
  48. ss = str.size()-1;
  49. FOR( i, 0, ss ) {
  50. if( str[i]=='1' )
  51. ++box[(ss-i)%17];
  52. }
  53.  
  54. FOR( i, 0, 16 )
  55. box[i] %= 131071;
  56.  
  57. rmd = 0;
  58. FOR( i, 0, 16 )
  59. rmd = (rmd+box[i]*(1LL<<i))%131071;
  60.  
  61. // output
  62. if( rmd ) puts("NO");
  63. else puts("YES");
  64. }
  65.  
  66. return 0;
  67. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement