# 超过C ++时限

While I couldn't find a way to solve the "Stable Wall" problem (see here to know what I'm talking about), I solved the other ones in less than 30 minutes and they all worked with google sample inputs.

``````//Countdown:
#include <iostream>
#include <string>

using namespace std;

int getter(string temp, int much) {
string result = "";
int count = 1;

for (auto it : temp) {
if (count == much)
result += it;

if (it == ' ') {
if (count++ == much)
break;
}
}

return stoi(result);
}

int main() {
string get, temp;
getline(cin, get);

int cases = stoi(get);

for (int n = 1; n <= cases; n++)
{
getline(cin, get);
int num =  getter(get, 1);
int k = getter(get, 2);

getline(cin, get);
int equal = k;
int count = 0;

for (int m = 1; m <= num; m++)
{
int sub = getter(get, m);
if (sub == equal)
equal--;
else
equal = k;

if (equal == 0)
{
count++;
equal = k;
}
}

cout << "Case #" << n << ": " << count << endl;
}
``````
``````//Perfect subarray:
#include <iostream>
#include <string>
#include <vector>
#include <math.h>

using namespace std;

int getter(string temp, int much) {
string result = "";
int count = 1;

for (auto it : temp) {
if (count == much)
result += it;

if (it == ' ') {
if (count++ == much)
break;
}
}

return stoi(result);
}

int main() {
string get, temp;
getline(cin, get);

int cases = stoi(get);

for (int n = 1; n <= cases; n++)
{
getline(cin, get);
int num = getter(get, 1);

getline(cin, get);
vector<int> all;

for (int m = 1; m <= num; m++)
all.push_back(getter(get, m));

int count = 0;

for (int m = 0; m < all.size(); m++)
{
int sum = 0;

for (int o = m; o < all.size(); o++)
{
sum += all[o];

double sqr = sqrt(sum);

if (sum >= 0 && sqr == (int)sqr)
count++;
}
}

cout << "Case #" << n << ": " << count << endl;
}
}
``````
``````//Candies:
#include <iostream>
#include <string>

using namespace std;

int getter(string temp, int much) {
string result = "";
int count = 1;

for (auto it : temp) {
if (count == much)
result += it;

if (it == ' ') {
if (count++ == much)
break;
}
}

return stoi(result);
}

int main() {
string get, temp;
getline(cin, get);

int cases = stoi(get);

for (int n = 1; n <= cases; n++)
{
getline(cin, get);
int num =  getter(get, 1);
int k = getter(get, 2);

getline(cin, get);
int equal = k;
int count = 0;

for (int m = 1; m <= num; m++)
{
int sub = getter(get, m);
if (sub == equal)
equal--;
else
equal = k;

if (equal == 0)
{
count++;
equal = k;
}
}

cout << "Case #" << n << ": " << count << endl;
}
}
``````

Even replacing `int` with `long long` every time anything changed, so the problem wasn't an integer overflow.

（比赛结束了，我很好奇）