Discription Problem statement is simple. Given A and B you need to calculate S(A,B) . Here, f(n)=n, if n is square free otherwise 0. Also f(1)=1. Input The first line contains one integer T - denoting the number of test cases. T lines follow each con…
题目连接:http://www.spoj.com/problems/LGLOVE/ 题意:给出n个初始序列a[1],a[2],...,a[n],b[i]表示LCM(1,2,3,...,a[i]),即1~a[i]的最小公倍数 然后给出三种操作,注意:0<=i,j<n 0 i j p :a[i]~a[j]都加上p 1 i j :求LCM(b[i],b[i+1],...,b[j]) 2 i j :求GCD(b[i],b[i+1],...,b[j]) 思路: 求LCM(b[i],b[i+1],...,…
SPOJ Problem Set (classical) 7001. Visible Lattice Points Problem code: VLATTICE Consider a N*N*N lattice. One corner is at (0,0,0) and the opposite one is at (N,N,N). How many lattice points are visible from corner at (0,0,0) ? A point X is visible…
3871. GCD Extreme Problem code: GCDEX Given the value of N, you will have to find the value of G. The meaning of G is given in the following code G=0; for(k=i;k< N;k++) for(j=i+1;j<=N;j++) { G+=gcd(k,j); } /*Here gcd() is a function that finds the g…
4491. Primes in GCD Table Problem code: PGCD Johnny has created a table which encodes the results of some operation -- a function of two arguments. But instead of a boring multiplication table of the sort you learn by heart at prep-school, he has cre…