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…
1615: 刘备闯三国之三顾茅庐(三) Time Limit: 1000 MS  Memory Limit: 128 MBSubmit: 45  Solved: 8[Submit][Status][Web Board] Description 刘备(161年-223年6月10日),字玄德,东汉末年幽州涿郡涿县,西汉中山靖王刘胜的后代.刘备一生极具传奇色彩,早年颠沛流离.备尝艰辛最终却凭借自己的谋略终成一方霸主.那么在那个风云激荡的年代,刘备又是如何从一个卖草鞋的小人物一步一步成为蜀汉的开国皇帝呢…
题目链接:传送门 思路:欧拉函数的性质:前n个数的欧拉函数之和为φ(n)*n/2,由此求出结果. 参考文章:传送门 #include<iostream> #include<cmath> #include<cstdio> #include<cstring> using namespace std; typedef long long LL; ; LL POW(LL a,LL b) { LL ans=; while(b) { ) ans=ans*a%MOD; a…
欧拉函数 定义 对于正整数n,欧拉函数是小于或等于n的正整数中与n互质的数的数目,记作φ(n). 算法思路 既然求解每个数的欧拉函数,都需要知道他的质因子,而不需要个数 因此,我们只需求出他的质因子,然后根据公式:N*(p1-1)/p1*(p2-1)/p2......即可 #include<bits/stdc++.h> using namespace std; typedef long long ll; ll n; int main() { ll i,j; cin>>n; for(…
题目链接:http://acm.csu.edu.cn/csuoj/problemset/problem?pid=2021 Description Everybody loves big numbers (if you do not, you might want to stop reading at this point). There are many ways of constructing really big numbers known to humankind, for instanc…
链接:https://ac.nowcoder.com/acm/contest/317/D 来源:牛客网 题目描述 小a和小b来到了一条布满了黄金的街道上.它们想要带几块黄金回去,然而这里的城管担心他们拿走的太多,于是要求小a和小b通过做一个游戏来决定最后得到的黄金的数量. 游戏规则是这样的: 假设道路长度为nn米(左端点为00,右端点为nn),同时给出一个数kk(下面会提到kk的用法) 设小a初始时的黄金数量为AA,小b初始时的黄金数量为BB 小a从11出发走向n−1n−1,小b从n−1n−1出…
数学实在是差到不行了…… #include <cstdio> #include <cstring> #include <algorithm> #include <iostream> #include <cmath> using namespace std; #define LL __int64 const LL maxn=1001; LL e[maxn],t; LL gcd(LL a,LL b){return b==0?a:gcd(b,a%b);…
题目: 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…
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…
题意 \(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_{…