Search
 
SCRIPT & CODE EXAMPLE
 

CPP

Codeforces Round #376 (Div. 2), problem: (A) Night at the Museum

#include<iostream>
#include<cmath>
using namespace std;
#include<cstring>

int main()
{
	int sum = 0;
	char ch[100];
	cin >> ch;
	char begin = 'a';
	for (int i = 0; i <strlen(ch); i++)
	{
		int l1 = abs(ch[i] - begin);
		int l2 = 26 - abs(l1);
		sum += min(l1, l2);
		begin = ch[i];
	}
	cout << sum << endl;
	return 0;
}
Comment

PREVIOUS NEXT
Code Example
Cpp :: wap in c++ to understand function template 
Cpp :: pca compact trick 
Cpp :: qt/c++ exception handler 
Cpp :: 1603. Design Parking System leetcode solution in c++ 
Cpp :: how to read qlistwidget in c++ 
Cpp :: Smooth Poti values on Arduino 
Cpp :: frc limelight tracking 
Cpp :: Lapindromes codechef solution in c++ 
Cpp :: 1162261467 
Cpp :: multiply two arbitrary integers a and b (a greater than b) 
Cpp :: nlohmann json, writing to json file 
Cpp :: bullet physics directx 11 
Cpp :: online c++ compiler 
Cpp :: print number with leading zeros 
Cpp :: Determine if map contains a value for a key c++ 
Cpp :: Set Specific Time in youtube Video url 
Cpp :: string to wstring conversion c++ 
Cpp :: x += c++ 
Cpp :: read from standard input cpp 
Cpp :: tan ^-1 ti 83 
C :: what is meaning of product *= in c 
C :: Animated sprite from few images pygame 
C :: convert string to float c 
C :: simplify fractions C 
C :: sigaction in c 
C :: get time to complete code c 
C :: what is strikethrough in markdown 
C :: how to combine strings in c 
C :: fopen function in c 
C :: strcmp c 
ADD CONTENT
Topic
Content
Source link
Name
8+3 =