傳送門
打表發現 f(n, c) = c ^ (n可以分解為多少個質因數)
用尤拉篩打出可以分解為多少個質因數
思路2:先判斷c、d和ab中垂線的關係,ac < bc時c在ab中垂線左,ac > bc時c在中垂線右,d點同理;若兩點都在左側,比較bc、bd;若兩點都在右側,比較ac、ad#includeusing namespace std;
typedef long long ll;
const ll inf = 0x3f3f3f3f3f3f3f3f;
const double pi = acos(-1.0);
const ll mod = 1e9 + 7;
const int n = 1e6 + 10;
int pri[n], tot, cnt[n];
bool vis[n];
void init()
for(int j = 1; j <= tot; ++j)
}}ll qpow(ll a, ll b)
return ans % mod;
}int main()
return 0;
}
傳送門#includeusing namespace std;
typedef long long ll;
const ll inf = 0x3f3f3f3f3f3f3f3f;
const double pi = acos(-1.0);
const ll mod = 1e9 + 7;
const int n = 1e6 + 10;
int main()
else }}
return 0;
}
題意:數1~n最多能組成多少對不互質的數對
思路:逆序遍歷小於 n 的所有素數,取出1~n中所有該素數的倍數,兩兩配對,如果是奇數個留下數 p * 2,因為這個數可以最後遍歷2的倍數時配。比賽的時候沒想到這一點,用優先佇列維護的有效(還沒有被遍歷過)素因子最多的數,把這個數留下來,比較麻煩,但也不是很慢:
emm還是用正解做吧:
#includeusing namespace std;
typedef long long ll;
const ll inf = 0x3f3f3f3f3f3f3f3f;
const double pi = acos(-1.0);
const ll mod = 1e9 + 7;
const int n = 2e5 + 10;
int pri[n], tot;
bool vis[n], is[n];
void init()
}}int main()
}if(cnt & 1)
else
vec.pop_back();}}
int ans = vec.size() / 2;
cout<
for(int i = 0; i < ans * 2; i += 2)
cout<
vec.clear();
}return 0;
}
2020牛客暑期多校訓練營(第四場)
參考部落格 注意的幾個點 include using namespace std typedef long long ll typedef int128 lll define print i cout debug i endl define close ios sync with stdio 0 c...
2020牛客暑期多校訓練營 第四場
開始堇業,把之前欠的債補上。這場只出了兩個水題。題目看起來太複雜了。仔細分析以後其實是除掉最小質因數之後的那個數的次數 1。一開始質因數從1列舉哇了一發。我是弱智。include using namespace std typedef long long ll const int mod 1e9 7...
牛客暑期多校訓練營B Boundary
給定n個點,然後確定乙個過原點的圓,要使這n個點盡可能多的存在與圓上,最後輸出最多的存在於圓上的點的個數 三點確定乙個圓,我們已知這個圓必定經過原點,所以再依次利用三點求圓心的公式列舉每兩個點與原點 三點不共線 確定的圓心,最後選擇確定次數最多的圓心構成的圓 include include incl...