欧拉函数/莫比乌斯函数

  Orz iwtwiioi

  这个嘛……很明显在同一条线上的两个点一定是满足  x1*k=x2,y1*k=y2,(好吧这个表示方式有点傻逼,懂得就好了)那么这条线上的点只有第一个会被看到,即x,y互质的那一个点(如果gcd(x,y)==k>1那么肯定在它前面还有点(x/k,y/k) )

  但是马上你就会指着鼻子骂我说这特么不是胡扯么……(2,1) 和 (4,2)明明都能被看到!那是因为这里的“坐标原点”是(1,1)啊……所以坐标都减个1就好了→_→

  所以就是求 ………………看iwtwiioi的博客去吧- -b 我不会用LeTeX……

  嗯就是求:(原谅我截图跑……iwtwiioi实在太神了)

          aaarticlea/png;base64,iVBORw0KGgoAAAANSUhEUgAAAVQAAACHCAIAAADGLTbXAAAPOUlEQVR4nO2dS2rjzhPHa6Gd1t7rArqBb6Ar6Ao6he+gU+gSmrxICIEQGGgYGBgYGEjiaN6P1X9RP9e/o5dlvboUfT+rGceWy2p9u6urq6vp379/f//+/fPnz+/fv3/9+vXz588fP358//7927dvX79+LYri5eXl5eVlv98/Pz8/Pz8/HXgEAKhHBMv63e/3rOiiKOjv378EAFgZ+/2e/vz5Q0QFAGA1ENHj4yP9/v0b4gdgVRDRly9f6NevXxA/AKuCiD5//kw/f/6E+AFYFUT06dMn+vHjB8QPwKogoo8fP9L3798hfgBWBRF9+PCBvn37BvEDsCqIyBhDX79+hfgBWBVE9P79e+J/uTYGADAfRPTw8EAvLy8QPwCrgoju7+8hfgBWBxHd3d3Rfr+H+AFYFUR0e3tLz8/PED8Aq4KIbm5uIH4AVgcRXV9f09PTE8QPwKogoqurK4gfgNVBRJeXlxA/AKuDiC4uLujx8XER4jfG+L7v2opGlJsHgA0RnZ+fL0D8xpg4jj3P02mncvMAqLIA8RtjuN6Y7/v8D9cWvUK5eQA0QURnZ2eqxV8URZ7nxpiiKHSqS7l5ANSyDPELytWl3DwAbIjo3bt3EP84KDcPABuIf0yUmweAzSDx53m+2Ww8z9tut0VRpGm62Wx83/c8LwzDCaw9TV3KzQPAL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4AVgdRHRzc0P7/R7iB2BVENHt7S29vLxA/ACsCiK6u7v7T/wAgFVxf39PRVHs9/vHx8cvX758/vz506dPHz9+/PDhgzHm/fv3Dw8P9/f3d3d3t7e3Nzc319fXV1dXl5eXFxcX5+fn5+fnZ2dnZ2dn7wAAamBVskIvLi4uLy+vrq6ur69vbm5ub2/v7u7u7+8fHh7+B1MKQh5fFdWLAAAAAElFTkSuQmCC" alt="" />

  这样一个东西……就是对于每个x,求一共有多少个y与它互质,这不就是欧拉函数的定义么→_→

  所以可以写成

          aaarticlea/png;base64,iVBORw0KGgoAAAANSUhEUgAAAOsAAABqCAIAAADShDH/AAAJ1klEQVR4nO2dS26jQBCGa8GONXuWM4u+ATfgClyBU3AHTsEliF+yZVmyLEVqKVKkSJEiOcaddzKrWVTSQoAB84q7qW81ymB3u/1T1Kvb8O/fv6+vr8/Pz4+Pj/f397e3t9fX15eXl+fn56enJyHE8Xg8Ho9JkhwOh8Ph8PjDniCGQqoORZgkCcpSCAFfX19AEGqSJAl8fn4CgCAI1QCA/X4PHx8fpGBCRQDg4eEB3t/fScGEigDA/f09vL29kYIJFQGAu7s7eH19JQUTKgIAt7e38PLyQgomVAQAbm5u4Pn5mRRMqAgAcM7h6emJFEyoCABcX18D/uu3J0MQZwMAu90OjscjKZhQEQDYbrekYEJVAGCz2UCSJKRgQkUAYL1ew+FwIAUTKgIAq9WKFEyoCgAsl0t4fHwkBRMqAgCLxUJ5BXPO48HhnP/25yYEAMznc7UVHMdx703URRiG8dsfnRAAMJvNYL/fq6tgIYRhGBl5WZblNcJ1Xdd1HcdhjFmWlX/nNL7v//ZHHzsAMJ1OlVdwFEV5ecVx3OH7e55n23ZmCNM0uxqCaIYmChZCeJ43gLw4567rpkeJoqjzUYj6AMBkMtFBwUIIy7IyInYcp4+BOOeMMRyCMdbHEKoQx/G5rhTn3PO8ruJgrRTMOc+7rUEQ9DSc7/s4xGiTEnEcG4bRIBiwbds0zU7WDQCurq40UbAQIgzDjIINw+hPYU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sVUi3FqXdYrPrkwhJwQ0VzDmP41ieUBaGoazUV9KHenAmmFArTwn3OhN0GDKHqcn2Mcdxugrm2qy/NrRScOHD9CxXT6rn3KFPgRUNy7LOfUx3OBN8FGR8cfzVIMMwOsxFtF9/DejGi2jJ5fTTXM5MiJpchIIJojGkYEJtvhX89+9fUjChImSDCbUhBRNqQ14EoTZkgwm1IQUTagMAk8kE/vz5QwomVORbwWSDCUUBgOl0SgomVOVbwY+Pj6RgQkUAYDabkYIJVQGA+XxOCiZUBQAWiwUcDgdSMKEiALBcLknBhKoAwGq1giRJSMGEigDAer2G4/FICiZUBAA2m823gglCRbbbLQghkiTZ7/cPDw/39/d3d3e3t7c3Nzec8+vr691ut91uN5vNer1erVbL5XKxWMzn89lsNp1Op9PpZDKZTCZXBNE1KC2U2Ww2m8/ni8ViuVyuVqv1er3ZbLbb7W63+w8OTRQEbJyk4QAAAABJRU5ErkJggg==" alt="" />【然后再乘二(x和y交换算两组)】

  最后还有一点细节要注意:(1,1)这个点统计了两次,(1,0) 和 (0,1)这两个点没有算。

  还有一种姿势,如果是用莫比乌斯函数写的话,第一个和式还可以写成:【Orz lqybzx

          sigma{ mu[i]*(n/i)*(n/i) }  (不要吐槽我的语法……)

我的代码:(线性筛模板参见《线性筛法与积性函数》——贾志鹏)

 /**************************************************************
Problem: 2190
User: Tunix
Language: C++
Result: Accepted
Time:24 ms
Memory:1624 kb
****************************************************************/ //BZOJ 2190
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<iostream>
#include<algorithm>
#define rep(i,n) for(int i=0;i<n;++i)
#define F(i,j,n) for(int i=j;i<=n;++i)
#define D(i,j,n) for(int i=j;i>=n;--i)
using namespace std;
int getint(){
int v=,sign=; char ch=getchar();
while(ch<''||ch>''){ if (ch=='-') sign=-; ch=getchar();}
while(ch>=''&&ch<=''){ v=v*+ch-''; ch=getchar();}
return v*=sign;
}
/******************tamplate*********************/
const int N=;
int phi[N],prime[N];
bool check[N];
void getphi(int n){
memset(check,,sizeof check);
phi[]=;
int tot=;
F(i,,n){
if(!check[i]){
prime[tot++]=i;
phi[i]=i-;
}
rep(j,n){
if(i*prime[j]>n) break;
check[i*prime[j]]=;
if(i % prime[j]==){
phi[i*prime[j]]=phi[i]*prime[j];
break;
}
else phi[i*prime[j]]=phi[i]*(prime[j]-);
}
}
}
int main(){
int n=getint(),ans=;
getphi(n);
F(i,,n-)
ans+=phi[i];
ans=ans*+;
printf("%d\n",ans);
return ;
}

欧拉函数

 /**************************************************************
Problem: 2190
User: Tunix
Language: C++
Result: Accepted
Time:28 ms
Memory:1624 kb
****************************************************************/ //BZOJ 2190
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<iostream>
#include<algorithm>
#define rep(i,n) for(int i=0;i<n;++i)
#define F(i,j,n) for(int i=j;i<=n;++i)
#define D(i,j,n) for(int i=j;i>=n;--i)
using namespace std;
int getint(){
int v=,sign=; char ch=getchar();
while(!isdigit(ch)) {if(ch=='-') sign=-; ch=getchar();}
while(isdigit(ch)) {v=v*+ch-''; ch=getchar();}
return v*sign;
}
/*******************template********************/
const int N=;
int prime[N],mu[N];
bool check[N];
void getmu(int n){
memset(check,,sizeof check);
mu[]=;
int tot=;
F(i,,n){
if(!check[i]){
prime[tot++]=i;
mu[i]=-;
}
rep(j,tot){
if(i*prime[j]>n) break;
check[i*prime[j]]=true;
if(i%prime[j]==){
mu[i*prime[j]]=;
break;
}
else mu[i*prime[j]]=-mu[i];
}
}
}
int main(){
int n,ans=;
n=getint();
n--;
getmu(n);
F(i,,n) ans+=mu[i]*(n/i)*(n/i);
ans=ans+;
printf("%d\n",ans);
return ;
}

莫比乌斯函数

【BZOJ】【2190】【SDOI2008】仪仗队的更多相关文章

  1. BZOJ 2190: [SDOI2008]仪仗队

    2190: [SDOI2008]仪仗队 Time Limit: 10 Sec  Memory Limit: 259 MBSubmit: 2689  Solved: 1713[Submit][Statu ...

  2. BZOJ 2190: [SDOI2008]仪仗队( 欧拉函数 )

    假设C君为(0, 0), 则右上方为(n - 1, n - 1). 一个点(x, y) 能被看到的前提是gcd(x, y) = 1, 所以 answer = ∑ phi(i) * 2 + 2 - 1 ...

  3. bzoj 2190: [SDOI2008]仪仗队 线性欧拉函数

    2190: [SDOI2008]仪仗队 Time Limit: 10 Sec  Memory Limit: 259 MB[Submit][Status][Discuss] Description 作为 ...

  4. bzoj 2190 [SDOI2008]仪仗队(欧拉函数)

    [题目链接] http://www.lydsy.com/JudgeOnline/problem.php?id=2190 [题意] n*n的正方形,在(0,0)格点可以看到的格子数目. [思路] 预处理 ...

  5. 【刷题】BZOJ 2190 [SDOI2008]仪仗队

    Description 作为体育委员,C君负责这次运动会仪仗队的训练.仪仗队是由学生组成的N * N的方阵,为了保证队伍在行进中整齐划一,C君会跟在仪仗队的左后方,根据其视线所及的学生人数来判断队伍是 ...

  6. [bzoj 2190][SDOI2008]仪仗队(线性筛欧拉函数)

    题目:http://www.lydsy.com/JudgeOnline/problem.php?id=2190 分析:就是要线性筛出欧拉函数... 直接贴代码了: memset(ans,,sizeof ...

  7. BZOJ 2190 [SDOI2008]仪仗队 ——Dirichlet积

    [题目分析] 考虑斜率为0和斜率不存在的两条线上只能看到3人. 其余的人能被看见,当且仅当gcd(x,y)=1 ,然后拿卷积算一算 发现就是欧拉函数的前缀和的二倍. 注意2的情况要特判. [代码] # ...

  8. BZOJ——2190: [SDOI2008]仪仗队

    思路: 我们将其所在的位置设为(0,0),那么如果存在一个点(x,y),且有gcd(x,y)=k(k!=1),那么点(x/k,y/k)一定会将(x,y)挡住.而如果k=1,那么点(x,y)就一定会被看 ...

  9. 2190: [SDOI2008]仪仗队(欧拉函数)

    2190: [SDOI2008]仪仗队 Time Limit: 10 Sec  Memory Limit: 259 MBSubmit: 3235  Solved: 2089 Description 作 ...

  10. 【BZOJ】2190 [SDOI2008]仪仗队(欧拉函数)

    Description 作为体育委员,C君负责这次运动会仪仗队的训练.仪仗队是由学生组成的N * N的方阵,为了保证队伍在行进中整齐划一,C君会跟在仪仗队的左后方,根据其视线所及的学生人数来判断队伍是 ...

随机推荐

  1. 基于系统的UIMenuController的使用及自定义UIMenuItem

    1.前言 在开发中 UIMenuController 用得较少,偶尔遇到了,一时竟想不起来,因此做个回顾 2.系统默认支持 UIMenuController 的UI控件 UITextField UIT ...

  2. Cocos2d-JS中的cc.LabelAtlas

    cc.LabelAtlas是图片集标签,其中的Atlas本意是“地图集”.“图片集”,这种标签显示的文字是从一个图片集中取出的,因此使用cc.LabelAtlas需要额外加载图片集文件.cc.Labe ...

  3. [转]基于SQL脚本将数据库表及字段提取为C#中的类

    开发时,勉不了需要使用SQL直接与数据库交互,这时对于数据库中的表名及字段名会使用的比较多.如果每使用一次都复制一个,实在蛋疼.所以就考虑将其做成const常量.但是数据库中的表和字段相当多,一个一个 ...

  4. 字符集转换: Unicode - Ansi

    字符集转换: Unicode - Ansi string UnicodeToAnsi ( const wstring& wstrSrc ) { /*!< 分配目标空间, 一个16位Uni ...

  5. 麦子学院Android开发Java教程ClassCastException 错误解析

    现在Java编程中经常碰到ClassCastException 错误,ClassCastException 是 JVM 在检测到两个类型间的转换不兼容时引发的运行时异常.此类错误通常会终止用户请求.本 ...

  6. zedboard 构建嵌入式linux

    本文通过五部完成zedboard的嵌入式LINUX搭建,所谓磨刀不五砍材工嘛 1:系统环境搭建 要准备好交叉编译环境 见http://blog.csdn.net/xiabodan/article/de ...

  7. ADO.NET笔记——利用Command对象的ExecuteScalar()方法返回一个数据值

    相关知识: 有些SQL操作,例如SUM,只会从数据库返回一个数据值,而不是多行数据 尽管也可以使用ExecuteReader()返回一个DataReader对象,代表该数据值,但是使用Command对 ...

  8. Tomcat启动超时

    当启动tomcat时候出现 Server Tomcat v8.0 Server at localhost was unable to start within 45 seconds. If the s ...

  9. SequoiaDB数据库集群部署

    一般在多机环境下部署数据库的集群模式是比较繁琐的,下面我来分享一个如何通过shell脚本的方式简单.方便地部署我们的集群. 首先,我们要给机器配置信任关系,这样我们就无需手动的输入密码来执行ssh和s ...

  10. Stanford parser学习:LexicalizedParser类分析

    上次(http://www.cnblogs.com/stGeekpower/p/3457746.html)主要是对应于javadoc写了下LexicalizedParser类main函数的功能,这次看 ...