自定义博客皮肤VIP专享

*博客头图:

格式为PNG、JPG,宽度*高度大于1920*100像素,不超过2MB,主视觉建议放在右侧,请参照线上博客头图

请上传大于1920*100像素的图片!

博客底图:

图片格式为PNG、JPG,不超过1MB,可上下左右平铺至整个背景

栏目图:

图片格式为PNG、JPG,图片宽度*高度为300*38像素,不超过0.5MB

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+
  • 博客(43)
  • 资源 (1)
  • 收藏
  • 关注

原创 SPOJ BYTESM2

#include #include using namespace std;const int N = 100;int tiles[N][N];int sums[N][N];int r,c;int totalsum;void computeMax(int i, int j) { int s1, s2, s3; if (j == 0) { s1 = -1; } els

2014-05-14 22:44:46 583

转载 一个非常好的01背包问题的详解,非常清晰

摘自:http://love-oriented.com/pack/P01.htmlP01: 01背包问题题目有N件物品和一个容量为V的背包。第i件物品的费用是c[i],价值是w[i]。求解将哪些物品装入背包可使价值总和最大。基本思路这是最基础的背包问题,特点是:每种物品仅有一件,可以选择放或不放。用子问题定义状态:即f[i][v]表示前i件物品恰放入一个容量为v的背包可

2014-02-13 14:07:35 712

原创 SPOJ PIGBANK

// http://www.spoj.com/problems/PIGBANK/#include#include#includeusing namespace std;#define Max 10000// dp(x) means the minimal value of conins with weight x.int dp[Max+1];// temp(x) means

2014-02-11 00:49:52 533

原创 SPOJ MARBLES

// http://www.spoj.com/problems/MARBLES/#include using namespace std;// 假设30个位置void f() { int n, k; cin >> n >> k; long double result; n--; k--; result = 1.0; for(double i=0.0; i<k; i+=1.0

2014-02-11 00:49:17 468

原创 SPOJ MAXLN

// http://www.spoj.com/problems/MAXLN/#include #include using namespace std;void f(int casenum) { int r; double c = 0.25; cin >> r; double result = 4.0f * (double)r * (double)r + c; cout << "

2014-02-11 00:47:02 536

原创 SPOJ PALIN

// http://www.spoj.com/problems/PALIN/#include #include int main(){ int t,len,l,m,r,c,cur; char K[1000001],tmp[1000001]; scanf("%d",&t); while(t--) { memset(K,0,sizeof(K)); memset(tmp,0

2014-02-07 00:10:31 477

原创 SPOJ HUBULLU

// http://www.spoj.com/problems/HUBULLU/// Because 1 is all numbers’ divisor. // So, the first people can choose ‘1’ with all other numbers.#include using namespace std;void f() { int n; cin >

2014-02-06 16:28:40 988

原创 SPOJ INVCNT

// http://www.spoj.com/problems/INVCNT/#include using namespace std;long long mergeCount(int a[], int low, int mid, int high) { int b[200000]; int i = low; int j = mid + 1; int k = low; long

2014-02-06 13:58:18 486

原创 SPOJ BITMAP

// http://www.spoj.com/status/BITMAP,lojian/#include #include using namespace std;int f(){ int n,m; char c; cin >> n >> m; short int tab[n][m]; queue Q; for(int i=0; i<

2014-02-06 13:57:48 499

原创 SPOJ ARITH2

//http://www.spoj.com/problems/ARITH2/#include #include #include using namespace std;int main() { int t; cin >> t; queue numbers; queue operations; long result = 0; bool first = true; whil

2014-01-30 00:28:59 433

原创 SPOJ BEENUMS

// http://www.spoj.com/problems/BEENUMS/#include using namespace std;int main() { long cells; cin >> cells; while (cells != -1) { if (cells == 1) { cout << "Y" << endl; } else { int c

2014-01-29 23:46:35 428

原创 SPOJ AP2

// http://www.spoj.com/problems/AP2/#include #include using namespace std;int main() { ios_base::sync_with_stdio(false); int t; cin >> t; while (t-- >0) { long long thirdt = 0; long long

2014-01-29 10:02:44 552

原创 SPOJ NGM

// http://www.spoj.com/problems/NGM//* Win/Lost Table1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20W W W W W W W W W L W W W W W W W W W LSo seems postition X0 can be lose for Nik*

2014-01-28 23:12:53 481

原创 SPOJ GIRLSNBS

// http://www.spoj.com/problems/GIRLSNBS/#include #include using namespace std;int main(){ int g, b; cin >> g >> b; while (g != -1 && b != -1) { int bigger, smaller; if (g > b) { bigge

2014-01-28 17:36:28 948

原创 SPOJ OFFSIDE

// http://www.spoj.com/problems/OFFSIDE/#include #include #include using namespace std;int main(){ int a, d; cin >> a >> d; vector A; vector D; while (a != 0 && d != 0) { int t; for (in

2014-01-28 14:53:19 678

原创 SPOJ PT07Y

// http://www.spoj.com/problems/PT07Y/#include using namespace std;int findroot(int* points, int p) { while (points[p] != p) p = points[p]; return p;}int main() { int V, E; cin >> V >> E; in

2014-01-28 14:00:41 712

原创 SPOJ WILLITST

// http://www.spoj.com/problems/WILLITST/#include using namespace std;int main() { unsigned long long int t; cin >> t; if((t&(t-1))==0) //checks for 2^n cout << "TAK" << endl; else

2014-01-26 17:41:32 451

原创 SPOJ FENCE1

// http://www.spoj.com/problems/FENCE1/#include #include using namespace std;/*L = PI * R;R = L/PI;S = PI * (L/PI)^2 /2 = L^2/PI/2*/const float PI = 3.1415926f;int main() { ios_base::sync

2014-01-26 15:28:35 501

原创 SPOJ STPAR

// http://www.spoj.com/problems/STPAR/#include #include using namespace std;int main() { ios_base::sync_with_stdio(false); int num = 0; cin >> num; const int NOTSET = -1; stack waitting;

2014-01-26 14:58:19 590

原创 SPOJ STAMPS

// http://www.spoj.com/problems/STAMPS/#include #include using namespace std;int main() { ios_base::sync_with_stdio(false); int t; cin >> t; int s = 1; while (t-- >0) { int target, np;

2014-01-25 22:18:06 479

原创 SPOJ ARMY

// http://www.spoj.com/problems/ARMY/#include #include #include #include using namespace std;int main(int argc, char*argv[]) { ios_base::sync_with_stdio(false); int t; cin >> t; string

2014-01-25 21:39:31 414

原创 SPOJ Alphacode

// http://www.spoj.com/problems/ACODE/#include #include #include using namespace std;const int maxn = 50000 + 10;int n;char s[ maxn ];long long f[ maxn ];void work()

2014-01-15 22:56:58 505

原创 Ambiguous Permutations

//http://www.spoj.com/problems/PERMUT2/#include using namespace std;int main(int argc, char* argv[]) { int buffer[100001]; int n; cin >> n; while (n!=0) { for (int i = 1; i <=n; i++) { c

2014-01-15 22:10:00 662

原创 Anti-Blot System

// http://www.spoj.com/problems/ABSYS/#include #include #include #include #include using namespace std;int main(int argc, char* argv[]) { int t; cin >> t; string line; std::getline(std::

2014-01-14 23:09:03 647

原创 Count on Cantor

// http://www.spoj.com/problems/CANTON/#include using namespace std;int main(int argc, char* argv[]) { int t; cin >> t; while (t-- >0) { int n; cin >> n; int approacher = 1; int x = 1;

2014-01-14 22:30:31 508

原创 Triple Fat Ladies

// http://www.spoj.com/problems/EIGHTS/#include using namespace std;int main(int argc, char* argv[]) { int t; cin >> t; while (t-- >0) { long long k; cin >> k; cout << (192ll + (k -1ll)*

2014-01-13 22:02:25 572

原创 Hangover

// http://www.spoj.com/problems/HANGOVER/#include using namespace std;int main(int argc, char* argv[]) { float testcase; cin >> testcase; while (testcase != 0.00f) { float a = 2.0f; floa

2014-01-13 21:44:34 431

原创 Bytelandian gold coins

//http://www.spoj.com/problems/COINS/#include #include using namespace std;#define MEMOSIZE 1000000unsigned memo[MEMOSIZE];unsigned maxprofit(unsigned n) { unsigned s; if ((n<MEMOSIZE)&&memo[

2014-01-12 22:10:16 857

原创 The last digit

// http://www.spoj.com/problems/LASTDIG/#include using namespace std;int dat[10][4]={{0,0,0,0}, {1,1,1,1}, {2,4,8,6}, {3,9,7,1}, {4,6,4,6}, {5,5,5,5}, {6,6,6,6},

2014-01-12 21:51:55 517

原创 Candy III

// http://www.spoj.com/problems/CANDY3/#include using namespace std;int main(int argc, char* argv[]) { int t; cin >> t; while (t-- >0) { long long candies; long long remidner = 0; long l

2014-01-12 21:47:15 428

原创 Rectangles

//http://www.spoj.com/problems/AE00/#include #include using namespace std;int main(int argc, char* argv[]) { int n; cin >> n; int sum = 0; for (int i = 1; i <=n; i++) { for (int w=1; w*w<=i

2014-01-12 21:15:34 476

原创 What’s Next

// http://www.spoj.com/problems/ACPC10A/#include using namespace std;int main(int argc, char* argv[]) { int a, b, c; cin >> a >> b >> c; while(a != b && b != c && c != a) { int diffba = b -

2014-01-12 16:09:07 481

原创 Candy I

// http://www.spoj.com/problems/CANDY/#include using namespace std;int main(int argc, char* argv[]) {int n;cin >> n;while(n!=-1) {int *p = new int[n];int total = 0;int av

2014-01-12 15:56:03 534

原创 Fashion Shows

// http://www.spoj.com/problems/FASHION/#include #include using namespace std;int compare_ints(const void* a, const void* b) { int arg1 = *reinterpret_cast(a); int arg2 = *reinterpret_cast(b);

2014-01-12 15:30:23 482

原创 Julka

// http://www.spoj.com/problems/JULKA/// hint: x+y=total x-y=diff x = (total+diff)/2; y = total -x;#include #include #include #include #include #include #include #include #include #inclu

2014-01-12 14:47:03 519

原创 To and Fro

// http://www.spoj.com/problems/TOANDFRO/#include #include #include using std::cin;using std::cout;using std::endl;using std::string;using std::memset;int main(int argc, char* argv[]) { int

2014-01-12 10:42:52 495

原创 Adding Reversed Numbers

// http://www.spoj.com/problems/ADDREV/#include #include #include #include int main(int argc, char* argv[]){ using std::string; using std::reverse; int N = 0; std::cin >> N; while ( N

2014-01-12 06:16:14 573

原创 Factorial

// http://www.spoj.com/problems/FCTRL/#include #include int main(int argc, char* argv[]){ using std::cin; using std::cout; int c = 0; cin >> c; while (c-- >0) { int n; cin >> n; int a

2014-01-12 06:15:13 597

原创 Small factorials

// http://www.spoj.com/problems/FCTRL2/#include #include using std::cin;using std::cout;using std::endl;unsigned long long calFactorial(int n){ unsigned long long result=1; for(unsigned lon

2014-01-12 06:13:55 480

原创 Prime Generator

// http://www.spoj.com/problems/PRIME1/#include #include #include #include using namespace std;int main(){ int casen; cin >> casen; while(casen--) { int n,m;

2014-01-12 06:10:56 516

C的并发行为(C Concurrency In Action)

C的并发行为 C Concurrency In Action

2011-03-23

空空如也

TA创建的收藏夹 TA关注的收藏夹

TA关注的人

提示
确定要删除当前文章?
取消 删除