ios_base::sync_with_stdio(); cin.tie(); ], nxt[MAXM << ], Head[MAXN], ed = ; inline void addedge(int u, int v) { to[++ed] = v; nxt[ed] = Head[u]; Head[u] = ed; } #include<iostream> #include<cstdio> #include<cstdlib> #include<cst…
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…
zhx's contest Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)Total Submission(s): 1867    Accepted Submission(s): 596 Problem Description As one of the most powerful brushes, zhx is required to give his juniors n p…
洛谷试炼场-简单数学问题 B--P1045 麦森数 Description 形如2^P−1的素数称为麦森数,这时P一定也是个素数.但反过来不一定,即如果PP是个素数,2^P-1 不一定也是素数.到1998年底,人们已找到了37个麦森数.最大的一个是P=3021377P=3021377,它有909526位.麦森数有许多重要应用,它与完全数密切相关. 任务:从文件中输入PP(1000<P<31000001000<P<3100000),计算2^P-1 的位数和最后500位数字(用十进制高…
/* 矩阵乘法+快速幂. 一开始迷之题意.. 这个gcd有个规律. a b b c=a*x+b(x为常数). 然后要使b+c最小的话. 那x就等于1咯. 那么问题转化为求 a b b a+b 就是斐波那契了.... */ #include<iostream> #include<cstdio> #define MAXN 3 #define LL long long #define mod 1000000007 using namespace std; LL n; LL a[MAXN]…
Fermat's theorem states that for any prime number p and for any integer a > 1, ap = a (mod p). That is, if we raise a to the pth power and divide by p, the remainder is a. Some (but not very many) non-prime values of p, known as base-a pseudoprimes,…
1202: GCD Time Limit: 1 Sec  Memory Limit: 1280 MBSubmit: 201  Solved: 31[Submit][Status][Web Board] Description   Input The first line is an positive integer  T . (1<=T<= 10^3) indicates the number of test cases. In the next T lines, there are thre…
Sum Time Limit:1000MS     Memory Limit:131072KB     64bit IO Format:%I64d & %I64u Submit Status Practice HDU 4704 Description   Sample Input 2   Sample Output 2 Hint 1. For N = 2, S(1) = S(2) = 1. 2. The input file consists of multiple test cases. 题意…
分析:直接上吧,建议不要使用模板,否则没啥意义了. 代码如下: =================================================================================================================================== #include<algorithm> #include<stdio.h> #include<string.h> #include<queu…
import java.io.*; import java.math.*; import java.util.*; import java.text.*; public class Main { public static void main(String[] args) { Scanner cin = new Scanner(System.in); BigInteger a, b, m, ans; while (cin.hasNext()) { ans = new BigInteger("1&…