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 a of length n and an array of symbols b of length n , consisting of symbols '*' and '/'.
Let's denote a path of calculations for a segment [l;r] ( 1≤l≤r≤n ) in the following way:
- Let x=1 initially. For every i from l to r we will consequently do the following: if bi= '*', x=x∗ai , and if bi= '/', then x=aix . Let's call a path of calculations for the segment [l;r] a list of all x that we got during the calculations (the number of them is exactly r−l+1 ).
For example, let a=[7, 12, 3, 5, 4, 10, 9] , b=[/, ∗, /, /, /, ∗, ∗] , l=2 , r=6 , then the path of calculations for that segment is [12, 4, 0.8, 0.2, 2] .
Let's call a segment [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] ( 1≤l≤r≤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 n ( 2≤n≤106 ).
The second line contains n integers a1,a2,…,an ( 1≤ai≤106 ).
The third line contains n symbols without spaces between them — the array b1,b2…bn ( bi= '/' or bi= '*' for every 1≤i≤n ).
输出格式
Print a single integer — the number of simple segments [l;r] .
输入输出样例
输入#1
3 1 2 3 */*
输出#1
2
输入#2
7 6 4 10 1 2 15 1 */*/*//
输出#2
8