From 1dabc2c762af2c0abc64b05b53bba82d632d3601 Mon Sep 17 00:00:00 2001 From: Singhal-Coder Date: Wed, 1 May 2024 18:33:31 +0530 Subject: [PATCH] Adding Solutions to given problems --- Question-1/Answer-1.cpp | 26 ++++++++++++++++++++++++++ question-2/Answer-2.cpp | 20 ++++++++++++++++++++ 2 files changed, 46 insertions(+) create mode 100644 Question-1/Answer-1.cpp create mode 100644 question-2/Answer-2.cpp diff --git a/Question-1/Answer-1.cpp b/Question-1/Answer-1.cpp new file mode 100644 index 0000000..520cefc --- /dev/null +++ b/Question-1/Answer-1.cpp @@ -0,0 +1,26 @@ +#include +using namespace std; + +void solve(){ + int n; + cin >> n; + int arr[n]; + map mp; + for(int i{0}; i> arr[i]; + mp[arr[i]]++; + } + int ans = 0; + for(auto x:mp) ans+=x.second/3; + cout << ans; +} + +int main(){ + int t; + cin >> t; + while(t--){ + solve(); + cout << '\n'; + } + return 0; +} \ No newline at end of file diff --git a/question-2/Answer-2.cpp b/question-2/Answer-2.cpp new file mode 100644 index 0000000..0873cf5 --- /dev/null +++ b/question-2/Answer-2.cpp @@ -0,0 +1,20 @@ +#include +using namespace std; + +void solve(){ + int n; + cin >> n; + int trailing_zeros = 0; + for(int i{5}; i<=n; i*=5) trailing_zeros+=n/i; + cout << trailing_zeros; +} + +int main(){ + int t; + cin >> t; + while(t--){ + solve(); + cout << '\n'; + } + return 0; +} \ No newline at end of file