ইনপুট এই রকম ও দেয়া থাকতে পারে
10101010 101010 101# 1010111# 1# 0#
কোড
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Problem : 10176 - Ocean Deep !.cpp | |
* Author : ~menon; | |
*/ | |
#include <string.h> | |
#include <iostream> | |
#include <stdio.h> | |
int main() | |
{ | |
char binary; | |
int dec; | |
while(std::cin >> binary) | |
{ | |
dec = 0; | |
dec += binary - '0'; | |
while(std::cin >> binary) { | |
if(binary == '#') { | |
break; | |
} | |
// this line convert binary to dicemal; | |
dec = dec * 2 + (binary - '0'); | |
dec = dec % 131071; | |
} | |
if(dec == 0) { | |
printf("YES\n"); | |
} | |
else { | |
printf("NO\n"); | |
} | |
} | |
return 0; | |
} |
Comments
Post a Comment