Skip to content

Instantly share code, notes, and snippets.

Created January 23, 2015 20:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anonymous/b9711e2b0dd15039323d to your computer and use it in GitHub Desktop.
Save anonymous/b9711e2b0dd15039323d to your computer and use it in GitHub Desktop.
#include <bits/stdc++.h>
using namespace std;
template <class T>
bool get_int(T& n)
{
n = 0;
int8_t sign=1;
register char c=0;
while(c<33)
c=getchar_unlocked();
if (c=='-')
{
sign=-1;
c=getchar_unlocked();
if(c == -1)
return false;
}
while(c>='0'&&c<='9')
{
n=(n<<3)+(n<<1)+(c-'0');
c=getchar_unlocked();
if(c == -1)
{
n *= sign;
return true;
}
}
n *= sign;
return true;
}
void gstr(char* s)
{
while(((*s) >= '0') && ((*s) <= '9'))
*(s++) = getchar_unlocked();
*s = '\0';
}
template<class T>
void pint(T a)
{
register char c;
char num[21];
int8_t i = 0;
if(a < 0) {
putchar_unlocked('-');
a *= -1;
}
do
{
num[i++] = a%10 + 48;
a /= 10;
} while (a != 0);
i--;
while (i >= 0)
putchar_unlocked(num[i--]);
putchar_unlocked('\n');
}
int main(int argc, char const *argv[])
{
int t;
get_int(t);
while(t--)
{
char c = 0;
int shift = 0;
while(c < 33){
c = getchar_unlocked();
if(c == -1){
c = 0;
break;
}
}
int count = 0;
while((c >= '0') and (c <= '9'))
{
char t = getchar_unlocked();
if(t == c){
count++;
}
else{
shift += count;
count = 0;
}
c = t;
}
pint((long long int)(1 << ((long long int)shift)));
}
return 0;
}
#!/usr/bin/env python
# encoding: utf-8
from itertools import groupby
from sys import stdin
def main():
inp = stdin.read().split()
out = []
for _ in xrange(int(inp[0])):
prod = 0
for item, it in groupby(inp[_ + 1]):
prod += sum([1 for x in it]) - 1
out.append(str(1 << prod))
print '\n'.join(out)
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment