798A - . Mike and palindrome memory limit per test 256 megabytes input standard input output standard output Mike has a string s consisting of only lowercase English letters. He wants to change exactly one character from the string so that the resulting one is a palindrome. A palindrome is a string that reads the same backward as forward, for example strings " z ", " aaa ", " aba ", " abccba " are palindromes, but strings " codeforces ", " reality ", " ab " are not. Input The first and single line contains string s ( 1 ≤ | s | ≤ 15 ). Output Print " YES " (without quotes) if Mike can change exactly one character so that the resulting string is palindrome or " NO " (wi...
262A - Roma and Lucky Numbers #include < bits / stdc ++. h > using namespace std ; int main () { int n , k , c = 0 , ans = 0 ; cin >> n >> k ; while ( n --) { c = 0 ; string s ; cin >> s ; for ( int i = 0 ; i < s . length (); i ++){ if ( s [ i ]== '4' or s [ i ]== '7' ) c ++; } if ( c <= k ) ans ++; } cout << ans ; return 0 ; }
#include <iostream> #include <algorithm> using namespace std ; int main () { long int n ; cin >> n ; long long arr [ n ]; for ( int j = 0 ; j < n ; j ++){ cin >> arr [ j ];} sort ( arr , arr + n ); int b = arr [ 0 ]; int l = arr [ n - 1 ]; int x = 0 ; for ( int i = b ; i <= l ; i ++) { x ++; } cout << x - n ; return 0 ; }
Comments
Post a Comment