diff options
author | crupest <crupest@outlook.com> | 2021-03-11 23:05:14 +0800 |
---|---|---|
committer | crupest <crupest@outlook.com> | 2021-03-11 23:05:14 +0800 |
commit | e5ab5e760d64d047ab785168d65650cf6d41ec41 (patch) | |
tree | f24c236f50457e0eca5b70805af422851cf2f326 /acwing | |
parent | 8f2f4de3431ad8e38922495ecfc62af41f0fc252 (diff) | |
download | solutions-e5ab5e760d64d047ab785168d65650cf6d41ec41.tar.gz solutions-e5ab5e760d64d047ab785168d65650cf6d41ec41.tar.bz2 solutions-e5ab5e760d64d047ab785168d65650cf6d41ec41.zip |
Add problem 1230.
Diffstat (limited to 'acwing')
-rw-r--r-- | acwing/1230.cpp | 36 |
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;
+}
|