One day Vitaly was going home late at night and wondering: how many people aren't sleeping at that moment? To estimate, Vitaly decided to look which windows are lit in the house he was passing by at that moment. Vitaly sees a building of n floors and 2· m windows on each floor. On each floor there are m flats numbered from 1 to m , and two consecutive windows correspond to each flat. If we number the windows from 1 to 2· m from left to right, then the j -th flat of the i -th floor has windows 2· j - 1 and 2· j in the corresponding row of windows (as usual, floors are enumerated from the bottom). Vitaly thinks that people in the flat aren't sleeping at that moment if at least one of the windows corresponding to this flat has lights on. Given the information about the windows of the given house, your task is to calculate the number of flats where, ac...
Problem link Solution O(1) #include <stdio.h> #include <iostream> using namespace std ; int main () { long int l , r ; int t ; cin >> t ; long int x = l , y = r ; while ( t --) { scanf ( "%ld" ,& l ); scanf ( "%ld" ,& r ); y = r ; int mod =( r % l ); cout << l << " " << r - mod << endl ; mod = 0 ; } return 0 ;}
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...
Comments
Post a Comment