原创 HDU - 4746 (莫比烏斯反演)

As we know, any positive integer C ( C >= 2 ) can be written as the multiply of some prime numbers:     C = p1×p2× p3×

原创 codeforces 296B - Yaroslav and Two Strings (DP+容斥)

B. Yaroslav and Two Strings Yaroslav thinks that two strings s and w, consisting of digits and having length n

原创 LightOJ - 1245

I was trying to solve problem '1234 - Harmonic Number', I wrote the following code long long H( int n ) {     long lon

原创 LightOJ - 1282(n^k的前三位數字和後三位數字)

    You are given two integers: n and k, your task is to find the most sig

原创 UVA 7040

大意:有一排一共n個珠子,要用m種顏色中的恰好k種去塗色,相鄰的兩個顏色要不同,問方案數。 做法大概就是C(m,k)表示m中k種顏色,然後對於每k個顏色進行容斥(大概就是這樣) 代碼: #include <iostream> #incl

原创 HDU - 4675(莫比烏斯反演)

Alice is playing a game with Bob. Alice shows N integers a 1, a 2, …, a N

原创 LightOJ - 1220

Dr. Mob has just discovered a Deathly Bacteria. He named it RC-01. RC-01 has a very strange reproduction system. RC-01

原创 LightOJ - 1341 合數分解

It's said that Aladdin had to solve seven mysteries before getting the Magical Lamp which summons a powerful Genie. Her

原创 LightOJ - 1336 Sigma Function (n以內約數和爲奇數(偶數)的數的個數)

Sigma function is an interesting function in Number Theory. It is denoted by the Greek letter Sigma (σ). This function

原创 Codeforces 547C - Mike and Foam (容斥)

在這個題用容斥做的過程中從別人的博客學到了一些有趣的處理方法(好吧,其實是我太菜了,那種方法我之前沒見過)。。。。。。 思路:先預處理出每個數的質因子然後對於每一個操作數算出與它互質的數的個數再加加減減。。。。。。詳見代碼,可能有說不清楚

原创 LightOJ - 1356

素數+二分圖 二分圖我不會暫時就不給代碼了 A set of integers is called prime independent if none of its member is a prime multiple of anot

原创 SPOJ - VLATTICE Visible Lattice Points (莫比烏斯反演)

Consider a N*N*N lattice. One corner is at (0,0,0) and the opposite one is

原创 UVA - 11426

可以轉化成求n以內gcd爲1的,gcd爲2的………gcd爲n-1的i,j(i<j≤n)的對數,然後對數乘以相應的gcd即可 然後gcd爲k的i,j的對數爲m=n/k以內的i,j互質的對數,即2以內與2互質的數的數目+3以內與3互質的數的

原创 LightOJ - 1138

You task is to find minimal natural number N, so that N! contains exactly Q zeroes on the trail in decimal notation. A

原创 LightOJ - 1220(n=b^k時最大的k,GCD)

Dr. Mob has just discovered a Deathly Bacteria. He named it RC-01. RC-01 has a very strange reproduction system. RC-01