来自HDOJ:
/*
━━━━━┒ギリギリ♂ eye!
┓┏┓┏┓┃キリキリ♂ mind!
┛┗┛┗┛┃\○/
┓┏┓┏┓┃ /
┛┗┛┗┛┃ノ)
┓┏┓┏┓┃
┛┗┛┗┛┃
┓┏┓┏┓┃
┛┗┛┗┛┃
┓┏┓┏┓┃
┛┗┛┗┛┃
┓┏┓┏┓┃
┃┃┃┃┃┃
┻┻┻┻┻┻
*/
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <climits>
#include <complex>
#include <cassert>
#include <cstdio>
#include <bitset>
#include <vector>
#include <deque>
#include <queue>
#include <stack>
#include <ctime>
#include <set>
#include <map>
#include <cmath>
using namespace std;
#define fr first
#define sc second
#define cl clear
#define BUG puts("here!!!")
#define W(a) while(a--)
#define pb(a) push_back(a)
#define Rint(a) scanf("%d", &a)
#define Rll(a) scanf("%I64d", &a)
#define Rs(a) scanf("%s", a)
#define Cin(a) cin >> a
#define FRead() freopen("in", "r", stdin)
#define FWrite() freopen("out", "w", stdout)
#define Rep(i, len) for(int i = 0; i < (len); i++)
#define For(i, a, len) for(int i = (a); i < (len); i++)
#define Cls(a) memset((a), 0, sizeof(a))
#define Clr(a, x) memset((a), (x), sizeof(a))
#define Full(a) memset((a), 0x7f7f7f, sizeof(a))
#define lrt rt << 1
#define rrt rt << 1 | 1
#define pi 3.14159265359
#define RT return
#define lowbit(x) x & (-x)
#define onenum(x) __builtin_popcount(x)
typedef long long LL;
typedef long double LD;
typedef unsigned long long ULL;
typedef pair<int, int> pii;
typedef pair<string, int> psi;
typedef pair<LL, LL> pll;
typedef map<string, int> msi;
typedef vector<int> vi;
typedef vector<LL> vl;
typedef vector<vl> vvl;
typedef vector<bool> vb; const int maxn = ;
const int maxm = ;
const LL mod = ;
typedef struct Bucket {
LL b[maxm];
}Bucket;
int n;
LL a[maxn];
bool _p[maxm];
LL prime[maxm];
int pcnt;
LL dp[maxn][maxn]; void init() {
Cls(_p); pcnt = ;
For(i, , maxm) {
if(_p[i] == ) {
prime[pcnt++] = i;
for(int j = i * ; j < maxm; j+=i) {
_p[j] = ;
}
}
}
} void gao(int i, LL x) {
for(int j = ; j < pcnt; j++) {
if(x % prime[j]) continue;
int cnt = ;
while(x % prime[j] == ) {
x /= prime[j];
cnt ^= ;
}
dp[i][j] = cnt;
}
} LL quickmul(LL x, LL n, LL mod) {
LL ret = ;
while(n) {
if(n & ) ret = (ret * x) % mod;
x = (x * x) % mod;
n >>= ;
}
return ret;
} int main() {
// FRead();
int T, _ = ;
Rint(T);
init();
W(T) {
Cls(dp);
printf("Case #%d:\n", _++);
Rint(n);
For(i, , n+) {
cin >> a[i];
gao(i, a[i]);
}
int p = ;
Rep(i, pcnt) {
For(j, p, pcnt) {
if(dp[j][i]) {
For(k, i, pcnt) {
swap(dp[j][k], dp[p][k]);
}
break;
}
}
if(!dp[p][i]) continue;
For(j, p+, pcnt) {
if(dp[j][i]) {
For(k, i, pcnt) {
dp[j][k] ^= dp[p][k];
}
}
}
p++;
}
cout << (quickmul(,n-p,mod)-+mod)%mod << endl;
}
RT ;
}
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <complex>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <cassert>
using namespace std;
int s[];
int main(){
int T,n;
int sum,ans,coco;
scanf("%d",&T);
int pp = ;
while(T--){
int maxn = ;
sum = ;
scanf("%d",&n);
for(int i=;i<n;i++){
scanf("%d",&s[i]);
sum +=s[i];
maxn = maxn < s[i] ? s[i] : maxn;
}
ans = sum/;
if(maxn > sum/){
coco = (sum - maxn) * + ;
ans = coco > ans ? ans : coco;
}
printf("Case #%d: %d\n",pp++,ans);
}
}
/*
━━━━━┒ギリギリ♂ eye!
┓┏┓┏┓┃キリキリ♂ mind!
┛┗┛┗┛┃\○/
┓┏┓┏┓┃ /
┛┗┛┗┛┃ノ)
┓┏┓┏┓┃
┛┗┛┗┛┃
┓┏┓┏┓┃
┛┗┛┗┛┃
┓┏┓┏┓┃
┛┗┛┗┛┃
┓┏┓┏┓┃
┃┃┃┃┃┃
┻┻┻┻┻┻
*/
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <climits>
#include <complex>
#include <cassert>
#include <cstdio>
#include <bitset>
#include <vector>
#include <deque>
#include <queue>
#include <stack>
#include <ctime>
#include <set>
#include <map>
#include <cmath>
using namespace std;
#define fr first
#define sc second
#define cl clear
#define BUG puts("here!!!")
#define W(a) while(a--)
#define pb(a) push_back(a)
#define Rint(a) scanf("%d", &a)
#define Rll(a) scanf("%I64d", &a)
#define Rs(a) scanf("%s", a)
#define Cin(a) cin >> a
#define FRead() freopen("in", "r", stdin)
#define FWrite() freopen("out", "w", stdout)
#define Rep(i, len) for(int i = 0; i < (len); i++)
#define For(i, a, len) for(int i = (a); i < (len); i++)
#define Cls(a) memset((a), 0, sizeof(a))
#define Clr(a, x) memset((a), (x), sizeof(a))
#define Full(a) memset((a), 0x7f7f7f, sizeof(a))
#define lrt rt << 1
#define rrt rt << 1 | 1
#define pi 3.14159265359
#define RT return
#define lowbit(x) x & (-x)
#define onenum(x) __builtin_popcount(x)
typedef long long LL;
typedef long double LD;
typedef unsigned long long ULL;
typedef pair<int, int> pii;
typedef pair<string, int> psi;
typedef pair<LL, LL> pll;
typedef map<string, int> msi;
typedef vector<int> vi;
typedef vector<LL> vl;
typedef vector<vl> vvl;
typedef vector<bool> vb; const int maxn = ;
char str[maxn];
int len;
int mod(int num) {
int ret = ;
Rep(i, len) {
ret = (int)(((LL)ret * + (str[i] - '')) % num);
}
return ret;
} int main() {
// FRead();
int _ = ;
while(Rs(str)!=EOF) {
printf("Case #%d: ", _++);
len = strlen(str);
int num = ;
if(len <= ) {
Rep(i, len) {
num *= ;
num += str[i] - '';
}
if(num == || num % == ) {
puts("YES");
continue;
}
if(num != || num % != ) {
puts("NO");
continue;
}
}
int t = mod();
if(t == ) puts("YES");
else puts("NO");
}
RT ;
}
/*
━━━━━┒ギリギリ♂ eye!
┓┏┓┏┓┃キリキリ♂ mind!
┛┗┛┗┛┃\○/
┓┏┓┏┓┃ /
┛┗┛┗┛┃ノ)
┓┏┓┏┓┃
┛┗┛┗┛┃
┓┏┓┏┓┃
┛┗┛┗┛┃
┓┏┓┏┓┃
┛┗┛┗┛┃
┓┏┓┏┓┃
┃┃┃┃┃┃
┻┻┻┻┻┻
*/
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <climits>
#include <complex>
#include <cassert>
#include <cstdio>
#include <bitset>
#include <vector>
#include <deque>
#include <queue>
#include <stack>
#include <ctime>
#include <set>
#include <map>
#include <cmath>
using namespace std;
#define fr first
#define sc second
#define cl clear
#define BUG puts("here!!!")
#define W(a) while(a--)
#define pb(a) push_back(a)
#define Rint(a) scanf("%d", &a)
#define Rll(a) scanf("%I64d", &a)
#define Rs(a) scanf("%s", a)
#define Cin(a) cin >> a
#define FRead() freopen("in", "r", stdin)
#define FWrite() freopen("out", "w", stdout)
#define Rep(i, len) for(int i = 0; i < (len); i++)
#define For(i, a, len) for(int i = (a); i < (len); i++)
#define Cls(a) memset((a), 0, sizeof(a))
#define Clr(a, x) memset((a), (x), sizeof(a))
#define Full(a) memset((a), 0x7f7f7f, sizeof(a))
#define lrt rt << 1
#define rrt rt << 1 | 1
#define pi 3.14159265359
#define RT return
#define lowbit(x) x & (-x)
#define onenum(x) __builtin_popcount(x)
typedef long long LL;
typedef long double LD;
typedef unsigned long long ULL;
typedef pair<int, int> pii;
typedef pair<string, int> psi;
typedef pair<LL, LL> pll;
typedef map<string, int> msi;
typedef vector<int> vi;
typedef vector<LL> vl;
typedef vector<vl> vvl;
typedef vector<bool> vb; const int maxn = ;
char str[maxn];
int ascii[];
int a[maxn];
int n, q;
int ord;
int dp[maxn];
int s[maxn]; int bs(int ll, int rr, int v) {
while(ll <= rr) {
int mm = (ll + rr) >> ;
if(s[mm] < v) ll = mm + ;
else rr = mm - ;
}
return ll;
} int main() {
// FRead();
int T, _ = ;
Rint(T);
W(T) {
ord = ; q = ;
Rs(str);
memset(ascii, -, sizeof(ascii));
memset(dp, , sizeof(dp));
memset(s, 0x7f7f7f7f, sizeof(s));
printf("Case #%d: ", _++);
n = strlen(str);
Rep(i, n) {
if(ascii[str[i]] == -) {
ascii[str[i]] = ord;
a[q++] = ord++;
}
else {
a[q++] = ascii[str[i]];
}
}
int ans = ;
For(i, , n+) {
dp[i] = bs(, i, a[i]);
s[dp[i]] = min(s[dp[i]], a[i]);
ans = max(ans, dp[i]);
}
printf("%d\n", ans);
}
RT ;
}