原创 2018 ICPC 瀋陽網絡賽 G. Spare Tire 1到n中與m互質的平方和與本身和

計蒜客 全部課程  學習計劃 題庫 比賽  Spare Tire 編輯代碼  15.27%  1000ms  131072K A sequence of integer \lbrace a_n \rbrace{an​} can be ex

原创 01揹包詳解

揹包問題是動態規劃(dp)的一種,但是它的解法相對來說比較特別,所以我們把它單獨列出來學習和分析,但是它的基本思想還是dp。關於概念就不多說了,大家可以參考我以上所提到的資料,上面對概念的講解都是比較獨到和權威的。   而01揹包是最典型

原创 Hdu1087 Poj1458 Hdu 2602

Super Jumping! Jumping! Jumping!  Hdu1087 #include<bits/stdc++.h> const int maxn = 1005; typedef long long ll; using n

原创 多重揹包(二進制優化)hdu 1059

#include<bits/stdc++.h> const int maxn = 500000; typedef long long ll; using namespace std; int dp[maxn],n[7],a[maxn];

原创 xyz 的fft 模板

這是我在找的比較好用的,適用情況廣,比較清晰的fft模板了! #include <stdio.h> #include <string.h> #include <iostream> #include <algorithm> #includ

原创 HDU6265(能被n整除的因子與其歐拉乘積的和)

由這兩個公式聯立 公式很顯然我們可以消去d可以推出: 我們知道對於每個pi,我們都有qi種取法,根據歐拉函數的性質我們知道每一個質數的的倍數的歐拉函數值 都等於這個質數的歐拉函數值等於其擴大的倍數,正好其外面縮小倍數也爲其歐拉擴大的倍數,

原创 我的第一道杜教篩(莫比烏斯函數求和 51Nod-1244)

先總結一下,杜教篩的的精髓之處我認爲在於通過兩個積性函數做狄利克雷卷積以後就可以對其進行整除分塊了,又因爲一般用到杜教篩的題目數據量都特別大,是o(n)時間都跑不過來的數據,所以肯定不能預處理。但是這樣的題樣例數量不會太大,你只能每一次都

原创 經典小知識融合數論題(hdu-5528)

B - Count a * b  HDU - 5528  Marry likes to count the number of ways to choose two non-negative integers a and b less t

原创 逆元的幾種求法

1、快速冪直接求(要求取模的數爲質數) 由費馬小定理可得,如果p爲質數,則a^(p-1)%c=1=a*a^(p-2)%c; 如果a*b%mod=1; 則a爲b的逆元,b也爲a的逆元。 a的逆元爲a^(mod-2). ll pow_mod(

原创 另類容斥和歐拉函數巧妙應用(HDU--5514)

There are mm stones lying on a circle, and nn frogs are jumping over them.  The stones are numbered from 00 to m−1m−1 a

原创 莫比烏斯函數的求法

sqrt(n)求解莫比烏斯函數值,如果把素數篩出來會使求解莫比烏斯函數更快。 ll getmu(ll n) {     ll v=1;     for(int i=2;i*i<=n;i++)      if(n%i==0)      {

原创 異或和與組合數(HDU - 4810)按二進制位拆分

Ms.Fang loves painting very much. She paints GFW(Great Funny Wall) every day. Every day before painting, she produces a

原创 xyz的計算圓與多邊形相交面積模板

#include<bits/stdc++.h>   using namespace std;   const double eps = 1e-8; const double PI = acos(-1.0);   int dcmp(doub

原创 xyz的向量旋轉模板

#include<iostream> #include<algorithm> #include<stdio.h> #include<math.h> #include<cstring> #include<string>   #define

原创 莫比烏斯反演前綴和除法分塊優化(hdu4746)

C - Mophues  HDU - 4746  As we know, any positive integer C ( C >= 2 ) can be written as the multiply of some prime num