From 64951951612753d467823dd5a3ddcc1916ad0a97 Mon Sep 17 00:00:00 2001 From: Omar Magdy Date: Tue, 31 May 2022 01:17:07 +0200 Subject: Solved hardcash from codechef --- codechef/hardCash/main.cpp | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 codechef/hardCash/main.cpp (limited to 'codechef/hardCash/main.cpp') diff --git a/codechef/hardCash/main.cpp b/codechef/hardCash/main.cpp new file mode 100644 index 0000000..2b49804 --- /dev/null +++ b/codechef/hardCash/main.cpp @@ -0,0 +1,26 @@ +#include + +using namespace std; + +long long sum(vector v) { + long long sum = 0; + for(int i = 0; i < v.size(); i++) { + sum += v[i]; + } + return sum; +} + +int main() { + ios_base::sync_with_stdio(false); + cin.tie(NULL); + int tt; + cin >> tt; + while (tt--) { + int n, k; + cin >> n >> k; + vector v(n); + for (int &x : v) + cin >> x; + cout << sum(v) % k << '\n'; + } +} -- cgit v1.2.3