原创 zoj 1454 Employment Planning
d[i][j]:=第i個月僱傭j名工人的最小開支 #include <bits/stdc++.h> using namespace std; int h,s,f; int dd(int data) { if (data==0) ret
原创 zoj 1178 Booklet Printing
之所以這題要寫博客,那是因爲這題真是坑出翔 要不是我眼尖不知道又要wa多少次了 你能想象back前比front多了一個空格嗎?爲此我找了好久的錯 #include <bits/stdc++.h> using namespace std;
原创 zoj 1159 487-3279
簡單字符串處理,wa了十幾次後發現是自己最後的空格格式控制出了錯,暈 tmd,不管wa了多少次,我也一定要ac #include <bits/stdc++.h> using namespace std; string dd[1000];
原创 zoj 1276 Optimal Array Multiplication Sequence
dp,經典問題了 注意乘號兩邊都有空格 #include <bits/stdc++.h> using namespace std; struct node { int l,r; }; node m[15]; int n; int d
原创 zoj 1788 Quad Trees
題意:對於一個0,1矩陣,如果該矩陣全都是一種顏色,那麼就在樹上表示爲(0,1)or(0,0)第二個值看對應區域的顏色是0還是1了,如果顏色不同就在樹上標記爲1,並且繼續細分直到該區域顏色全都相同爲止,分法就是把當前區域平均分成4份,如圖
原创 zoj 1524 Supermarket
給定一個表單要求順序購買,求最小的花費 d[i][j]:=在前j個商家購買前i件物品的最小花費 d[i][j]=min(d[i][j-1],d[i-1][j-1]+price[j]); 其中第j個廠商賣的是第i件物品 滾動數組優化空間
原创 scanf/fscanf 的%[]和%n使用方法
標準輸入輸出函數%[]和%n說明符的使用方法 scanf fscanf,均從第一個非空格的可顯示字符開始讀起! 標準輸入輸出函數scanf具有相對較多的轉換說明符,它常常作爲入門級函數出現在各種教材中。但奇怪的是
原创 zoj 1520 Duty Free Shop
題意:Pedro有2種巧克力分別有m塊和 l塊,現在他有n個巧克力盒子,他希望把這n個盒子全都填滿,要求每種盒子中只能包含有一種巧克力,巧克力可以有剩餘,如果能填滿,就輸出第一種巧克力用了多少個盒子,並且輸出盒子的序號,如果不能就輸出Im
原创 zoj 1713 Haiku Review
水題,但是我從別人的博客那裏學來了新的讀入方式,可以簡化操作 #include <bits/stdc++.h> using namespace std; int is(char c) { switch (c) {
原创 zoj 1366 Cash Machine
揹包問題,二進制分割 #include <bits/stdc++.h> using namespace std; int main() { int crase,nn; while(~scanf("%d%d",&crase,&nn))
原创 zoj 1666 Square Coins
d[s]:湊齊s值的方法數 d[s]=sum(d[s-i*i]) 1=<i*i<=s #include <bits/stdc++.h> using namespace std; int main() { int n; int d[30
原创 zoj 1738 Lagrange's Four-Square Theoremdon
動態規劃 d[s]:組成s值的方法數 d[s]+=d[s-i*i] #include<bits/stdc++.h> using namespace std; #define N 40000 int main() { int n; in
原创 zoj 1602 Multiplication Puzzle
d[i][j]:在區間a[i]~a[j]範圍內能取到的最大值 d[i][j]=min{d[i][k]+a[k]*a[k+1]*a[k+2]+d[k+2][j]} i+1=<k<=j-1 #include<bits/stdc++.
原创 zoj 1425 Crossed Matchings
d[i][j]:=第一行的前i個與第二行的前j個匹配的最大值 d[i][j]:=max(d[i-1][j],d[i][j-1],d[s1-1][s2-1]+2) 1<=s1<i,1<=s2<j a[s1]==b[j],a[i]==b[s2
原创 zoj 1905 Power Strings
#include <bits/stdc++.h> using namespace std; char a[1000005]; int len; int check(int lens) { for (int i=0;i<len;i+=le