poj_3696_The Luckiest number】的更多相关文章

Chinese people think of '8' as the lucky digit. Bob also likes digit '8'. Moreover, Bob has his own lucky number L. Now he wants to construct his luckiest number which is the minimum among all positive integers that are a multiple of L and consist of…
还是挺难的吧......勉强看懂调了半天 首先表达式可以写成 8(10^x -1)/9,题意为求一个最小的x使L | 8(10^x -1)/9 设d=gcd(L,8) L | 8(10^x -1)/9 <=>9L | 8(10^x -1) <=>9L/d | 10^x -1 (因为 9L/d 和 8/d 互质了 所以 9L/d 能整除(8/d)*(10^x-1)和 8/d 无关,所以可以去掉) <=>10^x 同余 1(mod 9L/d) 引理: 若a,n互质,则满足1…
The Luckiest Number 题目大意:给你一个int范围内的正整数n,求这样的最小的x,使得:连续的x个8可以被n整除. 注释:如果无解输出0.poj多组数据,第i组数据前面加上Case i: 即可. 想法:这题还是挺好的.我最开始的想法是一定有超级多的数输出0.然后...我就在哪里找啊找....其实这道题是一道比较好玩儿的数论题.我们思考:连续的8可用什么来表示出来?$\frac{(10^x-1)}{9}\cdot 8$.其实想到这一步这题就做完了.这题的精髓就在于告诉我们连续的连…
题意 Language:Default The Luckiest number Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 7083 Accepted: 1886 Description Chinese people think of '8' as the lucky digit. Bob also likes digit '8'. Moreover, Bob has his own lucky number L. Now…
一.题目 Chinese people think of '8' as the lucky digit. Bob also likes digit '8'. Moreover, Bob has his own lucky number L. Now he wants to construct his luckiest number which is the minimum among all positive integers that are a multiple of L and consi…
Chinese people think of '8' as the lucky digit. Bob also likes digit '8'. Moreover, Bob has his own lucky number L. Now he wants to construct his luckiest number which is the minimum among all positive integers that are a multiple of L and consist of…
The Luckiest number Time Limit: 1000ms Memory Limit: 32768KB This problem will be judged on HDU. Original ID: 246264-bit integer IO format: %I64d      Java class name: Main Chinese people think of '8' as the lucky digit. Bob also likes digit '8'. Mor…
The Luckiest number Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 1163    Accepted Submission(s): 363 Problem Description Chinese people think of '8' as the lucky digit. Bob also likes digit '…
题目:http://poj.org/problem?id=3696 题意:给你一个数字L,你要求出一个数N,使得N是L的倍数,且N的每位数都必须是8,输出N的位数(如果不存在输出0) 分析: 首先我们假设N是x个8组成的 那么88888...888=kL 提个8出来:8*111..1111=kL ① 因为题目只要求x的值,所以要弄出关于x的方程 11...111可以写成(10^k-1)/9 于是①变成了8(10^x-1)=9kL ② 再来回顾下题目,②式中x和k是变量,且都属于正整数,要根据②式…
该题没思路,参考了网上各种题解.... 注意到凡是那种11111..... 22222..... 33333.....之类的序列都可用这个式子来表示:k*(10^x-1)/9进而简化:8 * (10^x-1)/9=L * k (k是一个整数)8*(10^x-1)=9L*kd=gcd(9L,8)=gcd(8,L)8*(10^x-1)/d=9L/d*k令p=8/d q=9L/d p*(10^x-1)=q*k因为p,q互质,所以q|(10^x-1),即10^x-1=0(mod q),也就是10^x=1…
# 题解 一道数论欧拉函数和欧拉定理的入门好题. 虽然我提交的时候POJ炸掉了,但是在hdu里面A掉了,应该是一样的吧. 首先我们需要求的这个数一定可以表示成\(\frac{(10^x-1)}{9}\times 8\). 那么可以列出一个下面的方程 \[\frac{(10^x-1)}{9}\times 8=L\times k\] 设\(d=gcd(9L,8)=gcd(L,8)\) \[\frac89(10^x-1)=Lk\] \[\frac{8(10^x-1)}d=\frac{9Lk}{d}\]…
题意: 给一个L,求长度最小的全8数满足该数是L的倍数. 分析: 转化为求方程a^x==1modm. 之后就是各种数学论证了. 代码: //poj 3696 //sep9 #include <iostream> #include <algorithm> using namespace std; typedef long long ll; ll L; ll factor[65536]; ll mul(ll x,ll y,ll p) { ll ret=0; while(y){ if(y…
昨天终于把欧拉定理的证明看明白了...于是兴冲冲地写了2道题,发现自己啥都不会qwq 题意:给定一个正整数L<=2E+9,求至少多少个8连在一起组成正整数是L的倍数. 这很有意思么... 首先,连续的8可表示为:8*(10^x-1)/9; 那么就是L|8*(10^x-1)*9 => 9*L|8*(10^x-1) ,求最小的x: 我们设d=gcd(L,8) 则9*L/d | 8/d*(10^x-1),因为此时9*L/d 和 8/d 互质,所以9*L/d | 10^x-1,所以 10^x ≡ 1…
给定一个数,判断是否存在一个全由8组成的数为这个数的倍数 若存在则输出这个数的长度,否则输出0 /* 个人感觉很神的一道题目. 如果有解的话,会有一个p满足:(10^x-1)/9*8=L*p => 10^x-1=9*L*p/8 设m=9*L/gcd(L,8) 则存在p1使得 10^x-1=m*p1 => 10^x=1(mod m) 根据欧拉定理 10^φ(m)=1(mod m) 所以x一定是φ(m)的因数(这好像是某个定理). */ #include<iostream> #incl…
[题目链接] http://poj.org/problem?id=3696 [算法] 设需要x个8 那么,这个数可以表示为 : 8(10^x - 1) / 9, 由题, L | 8(10^x - 1) / 9 令d = gcd(L,8),则 : L | 8(10^x - 1) / 9 9L | 8 (10^x - 1)  ->  9L/d | 10^x-1 -> 10^x(mod (9L/d)) = 1 易证a^x(mod n) = 1的最小正整数解是phi(n)的一个约数 那么,求出欧拉函数…
Period of an Infinite Binary Expansion 题目大意:给你一个分数,求这个分数二进制表示下从第几位开始循环,并求出最小循环节长度. 注释:int范围内. 想法:这题说实话,是一道神题!我们思考一下,如何将一个小数换成二进制?连续的乘2,然后取首位.这样的比较简洁的转换方式注定了这题其实是可做的.我们可以抓住循环节的在这样的方法下是怎样形成的?显然,存在一个x,使得每多乘$2^x$都会使得所形成的答案相同.第二点,我们知道,一个分数的循环节开始之前是不参与循环的.…
t1-Prime Distance 素数距离 大范围筛素数. t2-阶乘分解 欧拉筛素数后,按照蓝皮上的式子筛出素数. 复杂度:O(nlogn) t3-反素数ant 搜索 t4-余数之和 整除分块+容斥原理 t5-Hankson的趣味题 \(gcd\) t6-Visible Lattice Points 欧拉筛出欧拉函数,前缀和推式子求解. t7-The Luckiest number [题解] t8-Sumdiv 逆元 t9-同余方程 扩欧 t10-Strange Way to Express…
 1.burnside定理,polya计数法 这个专题我单独写了个小结,大家可以简单参考一下:polya 计数法,burnside定理小结 2.置换,置换的运算 置换的概念还是比较好理解的,<组合数学>里面有讲.对于置换的幂运算大家可以参考一下潘震皓的那篇<置换群快速幂运算研究与探讨>,写的很好. *简单题:(应该理解概念就可以了) pku3270 Cow Sorting http://acm.pku.edu.cn/JudgeOnline/problem?id=3270 pku…
[SinGuLaRiTy-1020] Copyright (c) SinGuLaRiTy 2017. All Rights Reserved. [CQBZOJ 1464] Hankson 题目描述 Hanks博士是BT (Bio-Tech,生物技术) 领域的知名专家,他的儿子名叫Hankson.现在,刚刚放学回家的Hankson正在思考一个有趣的问题. 今天在课堂上,老师讲解了如何求两个正整数c1和c2的最大公约数和最小公倍数.现在Hankson认为自己已经熟练地掌握了这些知识,他开始思考一个“…
The Luckiest number Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 980    Accepted Submission(s): 301 Problem Description Chinese people think of '8' as the lucky digit. Bob also likes digit '8…
Chinese people think of '8' as the lucky digit. Bob also likes digit '8'. Moreover, Bob has his own lucky number L. Now he wants to construct his luckiest number which is the minimum among all positive integers that are a multiple of L and consist of…
目录 1. Math 对象:数学对象,提供对数据的数学计算.如:获取绝对值.向上取整等.无构造函数,无法被初始化,只提供静态属性和方法. 2. Number 对象 :Js中提供数字的对象.包含整数.浮点数等等.并提供数字的类型转换.小数点截取等方法. 1. Math 对象 1.1 介绍 Math 对象,是数学对象,提供对数据的数学计算,如:获取绝对值.向上取整等.无构造函数,无法被初始化,只提供静态属性和方法. 1.2 构造函数 无 :Math 对象无构造函数,无法被初始化,只提供静态属性和方法…
题意:求f(n)=1/1+1/2+1/3+1/4-1/n   (1 ≤ n ≤ 108).,精确到10-8    (原题在文末) 知识点:      调和级数(即f(n))至今没有一个完全正确的公式,但欧拉给出过一个近似公式:(n很大时)       f(n)≈ln(n)+C+1/2*n       欧拉常数值:C≈0.57721566490153286060651209       c++ math库中,log即为ln. 题解: 公式:f(n)=ln(n)+C+1/(2*n); n很小时直接求…
Given a list of non negative integers, arrange them such that they form the largest number. For example, given [3, 30, 34, 5, 9], the largest formed number is 9534330. Note: The result may be very large, so you need to return a string instead of an i…
Eclipse 无法找到 该 断点,原因是编译时,字节码改变了,导致eclipse无法读取对应的行了 1.ANT编译的class Eclipse不认,因为eclipse也会编译class.怎么让它们统一呢,就是在build.xml里的javac标签里加上一句debug="true",一切就OK了. 如:<javac ... debug="true"> 链接:http://blog.csdn.net/liu251/article/details/36391…
/*移除HTML5 input在type="number"时的上下小箭头*/ input::-webkit-outer-spin-button, input::-webkit-inner-spin-button{ -webkit-appearance: none; margin:; } input[type="number"]{-moz-appearance:textfield;}…
真机调试免费App ID出现的问题The maximum number of apps for free development profiles has been reached.免费应用程序调试最大限度苹果免费App ID只能运行2个应用程序,当调试第三个的时候就会报这个错误,必须把之前的应用程序删除,才能调试新的 解决办法:1.连接iPhone 打开Xcode->Window->Devices     2.接着出现这个界面   3.删除其中一个,不是本次运行的应用程序 4.接着会弹框  …
每一个实数都能用有理数去逼近到任意精确的程度,这就是有理数的稠密性.The rational points are dense on the number axis.…
There are a number of spherical balloons spread in two-dimensional space. For each balloon, provided input is the start and end coordinates of the horizontal diameter. Since it's horizontal, y-coordinates don't matter and hence the x-coordinates of s…
Given n points in the plane that are all pairwise distinct, a "boomerang" is a tuple of points (i, j, k) such that the distance between i and j equals the distance between i and k (the order of the tuple matters). Find the number of boomerangs.…