传送门

Solution

懒得写啦

Code

 #include<iostream>
#include<cstdio>
#include<cmath>
#define Rg register
#define go(i,a,b) for(Rg int i=a;i<=b;i++)
#define yes(i,a,b) for(Rg int i=a;i>=b;i--)
#define ll long long
using namespace std;
int read()
{
int x=,y=;char c=getchar();
while(c<''||c>''){if(c=='-')y=-;c=getchar();}
while(c>=''&&c<=''){x=(x<<)+(x<<)+c-'';c=getchar();}
return x*y;
}
ll T,L,d,n,m,ans,c;
bool flag=;
ll gcd(ll x,ll y){return y==?x:gcd(y,x%y);}
ll phi(ll x)
{
ll sm=x,y=x;
go(i,,sqrt(y))
{
if(x%i==)sm=sm/i*(i-);
while(x%i==)x/=i;
}
if(x>)sm=sm/x*(x-);
return sm;
}
ll mul(ll x,ll y,ll mod)
{
ll sm=;
while(y)
{
if(y&)sm=(sm+x)%mod;
x=(x<<)%mod;y>>=;
}
return sm;
}
ll ksm(ll x,ll y,ll mod)
{
ll sm=;
while(y)
{
if(y&)sm=mul(sm,x,mod);//注意这里直接乘起来会溢出
x=mul(x,x,mod);y>>=;
}
return sm;
}
int main()
{
while()
{
scanf("%lld",&L);if(!L)break;T++;flag=;ans=;
if(%L==){printf("Case %lld: 1\n",T);continue;}
d=gcd(L,);n=*L/d;m=phi(n);c=sqrt(m);
go(i,,c)
{
if(m%i==&&ksm(,i,n)==){ans=i;flag=;break;}
}
if(!flag)
yes(i,c,)
{
if(m%i==&&ksm(,m/i,n)==){ans=m/i;break;}
}
printf("Case %lld: %lld\n",T,ans);
}
return ;
}

Poj3696 The Lukiest Number的更多相关文章

  1. POJ3696 The Luckiest number

    题意 Language:Default The Luckiest number Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 7 ...

  2. POJ3696:The Luckiest number(欧拉函数||求某数最小的满足题意的因子)

    Chinese people think of '8' as the lucky digit. Bob also likes digit '8'. Moreover, Bob has his own ...

  3. [POJ3696]The Luckiest number(数论)

    题目:http://poj.org/problem?id=3696 题意:给你一个数字L,你要求出一个数N,使得N是L的倍数,且N的每位数都必须是8,输出N的位数(如果不存在输出0) 分析: 首先我们 ...

  4. POJ3696 The Luckiest Number 欧拉定理

    昨天终于把欧拉定理的证明看明白了...于是兴冲冲地写了2道题,发现自己啥都不会qwq 题意:给定一个正整数L<=2E+9,求至少多少个8连在一起组成正整数是L的倍数. 这很有意思么... 首先, ...

  5. 「POJ3696」The Luckiest number【数论,欧拉函数】

    # 题解 一道数论欧拉函数和欧拉定理的入门好题. 虽然我提交的时候POJ炸掉了,但是在hdu里面A掉了,应该是一样的吧. 首先我们需要求的这个数一定可以表示成\(\frac{(10^x-1)}{9}\ ...

  6. JavaScript Math和Number对象

    目录 1. Math 对象:数学对象,提供对数据的数学计算.如:获取绝对值.向上取整等.无构造函数,无法被初始化,只提供静态属性和方法. 2. Number 对象 :Js中提供数字的对象.包含整数.浮 ...

  7. Harmonic Number(调和级数+欧拉常数)

    题意:求f(n)=1/1+1/2+1/3+1/4-1/n   (1 ≤ n ≤ 108).,精确到10-8    (原题在文末) 知识点:      调和级数(即f(n))至今没有一个完全正确的公式, ...

  8. Java 特定规则排序-LeetCode 179 Largest Number

    Given a list of non negative integers, arrange them such that they form the largest number. For exam ...

  9. Eclipse "Unable to install breakpoint due to missing line number attributes..."

    Eclipse 无法找到 该 断点,原因是编译时,字节码改变了,导致eclipse无法读取对应的行了 1.ANT编译的class Eclipse不认,因为eclipse也会编译class.怎么让它们统 ...

随机推荐

  1. python之tkinter使用-二级菜单

    # 菜单功能说明:二级菜单 import tkinter as tk from tkinter import messagebox root = tk.Tk() root.title('菜单选择') ...

  2. codeforces9A

    Die Roll CodeForces - 9A Yakko,Wakko和Dot,世界著名的狂欢三宝,哈哈,不知道你是否看过这个动画片. 某一天,过年了,他们决定暂定卡通表演,并去某些地方旅游一下.Y ...

  3. TM数据

    qatestjr_xuyue10@vipabc.comqatestjr_xuyue01@vipabc.com jrNHc2 jUBRTEqatestjr_nianyue@vipabc.com QE9E ...

  4. ubuntu eclipse 无法打开

    报错: The catalog could not be loaded... 这个问题,我上网查了很久.. 基本上网上可用的办法我都试过了.全是失败的 firefox+autoproxy,shadow ...

  5. Cuba获取属性文件中的配置

    最直接的办法是,使用AppContext.getProperty("cuba.trustedClientPassword"); 可以获取到系统中的web模块下的wep-app.pr ...

  6. 【BZOJ4671】异或图(斯特林反演)

    [BZOJ4671]异或图(斯特林反演) 题面 BZOJ Description 定义两个结点数相同的图 G1 与图 G2 的异或为一个新的图 G, 其中如果 (u, v) 在 G1 与 G2 中的出 ...

  7. 【转】STC51单片机下载程序的时候不要在VCC端接DHT11

    今天使用51单片机学习板调试DHT11湿度传感器,下载程序的时候把DHT11烧掉了. 一开始我使用杜邦线把DHT11的VCC引脚接到学习板上的VCC端,GND接GND,数据端口接51单片机的P0.0. ...

  8. Eclipse 插件Maven在使用 add dependency,找不到包,解决办法

    通过右键单击pom.xml文件选择maven –> add dependency 或者是打开pom.xml文件,选择dependencies –>add 时,搜索不到依赖的jar包,解决方 ...

  9. The 2018 ACM-ICPC China JiangSu Provincial Programming Contest快速幂取模及求逆元

    题目来源 The 2018 ACM-ICPC China JiangSu Provincial Programming Contest 35.4% 1000ms 65536K Persona5 Per ...

  10. intest

    /* ============================================================================ Name : http.c Author ...