http://acm.hdu.edu.cn/showproblem.php?pid=1286 题意:中文. 思路:求欧拉函数. #include <cstdio> #include <cstring> #include <algorithm> using namespace std; #define N 33000 int is_prime[N], prime[N], phi[N]; void Euler() { ; phi[] = ; ; ; i <= n; i…
Description has only two SentencesTime Limit: 3000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 852 Accepted Submission(s): 259 Problem Descriptionan = X*an-1 + Y and Y mod (X-1) = 0.Your task is to calculate th…
题意 \(n\) 局石头剪刀布,设每局的贡献为赢的次数与输的次数之 \(\gcd\) ,求期望贡献乘以 \(3^{2n}\) ,定义若 \(xy=0\) 则,\(\gcd(x,y)=x+y\) 思路 不难得出 \[ ans=3^n\sum_{i=0}^n\sum_{j=0}^{n-i}{n\choose i}{n-i\choose j}\gcd(i,j) \] 对于正整数 \(n\) ,有如下表达式 \[ n=\sum_{d|n}\varphi(d) \] 那么 \[ ans=3^n\sum_{…
M斐波那契数列 Time Limit: 3000/1000 MS (Java/Others)    Memory Limit: 65535/32768 K (Java/Others)Total Submission(s): 3087    Accepted Submission(s): 953 Problem Description M斐波那契数列F[n]是一种整数数列,它的定义如下: F[0] = aF[1] = bF[n] = F[n-1] * F[n-2] ( n > 1 ) 现在给出a,…
题目: GCD Again Time Limit: 1000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 125 Accepted Submission(s): 84   Problem Description Do you have spent some time to think and try to solve those unsolved problem afte…
Problem - 1286 用容斥原理做的代码: #include <cstdio> #include <iostream> #include <algorithm> #include <cstring> #include <vector> using namespace std; ; int last[N]; void pre() { last[] = ; ; i < N; i++) { if (!last[i]) { for (int…
题目链接 题意:给出一些单词,问全部单词能否首尾相连 直接 将每一个单词第一个和最后一个字母建立一条有向边,保证除了首尾两个出入度不相等,其他的要保证相等.还有一个条件就是 首尾两个出入度差为1 同时并查集判连通 #include <iostream> #include <cstdio> #include <cmath> #include <cstring> #include <algorithm> using namespace std; +…
Twin Prime Conjecture Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Problem Description If we define dn as: dn = pn+1-pn, where pi is the i-th prime. It is easy to see that d1 = 1 and dn=even for n>1. Twin Prime…
http://poj.org/problem?id=2478 http://acm.hdu.edu.cn/showproblem.php?pid=2824 欧拉函数模板裸题,有两种方法求出所有的欧拉函数,一是筛法,而是白书上的筛法. 首先看欧拉函数的性质: 欧拉函数是求小于n且和n互质(包括1)的正整数的个数.记为φ(n). 欧拉定理:若a与n互质,那么有a^φ(n) ≡ 1(mod n),经常用于求乘法逆元. 若p是一个质数,那么φ(p) = p-1,注意φ(1) = 1. 欧拉函数是积性函数…
版权声明:本文为博主原创文章,未经博主同意不得转载. vasttian https://blog.csdn.net/u012860063/article/details/36426357 题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=2824 欧拉函数性质: 1:(百科):http://baike.baidu.com/link?url=r-yneKCCyS9N6bhbQCqiZX0V2OCYq9r7iHSzHTSs03H7qRvu1OfUzlOxf…