Posted on 五月 8th, 2008.
求1到n中与n互素的数的个数.标准做法是欧拉函数,这道题范围小,随便就可以搞掉.
欧拉函数varphi(n)的求法:假设n的质因数分解为:n=p1^a1+p2^a2+…+pk^ak,其中p1到pk是互不相等的k个素数,那么varphi(n)=n*((p1-1)/p1)*((p2-1)/p2)*…*((pk-1)/pk)
然后随便一写就好…
{ SGU 102; Coprimes - sqybi’s code - 欧拉函数}//for my winstyprogram sgu102_sqybi; var n, m, nt, i: longint; a: array[1..10000]of longint;
begin readln(n); nt := n; m := 0; for i:=2 to n do begin if n = 1 then break; if n mod i = 0 then begin inc(m); a[m] := i; while […]
Read Full Post |
Make a Comment ( None so far )
Posted on 五月 8th, 2008.
见程序…随便列一下就出规律了…或者直接按照那个算除以三的余数的方法…P.S.这个方法的证明有兴趣去看<什么是数学>…
{SGU 105; Div 3- sqybi’s code}//for my winstyprogram sgu105; var n: longint;
begin readln(n); writeln(n div 3 * 2 + ord(n mod 3 = 2)); end.
阅读(31 次)
Read Full Post |
Make a Comment ( None so far )
Posted on 五月 8th, 2008.
alft 21:59:24很白痴的一道题alft 21:59:27给你一个指数alft 21:59:33给你N个数alft 21:59:43指数是1or2or3alft 21:59:57N个数绝对值不超过3alft 22:00:22选若干个数, 使求指定指数幂的和最大
程序不放了…
阅读(40 次)
Read Full Post |
Make a Comment ( None so far )
Posted on 五月 8th, 2008.
标题党没有人介意吧…
刚发现小号这道题没AC,于是就做了…最近准备刷SGU了.
阅读(31 次)
Read Full Post |
Make a Comment ( None so far )