http://acm.hdu.edu.cn/showproblem.php?pid=1220 Cube Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 2260 Accepted Submission(s): 1819 Problem Description Cowl is good at solving math problems…
Code: #include<cstdio> #include<cstring> #include<cmath> #include<iostream> using namespace std; const int maxn=100000+233; typedef long long ll; int v[maxn],vis[maxn]; int m[maxn]; int num; //质因子个数 ll ans=0; ll A,B; ll gcd(ll a,ll…
The Boss on Mars Problem's Link Mean: 给定一个整数n,求1~n中所有与n互质的数的四次方的和.(1<=n<=1e8) analyse: 看似简单,倘若自己手动推公式的话,还是需要一定的数学基础. 总的思路:先求出sum1=(1^4)+(2^4)+...(n^4),再求出sum2=(1~n中与n不互质的数的四次方的和),answer=sum1-sum2. 如何求sum1呢? 有两种方法: 1.数列差分.由于A={Sn}={a1^4+a2^4+...an^4}…