1285A - Mezo Playing Zoma - CodeForces Solution


math *800

Please click on ads to support us..

Python Code:


import bisect
import random

mod = 10 ** 9 + 7
eps = 10 ** -9

def _miillerTest(d, n):
    a = 2 + random.randint(1, n - 4)
    x = pow(a, d, n)
    if (x == 1 or x == n - 1):
        return True
    while (d != n - 1):
        x = (x * x) % n
        d *= 2;
 
        if (x == 1):
            return False
        if (x == n - 1):
            return True
    return False;

def _isprime(n):
    if (n < 2 or n == 4):
        return False
    if (n <= 3):
        return True
    d = n - 1;
    while (d % 2 == 0):
        d //= 2
    for i in range(5):
        if (_miillerTest(d, n) == False):
            return False
 
    return True

def _gcd(a, b):
    return a if b == 0 else _gcd(b, a % b)
  

def _lcm(a, b):
  return a * b / __gcd(a, b)

def _mex(a):
    mex = 0
    a.sort()
    for x in a:
        if x <= mex:
            mex += 1
        else:
            break
    return mex

def _dist(x1, y1, x2, y2):
  return (x1 - x2) ** 2 + (y1 - y2) ** 2

def _getprimes(n, m):
    primes = []
    if n <= 2:
        primes.append(2)
    if n % 2 == 0:
        n += 1
    for i in range(n, m + 1, 2):
        if _isprime(i):
            primes.append(i)
    return primes
  
def _primefactors(n):
    ret = []
    x = n
    i = 2
    if _isprime(n):
        ret.append(n)
        return ret
    while i * i <= x:
        while n % i == 0:      
            ret.append(i)
            n //= i
            if _isprime(n):
                break
        i += 1
    if n > 1:
        ret.append(n)
    return ret
  
def _pollardrho(n):
    if n % 2 == 0: return 2
    if _isprime(n): return n
    while True:
        c = random.randint(2, n -1)
        f = lambda x: x**2 + c 
        x = y = 2 
        d = 1 
        while d == 1:
            x = f(x) % n 
            y = f(f(y)) % n 
            d = _gcd((x - y) % n, n)
        
        if d != n and _isprime(d): return d

def _sumdigit(n):
  ret = 0
  while n > 0:
    ret += n % 10
    n //= 10
  return ret

def _modinverse(n, m):
    return (n % mod) * (pow(m, mod - 2, mod) % mod) % mod


def linp(type = int):
	return list(map(type, input().split()))
 
def minp(type = int):
	return map(type, input().split())
 
def tinp(type = int):
	return type(input())


def solve(t):
	n = tinp()
	s = tinp(str)
	print(s.count('L') + s.count('R') + 1)
t = 1
for i in range(t):
    solve(i + 1)

C++ Code:

#include <iostream>
using namespace std;

int main()
{
    int n;
    cin>>n;
    string s;
    cin>>s;
    cout<<n+1;



    return 0;
}


Comments

Submit
0 Comments
More Questions

946. Validate Stack Sequences
921. Minimum Add to Make Parentheses Valid
881. Boats to Save People
497. Random Point in Non-overlapping Rectangles
528. Random Pick with Weight
470. Implement Rand10() Using Rand7()
866. Prime Palindrome
1516A - Tit for Tat
622. Design Circular Queue
814. Binary Tree Pruning
791. Custom Sort String
787. Cheapest Flights Within K Stops
779. K-th Symbol in Grammar
701. Insert into a Binary Search Tree
429. N-ary Tree Level Order Traversal
739. Daily Temperatures
647. Palindromic Substrings
583. Delete Operation for Two Strings
518. Coin Change 2
516. Longest Palindromic Subsequence
468. Validate IP Address
450. Delete Node in a BST
445. Add Two Numbers II
442. Find All Duplicates in an Array
437. Path Sum III
436. Find Right Interval
435. Non-overlapping Intervals
406. Queue Reconstruction by Height
380. Insert Delete GetRandom O(1)
332. Reconstruct Itinerary