-
Notifications
You must be signed in to change notification settings - Fork 11
/
SPOJ10293.cc
48 lines (41 loc) · 792 Bytes
/
SPOJ10293.cc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
// SPOJ 10293: FANCY NUMBERS
// http://www.spoj.com/problems/FANCY/
//
// Solution: ad-hoc
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <vector>
#include <cstring>
#include <functional>
#include <algorithm>
using namespace std;
#define ALL(c) c.begin(), c.end()
#define FOR(i,c) for(typeof(c.begin())i=c.begin();i!=c.end();++i)
#define REP(i,n) for(int i=0;i<n;++i)
#define fst first
#define snd second
typedef long long LL;
LL solve(char s[]) {
LL ans = 1;
int k = 0;
char c = 0, *p = s;
do {
if (*p != c) {
ans *= (1ull << k);
k = -1;
c = *p;
}
++k;
} while (*p++ != 0);
return ans;
}
int main() {
char buf[256];
gets(buf);
int T = atoi(buf);
while (T--) {
gets(buf);
printf("%lld\n", solve(buf));
}
}