没有AK真是sad。。。
int x; bool use[10]; bool check(int y){ RST(use); while(y){ if(use[y%10]) return false; use[y %10] = 1; y /= 10; } return true; } void solve(){ x++; while(!check(x)) x++; OT(x); } int main(){ while(cin >>x) solve(); }
const int N = 1000; int a[N][N]; SI hash; SI :: iterator iter; int n , m; void solve(){ REP_2(i , j , n , m) { RD(a[i][j]); iter = hash.lower_bound(a[i][j]); a[i][j] = *iter - a[i][j]; } int ans = INF; REP(i , n){ int now = 0; REP(j , m) now += a[i][j]; checkMin(ans , now); } REP(i , m){ int now = 0; REP(j , n) now += a[j][i]; checkMin(ans , now); } OT(ans); } int main(){ getPrime(); hash.clear(); REP_1(i , prime[0]){ hash.insert(prime[i]); } while(cin >> n >>m) solve(); }
const int N = 1e6 + 9; int a[N] , n , k; void solve(){ if (k * 3 > n){ puts("-1"); return; } RST(a); int head = 0; REP_1(i , k){ a[head++] = i; } REP_1(i , k){ int now = i + 1; if (now == k + 1) now = 1; a[head++] = now; } REP_1(i , k - 1){ a[head++] = i; } REP(i , n){ if (i) printf(" "); if (a[i] == 0) printf("%d", k); else printf("%d" , a[i]); } puts(""); } int main(){ while(cin >> n >> k) solve(); }
string str , v; int k; set<ULL> hash; int main(){ cin >> str >> v >> k; hash.clear(); int len = str.length(); REP_C(i , len){ int bad = 0; ULL now = 0; FOR(j , i , len){ bad += v[str[j] - 'a'] == '0'; if (bad > k) break; now = now * 27 + str[j]; hash.insert(now); } } OT(SZ(hash)); }刚看到了能卡掉字典序hash的blog,Mark:http://hi.baidu.com/sillycross/item/386b1e172389391fb98a1ab1
eoyirpkwgpvvwzaaaaaaaaaaaaaa 11111111111111111111111111 1
VI divs; int n , m; int main(){ RD(n , m); int d = 0; DO(n) d = GCD(RD() - 1 , d); for(int i = 1 ; i * i <= d ; ++i){ if (d % i == 0){ divs.PB(i); if (i * i != d) divs.PB(d / i); } } LL ans = 0; ECH(it , divs) if ((*it) & 1) for(int i = 0 ; ((LL)(*it) << i) < m ; ++i) ans += m - ((LL)(*it) << i); OT(ans); }