We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
소스 코드
26개의 문자에 대해서 누적합 배열을 만들고 구간의 합을 구한다 (특정 문자가 등장하면 +1) 문자 i에 대해서 구간 [x, y]의 구간합은 다음과 같다. s[i][y] - s[i][x-1] 단, x == 0일 때 s[i][x-1] == 0이다
s[i][y] - s[i][x-1]
x == 0
s[i][x-1] == 0
문자가 아스키코드로 표현됨을 활용하여 (문자의 아스키코드) - 'a'로 알파벳을 0~25로 매칭한다
(문자의 아스키코드) - 'a'
for(int i = 0; i<str.length(); ++i) { s[str[i] - 'a'][i] += 1; if(i > 0) { for(int j = 'a'; j<='z'; ++j) { s[j - 'a'][i] += s[j - 'a'][i-1]; } } } for(int i = 0; i<N; ++i) { cin >> alphabet >> m >> n; if(m == 0) { cout << s[alphabet-'a'][n] << endl; continue; } cout << s[alphabet-'a'][n] - s[alphabet-'a'][m-1] << endl; }
The text was updated successfully, but these errors were encountered:
minsoo0715
No branches or pull requests
16139: 인간-컴퓨터 상호작용
소스 코드
아이디어
26개의 문자에 대해서 누적합 배열을 만들고 구간의 합을 구한다 (특정 문자가 등장하면 +1)
문자 i에 대해서 구간 [x, y]의 구간합은 다음과 같다.
s[i][y] - s[i][x-1]
단,x == 0
일 때s[i][x-1] == 0
이다구현
문자가 아스키코드로 표현됨을 활용하여
(문자의 아스키코드) - 'a'
로 알파벳을 0~25로 매칭한다The text was updated successfully, but these errors were encountered: