题目链接:https://cn.vjudge.net/contest/276376#problem/B 题目大意:for( int i= A ; i != B; i+ = c ),然后给你A,B,C,K,前三个是for循环里面的变量,K指的是每一次ABC三个数都对2^k进行取余,然后问你要使得这个循环停止,最少的循环次数,如果是一个死循环,就输出"FOREVER". 具体思路:和我之前写的那一篇博客思路差不多,证明过程直接上图. 一开始没有注意到B,等号右边应该是B-A,而不是B,以…
1.欧几里得算法(辗转相除法) 直接上gcd和lcm代码. int gcd(int x,int y){ ?x:gcd(y,x%y); } int lcm(int x,int y){ return x*y/gcd(x,y); } 2.扩欧:exgcd:对于a,b,一定存在整数对(x,y)使ax+by=gcd(a,b)=d ,且a,b互质时,d=1. x,y可递归地求得. 我懒得改返回值类型了 long long exgcd(long long a,long long b,long long &x,…
Repeater POJ - 3768 Harmony is indispensible in our daily life and no one can live without it----may be Facer is the only exception. One day it is rumored that repeat painting will create harmony and then hundreds of people started their endless draw…