刚开始用了几次gcd(),结果n次tle, 最后用了筛选法,终于a了,效率提高不少啊!http://acm.hdu.edu.cn/吧
原创 2021-08-01 14:17:34
58阅读
                                 &n
原创 2013-06-30 16:49:00
355阅读
找新朋友 http://acm.hdu.edu.cn/showproblem.php?pid=1286 Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) Problem Descripti
转载 2021-08-05 10:13:06
77阅读
原标题:点击打开链接关于欧拉函数的算法具体解说:点击打开链接欧拉函数1.欧拉函数是不全然积性函数。2.欧拉函数p(x) = x * (p1 - 1) / p1 * (p2 - 1)/p2 * .....(pn - 1)/ pn;#include #include #include using nam...
转载 2015-08-15 11:07:00
44阅读
2评论
找新朋友Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 9182    Accepted Submission(s): 4847Problem Description新年快到了,“猪头帮协会”准备搞一个聚会,
原创 2022-08-09 08:43:33
35阅读
找新朋友Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Ot
原创 2022-09-26 14:48:07
82阅读
地址:http://acm.hdu.edu.cn/showproblem.php?pid=1286题意:中文。mark:看似很绕其实就是求欧拉函数Phi(n)。对于所有n的素因子Pi,欧拉函数Phi(n) = n * (P1-1)/P1 * (P2-1)/P2 * (P3-1)/P3 ...。对于每一个Pi,因为n总是Pi的倍数,所以可以先除再乘,不会溢出。代码:# include <stdio.h>int Primes[40000] = {2, 3} ;int PrimeNum = 2 ;int dp[40000] ;int calc(int nn){ int ans = nn,
转载 2012-01-11 01:21:00
23阅读
http://acm.hdu.edu.cn/showproblem.php?pid=1286 没什么好说的,模板题,主要是弄懂欧拉函数的思想。 POJ2407:http://poj.org/problem?id=2407
原创 2024-08-16 09:36:27
25阅读
hdu 1286 找新朋友Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 7441    Accepted Submission(s): 3899Problem Description新年快到了,“猪头帮协会
原创 2022-12-02 00:28:08
62阅读
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 13639 Accepted Submission(s): 7275 Problem Descri
原创 2021-07-28 10:06:53
34阅读
Description新年快到了,“猪头帮协会”准备搞一个聚会,已经知道现有会朋友?请你编程序帮会长计算出来。Input第一行是测试数据的组数CN(Case number,1Output
原创 2022-11-09 19:22:17
72阅读
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1286数学题真的是有点吃不消了。。。View Code 1 #include<iostream> 2 #include<cmath> 3 using namespace std; 4 //可以快速求出欧拉函数的值 ( P为N的质因子 ) 5 //若(N%P==0 && (N/P)%P==0) 则有:E(N)=E(N/P)*P; 6 //若(N%P==0 && (N/P)%P!=0) 则有:E(N)=E(N/P)*(P-1); 7 8 //欧拉公
转载 2013-04-12 22:04:00
48阅读
2评论
题解:分析题目,就是一个裸的欧拉函数,于是AC。#include int eular(int n){ int ret=1,i; for(i=2;i*i1) ret*=n-1; return ret;}int main(){ int n; scanf("%d",&n); ...
转载 2013-12-27 16:00:00
24阅读
题目链接找新朋友Time Limit : 2000/1000ms (Java/Other) Memory Limit : 65536/32768K (Java/Other) Total Submission(s) : 5 Acce
原创 2023-02-02 11:12:46
60阅读
找新朋友http://acm.hdu.edu.cn/game/entry/problem/show.php?chapterid=2&sectionid=1&problemid=8Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 1560 Accepted Submission(s): 781Problem Description新年快到了,“猪头帮协会”准备搞一个聚会,已经知道现有会员N人,把会员从1到N编号,其中会长的号码是N
转载 2013-01-03 12:16:00
48阅读
2评论
题目地址:点击打开链接思路:欧拉函数的简单应用AC代码1:#include #include using namespace std;int main(){ int t,n,i,rea; scanf("%d",&t); while(t--) { scanf("%d",&n); rea = n;
原创 2022-08-04 09:13:49
38阅读
Burnside定理。可以用Euler函数优化。#include #include #include #include #include #define LL __int64using namespace std;LL Power(int a,int b){ LL ret=1; LL p=(LL)a...
转载 2014-10-16 16:55:00
15阅读
2评论
目录1.题目2.代码1.题目新年快到了,“猪头帮协会”准备搞一个聚会,已经知道现有会员N人,把会员从1到N编号,其中会长的号码是N号
原创 2022-06-10 17:05:51
233阅读
找新朋友 Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) Problem Description 新年快到了,“猪头帮协会”准备搞一个聚会,已经知道现有会员N人,把会员从1到N编号,其中
转载 2016-05-05 21:44:00
71阅读
2评论
题意:与2409类似,只是只能有3种颜色。分析:详见2409,注意输入0的情况。View Code #include <iostream>#include <cstdio>#include <cstdlib>#include <cstring>#include <cmath>using namespace std;int n, m;int gcd(int a, int b){ b = b % a; while (b) { a = a % b; swap(a, b); } return a;}int main(){ //freope..
转载 2012-07-03 09:13:00
19阅读
2评论
  • 1
  • 2
  • 3
  • 4
  • 5