zoukankan      html  css  js  c++  java
  • bzoj3994

    智商太低了

    详细题解在这里http://blog.csdn.net/zmoiynlp/article/details/45176129

     1 const max=50001;
     2 var u,c,p:array[0..max] of longint;
     3     g:array[0..max] of int64;
     4     v:array[0..max] of boolean;
     5     i,j,t,n,m:longint;
     6 
     7 function min(a,b:longint):longint;
     8   begin
     9     if a>b then exit(b) else exit(a);
    10   end;
    11 
    12 function cal(n,m:longint):int64;
    13   var i,j:longint;
    14   begin
    15     i:=1;
    16     cal:=0;
    17     while i<=min(n,m) do
    18     begin
    19       j:=min(n div (n div i), m div (m div i));
    20       cal:=cal+int64(u[j]-u[i-1])*g[n div i]*g[m div i];
    21       i:=j+1;
    22     end;
    23   end;
    24 
    25 begin
    26   u[1]:=1;
    27   g[1]:=1;
    28   c[1]:=1;
    29   for i:=2 to max do
    30   begin
    31     if not v[i] then
    32     begin
    33       inc(t);
    34       p[t]:=i;
    35       g[i]:=2;
    36       c[i]:=1;
    37       u[i]:=-1;
    38     end;
    39     for j:=1 to t do
    40     begin
    41       if i*p[j]>max then break;
    42       v[i*p[j]]:=true;
    43       if i mod p[j]=0 then
    44       begin
    45         g[i*p[j]]:=g[i] div (c[i]+1)*int64(c[i]+2);
    46         c[i*p[j]]:=c[i]+1;
    47         u[i*p[j]]:=0;
    48         break;
    49       end;
    50       g[i*p[j]]:=g[i]*2;
    51       u[i*p[j]]:=-u[i];
    52       c[i*p[j]]:=1;
    53     end;
    54   end;
    55   for i:=1 to max do
    56   begin
    57     u[i]:=u[i-1]+u[i];
    58     g[i]:=g[i-1]+g[i];
    59   end;
    60   readln(t);
    61   while t>0 do
    62   begin
    63     dec(t);
    64     readln(n,m);
    65     writeln(cal(n,m));
    66   end;
    67 end.
    View Code
  • 相关阅读:
    HTML技巧: 语义化你的代码
    css sprite
    Redis主从复制原理
    idea修改快捷键
    Ubuntu14.20 安装docker,创建centos6.7容器,并访问centos容器
    [转]SQL 中 with as 的用法
    ftp与sftp及sftp和scp的区别
    Linux top 命令
    Linux free 命令
    ubuntu 源方式 安装jdk
  • 原文地址:https://www.cnblogs.com/phile/p/4553159.html
Copyright © 2011-2022 走看看