From 011e4c04585a67c417b599a8e68036875f0ac607 Mon Sep 17 00:00:00 2001 From: ayham Date: Sun, 9 May 2021 19:54:29 +0300 Subject: [PATCH] solved hackerrank viral advertising Signed-off-by: ayham --- hackerrank.viral.advertising.cpp | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 hackerrank.viral.advertising.cpp diff --git a/hackerrank.viral.advertising.cpp b/hackerrank.viral.advertising.cpp new file mode 100644 index 0000000..7ea738e --- /dev/null +++ b/hackerrank.viral.advertising.cpp @@ -0,0 +1,16 @@ +#include +using namespace std; + +int main() { + int n; + cin >> n; + int recipients = 5; + int total_likes = 0; + while (n--) { + total_likes += floor(recipients/2); + recipients = floor(recipients/2)*3; + } + cout << total_likes <