Browse Source

Complete USACO 2020 December Bronze Problem 2: Daisy Chains

master
Abheek Dhawan 3 years ago
parent
commit
de0721354b
  1. 21
      usaco/Daisy Chain/index.cpp

21
usaco/Daisy Chain/index.cpp

@ -4,19 +4,28 @@ using namespace std;
int main() {
int n;
int a = 0;
cin >> n;
int flower_array[n];
for (int i = 0; i < n; i++) {
cin >> flower_array[i];
}
for (int i = 0; i < n - 1; i++) {
for (int j = 0; j < n - i - 1; j++) {
int k = j + i;
for (int l = 1; l <= k; l++) {
cout << flower_array[l] << " ";
for (int i = 0; i < n; i++) {
for (int j = 0; j < n - i; j++) {
double average = 0;
for (int k = 0; k <= j; k++) {
average += flower_array[i+k];
}
average /= (j+1);
for (int k = 0; k <= j; k++) {
if (flower_array[i+k] == average) {
a++;
break;
}
}
cout << endl;
}
}
//a -= n;
cout << a;
return 0;
}

Loading…
Cancel
Save