Codeforces Round 560 Div. 3 A Remainder
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 | #include <iostream> #include <vector> #include <queue> #include <algorithm> #include<string> #include <cstring> //memset using namespace std; const int MAX = 100000 + 2; int n, x, y; int Big; int main(void) { cin >> n >> x >> y; string s; cin >> s; string s1 = s.substr(n - x); // 10^x까지 잘라준다. int pos = 0; int cnt = 0; //10^y인 곳은 1이어야 하고, 나머지는 0 for (int i = s1.size() - 1; i >= 0; i--) { if (pos == y) { if (s1[i] == '0') cnt++; } else { if (s1[i] == '1') cnt++; } pos++; } cout << cnt; return 0; } | cs |
단순 구현 문제였습니다.
'알고리즘 > Codeforce' 카테고리의 다른 글
Codeforces Round 560 Div 3 C Good String (0) | 2019.05.18 |
---|---|
Codeforces Round 560 Div. 3 B Polycarp Training (0) | 2019.05.18 |
Codeforces Round 560 Div. 3 D Almost All Divisors (0) | 2019.05.18 |
코드포스 Superhero Transformation (0) | 2019.02.10 |