Page 3 of 3
Re: 10176 - Ocean Deep! Make it shallow!!
Posted: Thu Oct 08, 2009 10:01 am
by Jehad Uddin
got acc after a long time,
input processing was wrong actually.
Re: 10176 - Ocean Deep! Make it shallow!!
Posted: Thu Jan 26, 2012 8:25 am
by rmg_91
Why this code generate WA ,could anybody give some test cases?
Code: Select all
#include<cstdio>
#include<string>
#include<iostream>
#define mod 131071
using namespace std;
void doit(string s){
int sol=0;
for(int i=0;i<s.length();i++){
sol*=2;
sol%=mod;
sol=(sol+(int)(s[i]-'0'))%mod;
}
sol%=mod;
if(sol==0)puts("YES");
else puts("N0");
}
int main(){
string s,cad="";
while(cin>>s){
if(s[s.length()-1]=='#'){
doit(cad+s.substr(0,s.length()-1));
cad="";
}
else cad+=s;
}
}
Re: 10176 - Ocean Deep! Make it shallow!!
Posted: Thu Jan 26, 2012 9:38 am
by rmg_91
I found my mistake !!
Re: 10176 - Ocean Deep! Make it shallow!!
Posted: Sat Dec 21, 2013 8:15 pm
by X123
i am getting WA ,,, but failed to find out what is the wrong!!
#include<stdio.h>
#include<string.h>
#include<string>
#include<algorithm>
#include<iostream>
using namespace std;
int main()
{
char str[20000],temp[20000];
int i,j=0;
while(scanf("%c",&str[0])==1)
{
j=0;
int p=0;
if(str[0]!=' '&&str[0]!='\n'){
temp[j]=str[0];
j++;
}
for(i=1;i>=0;i++)
{
scanf("%c",&str
);
if(str=='#'){
temp[j]='\0';
break;
}
if(str!=' '&&str!='\n'){
temp[j]=str;
j++;
}
}
int l=strlen(temp);
for(i=0;i<l;i++)
{
int k=(temp-48)+p*2;
p=k%131071;
}
if(p==0)
printf("YES\n");
else
printf("NO\n");
}
return 0;
}
plz help 
Re: 10176 - Ocean Deep! Make it shallow!!
Posted: Wed Jan 15, 2014 1:08 am
by brianfry713
It looks like you figured it out
Re: 10176 - Ocean Deep ! - Make it shallow !!
Posted: Sun Nov 16, 2014 10:27 am
by Shahidul.CSE
Got Accepted
Re: 10176 - Ocean Deep ! - Make it shallow !!
Posted: Tue Nov 18, 2014 2:30 am
by brianfry713
At each step as you convert the binary string to a decimal value do a modulus 131071.
Re:
Posted: Thu Aug 27, 2015 10:26 pm
by seddik11
Dominik Michniewski wrote:I use Finite State Automaton to solve this problem.
Best regards
DM
very efficient way to use automate i just wrote 2 lines and got accepted really interesting !