序列和大数的计算的问题,如何运用C语言计算的呢,具体的思路

Problem Description
There is an old country and the king fell in love with a devil. The devil always asks the king to do some crazy things. Although the king used to be wise and beloved by his people. Now he is just like a boy in love and can’t refuse any request from the devil. Also, this devil is looking like a very cute Loli.

Let us continue our story, z*p(actually you) defeat the 'MengMengDa' party's leader, and the 'MengMengDa' party dissolved. z*p becomes the most famous guy among the princess's knight party.

One day, the people in the party find that z*p has died. As what he has done in the past, people just say 'Oh, what a nice boat' and don't care about why he died.

Since then, many people died but no one knows why and everyone is fine about that. Meanwhile, the devil sends her knight to challenge you with Algorithm contest.

There is a hard data structure problem in the contest:

There are n numbers a_1,a_2,...,a_n on a line, everytime you can change every number in a segment [l,r] into a number x(type 1), or change every number a_i in a segment [l,r] which is bigger than x to gcd(a_i,x) (type 2).

You should output the final sequence.

Input
The first line contains an integer T, denoting the number of the test cases.
For each test case, the first line contains a integers n.
The next line contains n integers a_1,a_2,...,a_n separated by a single space.
The next line contains an integer Q, denoting the number of the operations.
The next Q line contains 4 integers t,l,r,x. t denotes the operation type.

T<=2,n,Q<=100000
a_i,x >=0
a_i,x is in the range of int32(C++)

Output
For each test case, output a line with n integers separated by a single space representing the final sequence.
Please output a single more space after end of the sequence

Sample Input
1
10
16807 282475249 1622650073 984943658 1144108930 470211272 101027544 1457850878 1458777923 2007237709
10
1 3 6 74243042
2 4 8 16531729
1 3 4 1474833169
2 1 8 1131570933
2 7 9 1505795335
2 3 7 101929267
1 4 10 1624379149
2 2 8 2110010672
2 6 7 156091745
1 2 5 937186357

Sample Output
16807 937186357 937186357 937186357 937186357 1 1 1624379149 1624379149 1624379149

Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
立即提问

相似问题

0
一个序列求极值的一个算法的问题,要运用C语言的办法如何才能解决呢
0
求序列的鞍点的一个算法的问题,运用C编程语言如何解决这问题的呢
0
KMP序列匹配算法的一个实现原理问题,采用C语言方式的编程计算
0
序列的转置的算法的问题的计算的方式,使用C语言的编程算法技术
0
字符串的字符的序列的距离的计算,怎么采用C语言的程序的实现的思路怎么做?
0
多次的计算的子序列算法问题,怎么采用的C语言程序编写的办法实现的?
0
算术序列的运用公式的计算,运用的是C语言的程序代码编写的过程的实现的方式,怎么做
0
最长递增序列的问题,怎么利用C语言的程序代码编写的程序的方式如何来计算的?
0
由真分数构成的一个序列的计算的问题,怎么采用C语言的程序代码编写技术的知识实现的呢?
0
最长有序的子序列配对问题,怎么运用C语言的程序的代码编写的过程去实现的呢?
0
分段函数的条件的匹配问题计算序列的值,怎么使用C语言的程序所实现的代码的过程的思想的
0
线性的递归序列问题的计算,采用的是 C 语言编程语言的程序设计的手段,如何写出代码来实现的
0
序列计算连续最大积,怎么使用C语言的程序编写代码方式有效加以实现的
0
对于给定的N对双胞胎,计算是否有一个年龄序列满足条件,用C语言的程序的代码编写的过程实现的方式
0
计算递增子序列的长度,怎么用C语言的程序代码编写的设计思想运用的技术来编程
0
计算DNA基因序列的长度,怎么用C语言的程序设计的思想方式和技术来计算的呢?
0
计算线性序列的节点编号问题,怎么使用C语言的程序设计思想的办法有效解决计算问题
0
设计一个序列号的计算的算法的问题,怎么采用C语言的代码的编写的过程的方式有效地实现怎么写
0
偶数求和的计算的一个问题,如何利用C语言来表达
0
偶数求和 如何运用C语言