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 ...
随机推荐
- Unity UGUI按钮添加点击事件
1. 可视化创建及事件绑定 # 1 : 通过 Hierarchy 面板创建 UI > Button. 2 : 创建一个脚本 TestClick.cs, 定义了一个 Click 的 public ...
- 有限状态机在单片机和 Arduino 编程中的应用
有限状态机在单片机和 Arduino 编程中的应用,个人认为在实际中这是一种思想,意味着解决一类问题. 本帖最后由 张飞 于 2015-3-4 20:18 编辑 在单片机编程中,如果在不使用操作系统的 ...
- OO 第四单元总结
一.总结本单元两次作业的框架设计 1.1. 需求分析 通过分析mdj文件可知,两次作业如果对于时间复杂度没有要求,可以不涉及任何数据结构,直接根据读入的UML_ELEMENT逐个分析得到各个函数的结果 ...
- mysql对库,表,数据类型的操作以及完整性约束
一丶对库的操作 求救语法: help create database; 1.创建数据库 CREATE DATABASE 数据库名 charset utf8; 2.数据库的命名规则: 可以由字母.数字. ...
- web端 css hack(一)
逢10月小长假,几天不敲键盘,浑身难受.也是有时间分享一下自己遇到的css问题.先说一下什么css hack 简单介绍一下css hack: 定义: 一般都是利用各浏览器的支持CSS的能力和BUG来进 ...
- web安全防御之RASP技术
作者: 我是小三 博客: http://www.cnblogs.com/2014asm/ 由于时间和水平有限,本文会存在诸多不足,希望得到您的及时反馈与指正,多谢! 0x00:we ...
- JAVA继承与使用
说来惭愧,java学完已经两年了,开发也已经做了快一年了,现在才基本了解继承怎么用,平时都是在一个类中乱写一气.现在感觉原来学的知识真正运用起来还是具有一定的差距.希望能够先夯实基础,共勉.写一下自己 ...
- JAXB介绍一
参考博客: https://www.cnblogs.com/chenbenbuyi/p/8283657.html https://www.cnblogs.com/cnsdhzzl/p/8390514. ...
- javascript的常用操作(二)
Undefined 不是 Null 在 JavaScript 中, null 用于对象, undefined 用于变量,属性和方法. 对象只有被定义才有可能为 null,否则为 undefined. ...
- Spring IoC和AOP的介绍
基于Spring Framework 版本:5.0.2.RELEASE IoC 概念:传统Java开发中,程序通过new主动创建对象实例,而Spring有专门的IoC容器来创建对象,具体来说就是在Sp ...