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 | 14820ccd6c6c78ee1daa5d7cbdaaf8b34298fe2f (patch) | |
tree | 511d7d5356e7249efab0ac32f29b1182edd53508 /works/solutions/acwing/1230.cpp | |
parent | d8c415b249d0f5d327ae4a4c2123446b53337b40 (diff) | |
download | crupest-14820ccd6c6c78ee1daa5d7cbdaaf8b34298fe2f.tar.gz crupest-14820ccd6c6c78ee1daa5d7cbdaaf8b34298fe2f.tar.bz2 crupest-14820ccd6c6c78ee1daa5d7cbdaaf8b34298fe2f.zip |
import(solutions): Add problem 1230.
Diffstat (limited to 'works/solutions/acwing/1230.cpp')
-rw-r--r-- | works/solutions/acwing/1230.cpp | 36 |
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;
+}
|