摘要:
高精度java做View Code import java.io.*;import java.util.*;import java.math.*;public class Main { static public void main(String[] args) { Scanner cin = new Scanner(new BufferedInputStream(System.in)); while (true) { BigInteger a = cin.nextBigInteger(); int b = cin.... 阅读全文
posted @ 2011-09-16 17:15
undefined2024
阅读(133)
评论(0)
推荐(0)
摘要:
简单题View Code #include <iostream>#include <cstdlib>#include <cstring>#include <cstdio>#include <algorithm>using namespace std;#define maxn 15int n, f[maxn], g[maxn], sum;int cal(){ int ret = 0; for (int i = 0; i < n; i++) ret += f[i] * g[i]; return ret;}int main(){ // 阅读全文
posted @ 2011-09-16 17:03
undefined2024
阅读(270)
评论(0)
推荐(0)
摘要:
差分约束系统差分约束系统有两种方式可以求解,最短路和最长路。当我们把不等式整理成d[a]+w<=d[b]时,我们求最长路。整理成d[a]+w>=d[b]时,我们求最短路。当求最短路时,我们通常要把各点距离初始化为正无穷,求最短路,把各点距离逐渐减小,直到符合所有不等式。也就是开始各点不符合条件,后来通过减小变得符合了,所以一定是符合条件的最大值。既然是求最大值,并且是减小各点距离,也就是把各点由数轴的右侧向左侧拉,所以我们一定要选择一个最终在数轴最左侧的点,并初始化为0,把所有正无穷的点拉近到符合不等式。最长路同理。另外本题我的做法判断impossible的情况是不完全的,暂未发现 阅读全文
posted @ 2011-09-16 16:20
undefined2024
阅读(899)
评论(0)
推荐(0)