aboutsummaryrefslogtreecommitdiff
path: root/codechef
diff options
context:
space:
mode:
authorOmar Magdy <omar.professional8777@gmail.com>2022-05-31 01:17:07 +0200
committerOmar Magdy <omar.professional8777@gmail.com>2022-05-31 01:17:07 +0200
commit64951951612753d467823dd5a3ddcc1916ad0a97 (patch)
tree713a8ed1e28ff3b76100997248d21ea612e32324 /codechef
parent3a89fc707253f75f46fd5a4822817f1fd5156c40 (diff)
downloadcompetitive-programming-64951951612753d467823dd5a3ddcc1916ad0a97.tar.xz
competitive-programming-64951951612753d467823dd5a3ddcc1916ad0a97.zip
Solved hardcash from codechef
Diffstat (limited to 'codechef')
-rwxr-xr-xcodechef/cleanup.sh11
-rw-r--r--codechef/hardCash/hardCash.cpp14
-rw-r--r--codechef/hardCash/inp5
-rwxr-xr-xcodechef/hardCash/mainbin0 -> 31512 bytes
-rw-r--r--codechef/hardCash/main.cpp26
5 files changed, 31 insertions, 25 deletions
diff --git a/codechef/cleanup.sh b/codechef/cleanup.sh
deleted file mode 100755
index 410c246..0000000
--- a/codechef/cleanup.sh
+++ /dev/null
@@ -1,11 +0,0 @@
-#!/bin/sh
-
-files=$(ls)
-
-for file in files do
- tmp=$(echo $dir | sed 's/.cpp//')
- mkdir $tmp
- mv $file $tmp
- cd ..
-done
-
diff --git a/codechef/hardCash/hardCash.cpp b/codechef/hardCash/hardCash.cpp
deleted file mode 100644
index 5f6862e..0000000
--- a/codechef/hardCash/hardCash.cpp
+++ /dev/null
@@ -1,14 +0,0 @@
-#include<bits/stdc++.h>
-
-using namespace std;
-
-int main () {
- ios_base::sync_with_stdio(false);
- cin.tie(NULL);
- int tt;
- cin >> tt;
- while(tt--){
-
-
- }
-}
diff --git a/codechef/hardCash/inp b/codechef/hardCash/inp
new file mode 100644
index 0000000..617f23b
--- /dev/null
+++ b/codechef/hardCash/inp
@@ -0,0 +1,5 @@
+2
+5 7
+1 14 4 41 1
+3 9
+1 10 19
diff --git a/codechef/hardCash/main b/codechef/hardCash/main
new file mode 100755
index 0000000..7aa621a
--- /dev/null
+++ b/codechef/hardCash/main
Binary files differ
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 <bits/stdc++.h>
+
+using namespace std;
+
+long long sum(vector<int> 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<int> v(n);
+ for (int &x : v)
+ cin >> x;
+ cout << sum(v) % k << '\n';
+ }
+}