multiset<int>mst[(1<<5)+1]; multiset<int>::iterator it1,it2; int num[60020][10];
intmain(){ int n,m,od; while (~scanf("%d%d", &n, &m)){ for (int i = 0; i < (1<<5); i++) mst[i].clear(); for (int i = 1; i <= n; i++){ scanf("%d", &od); if (od == 0){ for (int j = 1; j <= m; j++) scanf("%d", &num[i][j]); for (int j = 0; j < (1 << m); j++){ int sum = 0; for (int k = 1; k <= m; k++){ if ((1<<(k-1)) & j) sum -= num[i][k]; else sum += num[i][k]; } mst[j].insert(sum); } }else { int x; scanf("%d", &x); for (int j = 0; j < (1 << m); j++){ int sum = 0; for (int k = 1; k <= m; k++){ if ((1<<(k-1)) & j) sum -= num[x][k]; else sum += num[x][k]; } it1 = mst[j].find(sum); mst[j].erase(it1); } } int ans = 0; for (int j = 0; j < (1 << m); j++){ it1 = mst[j].end(); it1--; it2 = mst[j].begin(); ans = max(ans,((*it1) - (*it2))); } printf("%dn", ans); }
ll solve(ll n,ll k){ ll sum = 0; if (n > k){ sum += k*(n-k); n = k; } int ndiv = k / n; int nnext,low,high; while (n > 1){ nnext = k / (ndiv + 1); if (n == nnext){ sum += k % n; n--; ndiv = k / n; continue; } low = k % n; high = k % (nnext + 1); sum += ((low + high) * (n - nnext)) >> 1; n = nnext; ndiv++; } return sum; }
intmain(){ int n,x; int Max = 0; scanf("%d", &n); for (int i = 0; i < n; i++){ scanf("%d", &x); s += x; Max = max(x,Max); } printf("%dn", max(1ll * Max,(s-1)/(n-1) + 1)); return0; }
intmain(){ ll a,b; while (cin >> a >> b){ if (!b || a <= 1) { printf("1n"); continue; } int bound = (ceil)(sqrt(a*1.0)); int cnt = 0; for (int i = 2; i < bound; i++){ if (a % i == 0){ pr[cnt] = i; pnum[cnt] = 0; while (a % i == 0){ a /= i; pnum[cnt] ++; } pnum[cnt++] *= b; } } if (a > 1) { pr[cnt] = a; pnum[cnt++] = b; } ll ans = 1; for (int i = 0; i < cnt; i++){ ll tmp = 1 + solve(pr[i],pnum[i]); ans = ans * tmp % mod;
ll dfs(int pos,int bal,int prenum,bool islim){ if (prenum < 0) return0;//从后向前枚举的所以不能小于0 if (pos == -1) return prenum == 0; if (!islim && dp[pos][bal][prenum] != -1){ return dp[pos][bal][prenum]; } int end = islim ? dig[pos] : 9; ll ans = 0; for (int i = 0; i <= end; i++){ ans += dfs(pos-1,bal,prenum+(pos-bal)*i,islim && i == end); } if (!islim) dp[pos][bal][prenum] = ans; return ans;
}
ll cal(ll n){ int num = 0; while (n){ dig[num++] = n % 10; n /= 10; } ll ret = 0; for (int i = 0; i < num; i++) ret += dfs(num-1,i,0,1); return ret-num+1;//因为0的支点可以整个数的数位减去重复的 //比如00000支点任意一个都可以 }
intmain(){ int t; init(); ll l,r;
for (scanf("%d", &t); t--;){ cin >> l >> r; cout << cal(r) - cal(l-1) << endl; } return0; }