Day 9 submission
This commit is contained in:
+33
-33
@@ -1,33 +1,33 @@
|
||||
#include <iostream>
|
||||
|
||||
using namespace std;
|
||||
|
||||
int main()
|
||||
{
|
||||
int next_fish;
|
||||
unsigned long long fish[9] = {0};
|
||||
for(int i = 0; i < 300; i++)
|
||||
{
|
||||
cin >> next_fish;
|
||||
fish[next_fish]++;
|
||||
}
|
||||
|
||||
unsigned long long total_fish = 300;
|
||||
for(int i = 0; i < 256; i++)
|
||||
{
|
||||
unsigned long long spawning_fish = fish[0];
|
||||
total_fish += spawning_fish;
|
||||
|
||||
for(int j = 1; j < 9; j++)
|
||||
{
|
||||
fish[j-1] = fish[j];
|
||||
}
|
||||
|
||||
fish[6] += spawning_fish;
|
||||
fish[8] = spawning_fish;
|
||||
}
|
||||
|
||||
cout << total_fish << endl;
|
||||
|
||||
return 0;
|
||||
}
|
||||
#include <iostream>
|
||||
|
||||
using namespace std;
|
||||
|
||||
int main()
|
||||
{
|
||||
int next_fish;
|
||||
unsigned long long fish[9] = {0};
|
||||
for(int i = 0; i < 300; i++)
|
||||
{
|
||||
cin >> next_fish;
|
||||
fish[next_fish]++;
|
||||
}
|
||||
|
||||
unsigned long long total_fish = 300;
|
||||
for(int i = 0; i < 256; i++)
|
||||
{
|
||||
unsigned long long spawning_fish = fish[0];
|
||||
total_fish += spawning_fish;
|
||||
|
||||
for(int j = 1; j < 9; j++)
|
||||
{
|
||||
fish[j-1] = fish[j];
|
||||
}
|
||||
|
||||
fish[6] += spawning_fish;
|
||||
fish[8] = spawning_fish;
|
||||
}
|
||||
|
||||
cout << total_fish << endl;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user