2011年10月6日
摘要: import java.io.IOException;import java.util.Scanner;public class Sieve { static Scanner cin = new Scanner(System.in); public static void main(String[] args) { // We will compute all primes less than the value specified on the // command line, or, if no argument, all primes less than 100. int max ... 阅读全文
posted @ 2011-10-06 20:55 Mathida 阅读(244) 评论(0) 推荐(0) 编辑
摘要: /*以123的全排列为例:1 1232 1323 2314 2135 3126 321*//* 结果可以分为三部分:123 132; 213 231; 312 321; 对于123 132,去掉1后23可看作是其子问题*/import java.io.IOException;public class PermulateArray{ static int size; static int count=0; static char[] charArray; public static void main(String[] args)throws IOException{ String inpu.. 阅读全文
posted @ 2011-10-06 20:35 Mathida 阅读(176) 评论(0) 推荐(0) 编辑
  2011年9月24日
摘要: import java.io.BufferedInputStream;import java.io.BufferedOutputStream;import java.io.FileReader;import java.io.FileWriter;import java.io.IOException;import java.io.PrintWriter;import java.util.Scanner;public class Main{ public static Scanner cin=new Scanner(new BufferedInputStream(System.in)); publ 阅读全文
posted @ 2011-09-24 12:58 Mathida 阅读(193) 评论(0) 推荐(0) 编辑
  2011年9月13日
摘要: 题目大意就不说了,方法是利用Kuskral算法(最小生成树算法)。因为要遍历全图,所以总存在一个生成树,所以我们利用Kuskral算法找到最后一条边---也就是最长的边。#include <iostream>#include <cstdio>#include <functional>#include <set>#include <algorithm>using namespace std;#define MAXV 2009#define INF 1000000090struct Edge{ int u,v; long long w; 阅读全文
posted @ 2011-09-13 14:09 Mathida 阅读(162) 评论(0) 推荐(0) 编辑
  2011年9月10日
摘要: 整数划分有两种1.不限定划分的个数如:5 = 1+1+1+1+1.5 = 1+1+1+2.5 = 1+2+2.5 = 1+1+3.5 = 2+3.5 = 1+4.5 = 5.可以利用组合数学中的母函数:G(x) = (1+x^1+x^2+x^3+...+x^n)(1+x^2+x^4+x^6+...+x^(2*p))(1+x^3+x^6+...+x^(3*q))+...using System;using System.Collections.Generic;using System.Linq;using System.Text;namespace 整数划分{ class Program ... 阅读全文
posted @ 2011-09-10 14:30 Mathida 阅读(179) 评论(0) 推荐(0) 编辑
  2011年9月6日
摘要: using System;using System.Collections.Generic;using System.Collections;using System.Linq;using System.Text;namespace Timus_Online{ class ProductOfDigits { static void Main() { string[] input = Console.In.ReadToEnd().Split(new char[] { ' ', '\t', '\n', '\r' }, StringSp 阅读全文
posted @ 2011-09-06 17:56 Mathida 阅读(148) 评论(0) 推荐(0) 编辑
摘要: 1 using System; 2 using System.Collections.Generic; 3 using System.Linq; 4 using System.IO; 5 using System.Text; 6 using System.Text.RegularExpressions; 7 8 namespace Timus_Online 9 {10 class StonePiles11 {12 static void Main()13 {14 string[] input = Console.In.... 阅读全文
posted @ 2011-09-06 14:14 Mathida 阅读(161) 评论(0) 推荐(0) 编辑