summaryrefslogtreecommitdiff
path: root/acwing/1230.cpp
diff options
context:
space:
mode:
authorcrupest <crupest@outlook.com>2021-03-11 23:05:14 +0800
committercrupest <crupest@outlook.com>2021-03-11 23:05:14 +0800
commite5ab5e760d64d047ab785168d65650cf6d41ec41 (patch)
treef24c236f50457e0eca5b70805af422851cf2f326 /acwing/1230.cpp
parent8f2f4de3431ad8e38922495ecfc62af41f0fc252 (diff)
downloadsolutions-e5ab5e760d64d047ab785168d65650cf6d41ec41.tar.gz
solutions-e5ab5e760d64d047ab785168d65650cf6d41ec41.tar.bz2
solutions-e5ab5e760d64d047ab785168d65650cf6d41ec41.zip
Add problem 1230.
Diffstat (limited to 'acwing/1230.cpp')
-rw-r--r--acwing/1230.cpp36
1 files changed, 36 insertions, 0 deletions
diff --git a/acwing/1230.cpp b/acwing/1230.cpp
new file mode 100644
index 0000000..958cbdd
--- /dev/null
+++ b/acwing/1230.cpp
@@ -0,0 +1,36 @@
+#include <iostream>
+
+using ll = long long;
+
+const int M = 100010;
+
+int N, K;
+ll p;
+int c[M];
+ll result;
+
+int main() {
+ std::ios_base::sync_with_stdio(false);
+ std::cin.tie(nullptr);
+
+ std::cin >> N >> K;
+
+ c[0] = 1;
+
+ for (int i = 1; i <= N; i++) {
+ int a;
+ std::cin >> a;
+
+ p += a;
+
+ int r = p % K;
+
+ result += c[r];
+
+ c[r]++;
+ }
+
+ std::cout << result;
+
+ return 0;
+}