JZOJ 5809. 【NOIP2008模拟】数羊
5809. 【NOIP2008模拟】数羊
(File IO): input:sheep.in output:sheep.out
Description
Input
Output
Sample Input
2 3
Sample Output
15
Data Constraint
#include <cstdio>
#include <iostream>
#include <cstring>
#include <cmath>
#define LL long long
#define mo 9901
#define N 50000007
using namespace std;
LL a, b, ans, Have[N / ];
int Pri[N / ], S[N / ];
bool v[N]; void Pre_work()
{
Pri[] = , Pri[] = ;
for (int i = ; i <= N - ; i += )
{
if (!v[i]) Pri[++Pri[]] = i;
for (int j = ; j <= Pri[] && i * Pri[j] < N - ; v[i * Pri[j]] = , j++);
}
} LL Fastpow(LL x, LL y)
{
LL ret = ;
x %= mo;
while (y)
{
if (y & ) ret = (ret * x) % mo;
y >>= ;
x = (x * x) % mo;
}
return ret;
} int main()
{
// freopen("sheep.in", "r", stdin);
// freopen("sheep.out", "w", stdout);
Pre_work();
scanf("%lld%lld", &a, &b);
LL p = a;
for (int i = ; p > ; )
{
while (p % Pri[i] != ) i++;
LL sum = ;
while (p % Pri[i] == ) Have[i]++, p /= Pri[i];
Have[i] *= b;
S[++S[]] = i;
}
ans = ;
for (int i = ; i <= S[]; i++)
{
LL v = Fastpow( - Pri[S[i]], mo - );
LL u = Fastpow(Pri[S[i]], Have[S[i]]);
u = ( - u * Pri[S[i]]) % mo;
ans = (ans * u * v) % mo;
}
printf("%lld", ans);
}
JZOJ 5809. 【NOIP2008模拟】数羊的更多相关文章
- JZOJ 5775. 【NOIP2008模拟】农夫约的假期
5775. [NOIP2008模拟]农夫约的假期 (File IO): input:shuru.in output:shuru.out Time Limits: 1000 ms Memory Lim ...
- JZOJ 5791. 【NOIP2008模拟】阶乘
5791. [NOIP2008模拟]阶乘 (File IO): input:factorial.in output:factorial.out Time Limits: 1000 ms Memory ...
- JZOJ 5777. 【NOIP2008模拟】小x玩游戏
5777. [NOIP2008模拟]小x玩游戏 (File IO): input:game.in output:game.out Time Limits: 1000 ms Memory Limits ...
- JZOJ 5793. 【NOIP2008模拟】小S练跑步
5793. [NOIP2008模拟]小S练跑步 (File IO): input:run.in output:run.out Time Limits: 2000 ms Memory Limits: ...
- JZOJ 5776. 【NOIP2008模拟】小x游世界树
5776. [NOIP2008模拟]小x游世界树 (File IO): input:yggdrasil.in output:yggdrasil.out Time Limits: 1500 ms Me ...
- JZOJ 5773. 【NOIP2008模拟】简单数学题
5773. [NOIP2008模拟]简单数学题 (File IO): input:math.in output:math.out Time Limits: 1000 ms Memory Limits ...
- JZOJ 5771. 【NOIP2008模拟】遨游
5771. [NOIP2008模拟]遨游 (File IO): input:trip.in output:trip.out Time Limits: 2000 ms Memory Limits: 2 ...
- JZOJ【NOIP2013模拟联考14】隐藏指令
JZOJ[NOIP2013模拟联考14]隐藏指令 题目 Description 在d维欧几里得空间中,指令是一个长度为2N的串.串的每一个元素为d个正交基的方向及反方向之一.例如,d = 1时(数轴) ...
- JZOJ5776. 【NOIP2008模拟】小x游世界树
题目:[NOIP2008模拟]小x游世界树: 题目的附加题解给的很清楚,这里只给一个代码: #include<iostream> #include<cstdio> #inclu ...
随机推荐
- Spark Mllib里如何生成KMeans的训练样本数据、生成线性回归的训练样本数据、生成逻辑回归的训练样本数据和其他数据生成
不多说,直接上干货! 具体,见 Spark Mllib机器学习(算法.源码及实战详解)的第2章 Spark数据操作
- Linux网络编程函数
1. Server端-socket/bind/listen/accept/read socket(AF_INET, SOCK_STREAM, 0); //指定端口,内核将端口上的数据转发给该socke ...
- Python3基础(3)集合、文件操作、字符转编码、函数、全局/局部变量、递归、函数式编程、高阶函数
---------------个人学习笔记--------------- ----------------本文作者吴疆-------------- ------点击此处链接至博客园原文------ 1 ...
- C#数字图像处理算法学习笔记(一)--C#图像处理的3中方法
C#数字图像处理算法学习笔记(一)--C#图像处理的3中方法 Bitmap类:此类封装了GDI+中的一个位图,次位图有图形图像及其属性的像素数据组成.因此此类是用于处理像素数据定义的图形的对象.该类的 ...
- 图片单独上传 (word)
Word.ApplicationClass wordApp=new ApplicationClass(); object file=path; object nullobj=System.Reflec ...
- css动画-小球撞壁反弹
小球碰到一面壁之后一般都会反弹,反射角=入射角: 其实用css3来实现这个效果也非常简单. 首先,分解一下小球的运动:水平运动和垂直运动. 当小球往右下方向运动时,如果碰到了下面的壁,那么由于碰撞,小 ...
- 关于dom4j在maven中的使用
在maven中添加dom4j的依赖, (如何使用eclipse构建maven项目, 这里就不在赘述) <!-- https://mvnrepository.com/artifact/org.do ...
- intelij idea相关笔记--持续更新
一.快捷键: Ctrl+F 文件内查找 Ctrl+Shift+F 全局查找 Ctrl+Shift+N 查找文件 Ctrl+Alt+← 返回上一步 Ctrl+Alt+→ 返回下一步 二.编译相关: 如果 ...
- shell实现网站备份
#!/bin/bash ##back web directory scripts #需要备份的目录写入与脚本同级目录test.txt文件中 DIR="/data/server/www&quo ...
- 利用binlog2sql解析mysqlbinlog row行日志
binlog2sql 项目作者:曹单锋 github项目地址:https://github.com/danfengcao/binlog2sql 也可在github.com上搜索“binlog2sql” ...