## A. Standing Ovation

100组数据。

### 解题

```def solve():
(n, aud) = raw_input().split()
n = int(n)
aud = map(int, aud)
stand = aud[0]
res = 0
for i in xrange(1, n + 1):
u = aud[i]
if not u:
continue
if i > stand:
res += i - stand
stand = i
stand += u
return res

T = int(raw_input())

for i in xrange(T):
print 'Case #%d: %d' % (i + 1, solve())
```

## B. Infinite House of Pancakes

### 题意

'Here comes Mia, daughter of none!'
-- The Dark Tower V: Wolves of the Calla

### 数据规模

100组测试数据。

D为有煎饼的客人的数目。Pi为客人拥有煎饼的最大值。

1 ≤ D ≤ 6.
1 ≤ Pi ≤ 9.

1 ≤ D ≤ 1000.
1 ≤ Pi ≤ 1000.

### 解题

```#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>

using namespace std;

#define print(x) cout << x << endl
#define input(x) cin >> x

const int SIZE = 1024 + 233;

int n;
vector<int> vec;

int main() {
int T, a, cas = 1;
input(T);

while (T--) {
input(n);
vec.clear();
for (int i = 0; i < n; i++) {
input(a);
vec.push_back(a);
}

int ans = SIZE * 233;
for (int i = 1; i <= SIZE; i++) {
int step = 0;
int maxi = 0;
for (const auto& num: vec) {
if (num > i) {
step += num % i? num / i: num / i - 1;
maxi = i;
} else {
maxi = max(maxi, num);
}
}
ans = min(ans, step + maxi);
}

printf("Case #%d: %d\n", cas++, ans);
}
return 0;
}
```

## C. Dijkstra

### 数据规模

1 ≤ X ≤ 10000.
1 ≤ L * X ≤ 10000.

1 ≤ X ≤ 10^12.
1 ≤ L * X ≤ 10^16.

### 解题

i与j的转化是类似的。

```#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <algorithm>
#include <vector>

using namespace std;

#define print(x) cout << x << endl
#define input(x) cin >> x
#define error(x) cerr << x << endl

const int SIZE = 12345;

enum {
ONE = 1,
II  = 2,
JJ  = 3,
KK  = 4
};

int trans[5][5] = {
{0, 0,   0,    0,   0},
{0, ONE, II,   JJ,  KK},
{0, II,  -ONE, KK, -JJ},
{0, JJ,  -KK, -ONE, II},
{0, KK,  JJ,  -II, -ONE}
};

int conv(char c) {
switch (c) {
case '1': return ONE;
case 'i': return II;
case 'j': return JJ;
case 'k': return KK;
}
return -1;
}

struct Number {
int sign;
int value;

Number() {}
Number(char c) {
sign = 1;
value = conv(c);
}
Number(int isign, int ivalue): sign(isign), value(ivalue){}

Number operator * (const Number& num) {
int a = num.sign * sign;
int b = trans[value][num.value];
if (b < 0) {
a *= -1;
b = abs(b);
}
return Number{a, b};
}
};

string _word;
string word;

long long L, X;

bool get_whole() {
Number num('1');
for (auto& c: _word) {
num = num * Number(c);
}
Number ans('1');

long long x = X;
while (x) {
if (x & 1) {
ans = ans * num;
}
num = num * num;
x >>= 1;
}
return ans.sign == -1 and ans.value == ONE;
}

int main() {
int T, cas = 1;
input(T);
while (T--) {
input(L >> X);
input(_word);
word = "";
for (int i = 0; i < min(X, 19LL); i++) {
word += _word;
}

Number num('1');

bool ii = false;
bool jj = false;
bool kk = get_whole();

int n = word.size();

for (int i = 0; i < n - 1; i++) {
num = num * word[i];

if (num.sign == 1 && num.value == II) {
ii = true;
}else if (ii && num.sign == 1 && num.value == KK) {
jj = true;
break;
}
}
kk = (kk && ii && jj);
printf("Case #%d: ", cas++);
puts(kk? "YES": "NO");
}
return 0;
}
```

`19`是一个magic number。还有，小心Dandelo数据超int。