現在每天做的題都記錄一下,免得不知道自己在幹什麼。
poj2406:用next陣列的定義求迴圈節
poj3261:字尾陣列**題
spoj705:同上,這題我wa了幾次,結果發現:我以為字串只有大寫字母,其實有小寫。
**如下:
poj2406
/*
* @author: duyixian
* @date: 2015-11-14 14:27:16
* @last modified by: duyixian
* @last modified time: 2015-11-14 14:39:42
*/#include "cstdio"
#include "cstdlib"
#include "iostream"
#include "algorithm"
#include "cstring"
#include "queue"
using namespace std;
#define max_size 1000005
#define inf 0x3f3f3f3f
#define eps
#define mod
inline int get_int()
while(ch < '0' || ch > '9');
do while(ch >= '0' && ch <= '9');
return num * flag;
}int length;
int next[max_size];
char str[max_size];
int main()
if(length % (length - next[length]))
printf("1\n");
else
printf("%d\n", length / (length - next[length]));
} return 0;
}
poj3261:
/*
* @author: duyixian
* @date: 2015-11-14 14:51:22
* @last modified by: duyixian
* @last modified time: 2015-11-14 15:15:12
*/#include "cstdio"
#include "cstdlib"
#include "iostream"
#include "algorithm"
#include "cstring"
#include "queue"
using namespace std;
#define max_size 20005
#define inf 0x3f3f3f3f
#define eps
#define mod
inline int get_int()
while(ch < '0' || ch > '9');
do while(ch >= '0' && ch <= '9');
return num * flag;
}int n, limit = 20000, k;
int num[max_size], sa[max_size], sa1[max_size], rank[max_size], rank1[max_size], height[max_size], bucket[max_size];
inline void calculate_sa()
}inline void calculate_height()
}inline bool find(int length)
if(num >= k)
return true;
} return false;
}inline void solve()
cout << left << endl;
}int main()
spoj705:
/*
* @author: duyixian
* @date: 2015-11-14 15:58:21
* @last modified by: duyixian
* @last modified time: 2015-11-14 16:47:07
*/#include "cstdio"
#include "cstdlib"
#include "iostream"
#include "algorithm"
#include "cstring"
#include "queue"
using namespace std;
#define max_size 50005
#define inf 0x3f3f3f3f
#define eps
#define mod
inline int get_int()
while(ch < '0' || ch > '9');
do while(ch >= '0' && ch <= '9');
return num * flag;
}int t, n, limit;
int rank[max_size], sa[max_size], rank1[max_size], sa1[max_size], bucket[max_size], height[max_size];
long long ans;
char str[max_size];
inline void calculate_sa()
}inline void calculate_height()
}int main()
return 0;
}
OI刷題記錄
2014 4 18 poj3264 bzoj1699 balanced lineup rmq 2014 4 19 bzoj1012 jsoi2008 最大數maxnumber noi2004 鬱悶的出納員 bzoj3224 tyvj 1728 普通平衡樹 2014 4 20 bzoj1862 105...
面試刷題記錄
寫一段 判斷乙個包括 的表示式是否合法 注意看樣例的合法規則。給定乙個表示式a,請返回乙個bool值,代表它是否合法。測試樣例 a b 5 4 返回 true 測試樣例 a b 5 4 返回 false include vector include iostream using namespace ...
刷題記錄2015 11 18
補上 hdu3065 多組資料有點坑爹 hdu2222 模板,但是換了一種寫法,雖然之前那種寫法貌似複雜度也是o n 的 不知道怎麼證明,但是感覺和kmp差不多 這種寫法構建了乙個trie圖,複雜度是很顯然的o n 而且 還短一點,大概要快十分之一。如下 hdu3065 include cstdio...