aboutsummaryrefslogtreecommitdiff
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
commitfbf896d210c528c7a8bd499a79c189c049f8424d (patch)
tree729ac490c31e943872f68decf20de76feb5a8c74
parentbc8d6a406174fe250af4124b5156e6e86f22a9a0 (diff)
downloadcrupest-fbf896d210c528c7a8bd499a79c189c049f8424d.tar.gz
crupest-fbf896d210c528c7a8bd499a79c189c049f8424d.tar.bz2
crupest-fbf896d210c528c7a8bd499a79c189c049f8424d.zip
import(solutions): Add problem 1230.
-rw-r--r--works/solutions/acwing/1230.cpp36
1 files changed, 36 insertions, 0 deletions
diff --git a/works/solutions/acwing/1230.cpp b/works/solutions/acwing/1230.cpp
new file mode 100644
index 0000000..958cbdd
--- /dev/null
+++ b/works/solutions/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;
+}