CF1582G.Kuzya and Homework

普及/提高-

通过率:0%

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

Kuzya started going to school. He was given math homework in which he was given an array aa of length nn and an array of symbols bb of length nn , consisting of symbols '*' and '/'.

Let's denote a path of calculations for a segment [l;r][l; r] ( 1lrn1 \le l \le r \le n ) in the following way:

  • Let x=1x=1 initially. For every ii from ll to rr we will consequently do the following: if bi=b_i= '*', x=xaix=x*a_i , and if bi=b_i= '/', then x=xaix=\frac{x}{a_i} . Let's call a path of calculations for the segment [l;r][l; r] a list of all xx that we got during the calculations (the number of them is exactly rl+1r - l + 1 ).

For example, let a=[7,a=[7, 12,12, 3,3, 5,5, 4,4, 10,10, 9]9] , b=[/,b=[/, ,*, /,/, /,/, /,/, ,*, ]*] , l=2l=2 , r=6r=6 , then the path of calculations for that segment is [12,[12, 4,4, 0.8,0.8, 0.2,0.2, 2]2] .

Let's call a segment [l;r][l;r] simple if the path of calculations for it contains only integer numbers.

Kuzya needs to find the number of simple segments [l;r][l;r] ( 1lrn1 \le l \le r \le n ). Since he obviously has no time and no interest to do the calculations for each option, he asked you to write a program to get to find that number!

输入格式

The first line contains a single integer nn ( 2n1062 \le n \le 10^6 ).

The second line contains nn integers a1,a2,,ana_1, a_2, \ldots, a_n ( 1ai1061 \le a_i \le 10^6 ).

The third line contains nn symbols without spaces between them — the array b1,b2bnb_1, b_2 \ldots b_n ( bi=b_i= '/' or bi=b_i= '*' for every 1in1 \le i \le n ).

输出格式

Print a single integer — the number of simple segments [l;r][l;r] .

输入输出样例

  • 输入#1

    3
    1 2 3
    */*

    输出#1

    2
  • 输入#2

    7
    6 4 10 1 2 15 1
    */*/*//

    输出#2

    8
首页