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 main() {
int n; int n;
int a = 0;
cin >> n; cin >> n;
int flower_array[n]; int flower_array[n];
for (int i = 0; i < n; i++) { for (int i = 0; i < n; i++) {
cin >> flower_array[i]; cin >> flower_array[i];
} }
for (int i = 0; i < n - 1; i++) { for (int i = 0; i < n; i++) {
for (int j = 0; j < n - i - 1; j++) { for (int j = 0; j < n - i; j++) {
int k = j + i; double average = 0;
for (int l = 1; l <= k; l++) { for (int k = 0; k <= j; k++) {
cout << flower_array[l] << " "; 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; return 0;
} }

Loading…
Cancel
Save