1. 程式人生 > >hdu 6134 (莫比烏斯函式,預處理快速求因子個數)

hdu 6134 (莫比烏斯函式,預處理快速求因子個數)

> The Death Star, known officially as the DS-1 Orbital Battle Station, also known as the Death Star I, the First Death Star, Project Stardust internally, and simply the Ultimate Weapon in early development stages, was a moon-sized, deep-space mobile battle station constructed by the Galactic Empire. Designed to fire a single planet-destroying superlaser powered by massive kyber crystals, it was the pet project of the Emperor, Darth Vader, and its eventual commander Grand Moff Wilhuff Tarkin to expound the military philosophy of the aptly named Tarkin Doctrine. 

> — Wookieepedia 

In the story of the Rogue One, the rebels risked their lives stolen the construction plan of the Death Star before it can cause catastrophic damage to the rebel base. According to the documents, the main weapon of the Death Star, the Superlaser, emits asymmetric energy in the battlefield that cause photons to annihilate and burns everything in a single shot. 

You are assigned the task to estimate the damage of one shot of the Superlaser.

Assuming that the battlefield is an n
×n
n×n
 grid. The energy field ignited by the Superlaser is asymmetric over the grid. For the cell at ii-th row and jj-th column, i/j⌈i/j⌉ units of damage will be caused. Furthermore, due to the quantum effects, the energies in a cell cancel out if gcd(i,j)1gcd(i,j)≠1 or i<ji<j

The figure below illustrates the damage caused to each cell for n
=100
n=100
. A cell in black indicates that this cell will not be damaged due to the quantum effects. Otherwise, different colors denote different units of damages. 

Your should calculate the total damage to the battlefield. Formally, you should compute 
f(n)=i=1nj=1iij[(i,j)=1],f(n)=∑i=1n∑j=1i⌈ij⌉[(i,j)=1],


where [(i,j)=1][(i,j)=1] evaluates to be 11 if gcd(i,j)=1gcd(i,j)=1, otherwise 00. InputThere are multiple test cases.