随笔分类 - 数学——高精度
摘要:题目链接:http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=3549最核心的是由于m^n 太大, 存不下了,存下来的复杂度也太高,就只能边运算边取模,看别人的代码才想到。0s 不会很多,就暴力枚举。import java.math.*;import java.util.*;public class Main { static BigInteger Fast_Power(BigInteger x ,BigInteger n, BigInteger mod) { BigInteger ret = Bi...
阅读全文
摘要:题目链接:http://codeforces.com/contest/294/problem/C代码:import java.util.*;import java.math.*;public class Main { public static void main(String[] args){ Scanner cin = new Scanner(System.in); BigInteger[] fir; fir = new BigInteger[1050]; fir[0] = fir[0].ONE; for(int ...
阅读全文
摘要:import java.io.*; import java.math.BigInteger; import java.util.*; public class Main { public static void main(String[] args) { BigInteger ans,Zero; Zero = BigInteger.ZERO; ans = BigInteger.ZERO; Scanner cin = new Scanner(System.in); while(cin.hasNextBig...
阅读全文
摘要:题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4474(a*10+b)%c = ((a%c)*10+b%c)%c;然后从高位开始枚举能填的数字填充,只是注意最高位(第一位)不能为0。代码:#include#include#include#include#include#includeusing namespace std;struct Node{ string s; int mod; Node(string s="",int mod=0): s(s),mod(mod) {}};bool can[15];bool vis[100
阅读全文
摘要:题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4762题目大意:一个圆形蛋糕,现在要分成M个相同的扇形,有n个草莓,求n个草莓都在同一个扇形上的概率。算法思路:n个草莓在圆形上有一个最左边的,为了好理解,先把假设草莓有1-n的不同编号。 现在从n个草莓中选出一个编号A的放在最左边(这个最左边可以随便放),得到C(n,1)*1.然后把其余的n-1草莓不分先后的放在A的右边角大小为(360)/m的扇形区域内就可以了。 所以概率为 n/(m^(n-1));由于20^20超 long long了,所以要用高精度。而且要约分。代码:#include#inc
阅读全文
摘要:题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4608 1 #include 2 #include 3 #include 4 #include 5 #include 6 #include 7 #include 8 #define maxn 105000 9 using namespace std;10 11 int len;12 char a[maxn],b[maxn]; 13 14 15 int getsum(){16 int ans = 0; //printf("%d\n",len);17 for(int i=0...
阅读全文