bzoj 1408 [Noi2002]Robot(欧拉函数)
【题目链接】
http://www.lydsy.com/JudgeOnline/problem.php?id=1408
【题意】
求m的所有约数中,满足可以分解成(奇数个不同素数/偶数个不同素数/其他)的所有的phi之和。
【思路】
ans1表示目前为止有偶数个奇质因子的欧拉函数的前缀和
ans2表示目前为止有奇数个奇质因子的欧拉函数的前缀和。
注意2不是奇质因子,需要去掉。
第三种可以由m-1减去前两种,减1为去掉1,1不是老师。
【代码】
#include<cstdio>
#include<cstring>
using namespace std; const int N = 2e3+;
const int MOD = ; int pow(int a,int p,int mod)
{
int ans=;
while(p) {
if(p&) ans=(ans*a)%mod;
a=(a*a)%mod; p>>=;
}
return ans;
} int ans1,ans2,ans3,n,m,p,e; int main()
{
scanf("%d",&n);
m=;
for(int i=;i<=n;i++)
{
scanf("%d%d",&p,&e);
m=(m*pow(p,e,MOD))%MOD;
if(p==) continue;
int t1=(ans1+ans2*(p-))%MOD;
int t2=(ans2+(ans1+)*(p-))%MOD;
ans1=t1,ans2=t2;
}
ans3=((m--ans1-ans2)%MOD+MOD)%MOD;
printf("%d\n%d\n%d\n",ans1,ans2,ans3);
return ;
}
bzoj 1408 [Noi2002]Robot(欧拉函数)的更多相关文章
- BZOJ 1408: [Noi2002]Robot
1408: [Noi2002]Robot Time Limit: 5 Sec Memory Limit: 64 MBSubmit: 510 Solved: 344[Submit][Status][ ...
- bzoj 2818 GCD 数论 欧拉函数
bzoj[2818]Gcd Description 给定整数N,求1<=x,y<=N且Gcd(x,y)为素数的数对(x,y)有多少对. Input 一个整数N Output 如题 Samp ...
- bzoj 2190 仪仗队(欧拉函数)
2190: [SDOI2008]仪仗队 Time Limit: 10 Sec Memory Limit: 259 MBSubmit: 2245 Solved: 1413[Submit][Statu ...
- BZOJ 2818 GCD 【欧拉函数 || 莫比乌斯反演】
传送门:https://www.lydsy.com/JudgeOnline/problem.php?id=2818 2818: Gcd Time Limit: 10 Sec Memory Limit ...
- BZOJ 2190仪仗队【欧拉函数】
问题的唯一难点就是如何表示队长能看到的人数?如果建系,队长所在的点为(0,0)分析几组数据就一目了然了,如果队长能看到的点为(m,n),那么gcd(m,n)=1即m n 互质或者是(0,1),(1,0 ...
- bzoj 2818 Gcd(欧拉函数 | 莫比乌斯反演)
[题目链接] http://www.lydsy.com/JudgeOnline/problem.php?id=2818 [题意] 问(x,y)为质数的有序点对的数目. [思路一] 定义f[i]表示i之 ...
- Bzoj 2749: [HAOI2012]外星人 欧拉函数,数论,线性筛
2749: [HAOI2012]外星人 Time Limit: 3 Sec Memory Limit: 128 MBSubmit: 568 Solved: 302[Submit][Status][ ...
- BZOJ 2818 GCD(欧拉函数)
题目链接:http://acm.hust.edu.cn/vjudge/problem/viewProblem.action?id=37161 题意:gcd(x, y) = 质数, 1 <= x, ...
- BZOJ 2190: [SDOI2008]仪仗队( 欧拉函数 )
假设C君为(0, 0), 则右上方为(n - 1, n - 1). 一个点(x, y) 能被看到的前提是gcd(x, y) = 1, 所以 answer = ∑ phi(i) * 2 + 2 - 1 ...
随机推荐
- 入门视频采集与处理(BT656简介)
入门视频采集与处理(BT656简介) http://ticktick.blog.51cto.com/823160/553535 1. 帧的概念(Frame) 一个视频序列是由N个帧组成的,采集图像的 ...
- lua的split函数
function split(s, delim) then return end local t = {} while true do local pos = string.find (s, deli ...
- Quartz动态添加、修改和删除定时任务
任务调度开源框架Quartz动态添加.修改和删除定时任务 Quartz 是个开源的作业调度框架,为在 Java 应用程序中进行作业调度提供了简单却强大的机制.Quartz框架包含了调度器监听.作业和触 ...
- 224. Basic Calculator
题目: Implement a basic calculator to evaluate a simple expression string. The expression string may c ...
- 【HDOJ】5632 Rikka with Array
1. 题目描述$A[i]$表示二级制表示的$i$的数字之和.求$1 \le i < j \le n$并且$A[i]>A[j]$的$(i,j)$的总对数. 2. 基本思路$n \le 10^ ...
- OGG-00782 - OGG 11.2.1.0.2 FOR Windows x64 Microsoft SQL Server
OS ENV:主机名: WIN-NO42QRNPMFAOS 名称: Microsoft Windows Server 2008 R2 Datacenter OS ...
- R: count number of distinct values in a vector
numbers <- c(4,23,4,23,5,43,54,56,657,67,67,435, 453,435,324,34,456,56,567,65,34,435) a & ...
- Android开发之assets文件夹中资源的获取
assets中的文件都是保持原始的文件格式,需要使用AssetManager以字节流的形式读取出来 步骤: 1. 先在Activity里面调用getAssets() 来获取AssetManager引用 ...
- version_info
import sys def check_version(): v = sys.version_info if v.major == 3 and v.minor >= 4: return Tru ...
- 【C#学习笔记】播放wav文件
using System; using System.Media; namespace ConsoleApplication { class Program { static void Main(st ...