[51NOD]BSG白山极客挑战赛

时间:2022-12-18 20:52:52

比赛链接:http://www.51nod.com/contest/problemList.html#!contestId=21

 /*
━━━━━┒ギリギリ♂ eye!
┓┏┓┏┓┃キリキリ♂ mind!
┛┗┛┗┛┃\○/
┓┏┓┏┓┃ /
┛┗┛┗┛┃ノ)
┓┏┓┏┓┃
┛┗┛┗┛┃
┓┏┓┏┓┃
┛┗┛┗┛┃
┓┏┓┏┓┃
┛┗┛┗┛┃
┓┏┓┏┓┃
┃┃┃┃┃┃
┻┻┻┻┻┻
*/
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <climits>
#include <complex>
#include <fstream>
#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("%lld", &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), 0x7f7f, sizeof(a))
#define lrt rt << 1
#define rrt rt << 1 | 1
#define pi 3.14159265359
#define RT return
typedef long long LL;
typedef long double LD;
typedef unsigned long long ULL;
typedef pair<int, int> pii;
typedef pair<string, int> psi;
typedef map<string, int> msi;
typedef vector<LL> vl;
typedef vector<vl> vvl;
typedef vector<bool> vb; LL p[];
int a,b,d,n; int main() {
// FRead();
int T;
Rint(T);
W(T) {
Cls(p);
Rint(a); Rint(b); Rint(d); Rint(n);
if(n==) {
if(a*b >= ) p[(a*b)/]++;
p[(a*b)%]++;
cout << p[d] << endl;
}
else {
int k = a*b;
int t = k / ;
int x = k % ;
int y = (x + t) / ;
int g = (x +t) % ;
int j = (x + y + t) % ;
p[j] += n-;
p[g] += ;
p[x] += ;
if(k >= ) p[y+t] += ;
cout << p[d] << endl;
}
}
RT ;
}

A

 /*
━━━━━┒ギリギリ♂ eye!
┓┏┓┏┓┃キリキリ♂ mind!
┛┗┛┗┛┃\○/
┓┏┓┏┓┃ /
┛┗┛┗┛┃ノ)
┓┏┓┏┓┃
┛┗┛┗┛┃
┓┏┓┏┓┃
┛┗┛┗┛┃
┓┏┓┏┓┃
┛┗┛┗┛┃
┓┏┓┏┓┃
┃┃┃┃┃┃
┻┻┻┻┻┻
*/
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <climits>
#include <complex>
#include <fstream>
#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("%lld", &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), 0x7f7f, sizeof(a))
#define lrt rt << 1
#define rrt rt << 1 | 1
#define pi 3.14159265359
#define RT return
typedef long long LL;
typedef long double LD;
typedef unsigned long long ULL;
typedef pair<int, int> pii;
typedef pair<string, int> psi;
typedef map<string, int> msi;
typedef vector<LL> vl;
typedef vector<vl> vvl;
typedef vector<bool> vb; const int maxn = ;
const int mod = ;
LL dp[maxn][maxn];
LL ans;
int n; int main() {
// FRead();
while(~Rint(n)) {
Cls(dp);
dp[][] = dp[][] = ; dp[][] = ;
For(i, , n+) {
Rep(j, i) {
For(k, , ) {
dp[i][k] += (dp[j][k-] * dp[i-j-][k-]) % mod;
if(dp[i][k] >= mod) dp[i][k] %= mod;
if(k >= ) {
dp[i][k] += (dp[j][k-] * dp[i-j-][k-]) % mod;
if(dp[i][k] >= mod) dp[i][k] %= mod;
}
dp[i][k] += (dp[j][k-] * dp[i-j-][k-]) % mod;
if(dp[i][k] >= mod) dp[i][k] %= mod;
}
}
}
ans = ;
Rep(i, ) {
ans += dp[n][i];
ans %= mod;
}
cout << ans << endl;
}
RT ;
}

B

 /*
━━━━━┒ギリギリ♂ eye!
┓┏┓┏┓┃キリキリ♂ mind!
┛┗┛┗┛┃\○/
┓┏┓┏┓┃ /
┛┗┛┗┛┃ノ)
┓┏┓┏┓┃
┛┗┛┗┛┃
┓┏┓┏┓┃
┛┗┛┗┛┃
┓┏┓┏┓┃
┛┗┛┗┛┃
┓┏┓┏┓┃
┃┃┃┃┃┃
┻┻┻┻┻┻
*/
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <climits>
#include <complex>
#include <fstream>
#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("%lld", &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), 0x7f7f, sizeof(a))
#define lrt rt << 1
#define rrt rt << 1 | 1
#define pi 3.14159265359
#define RT return
typedef long long LL;
typedef long double LD;
typedef unsigned long long ULL;
typedef pair<int, int> pii;
typedef pair<string, int> psi;
typedef map<string, int> msi;
typedef vector<LL> vl;
typedef vector<vl> vvl;
typedef vector<bool> vb; // const int maxn = ;
int n; int main() {
// FRead();
double r, R, s, v;
cin >> s; r = sqrt(s / pi) / ;
R = s / (pi * r) - r;
v = pi * r * r * sqrt(R * R - r * r) / ;
printf("%.6lf\n", v);; RT ; }

C

 /*
━━━━━┒ギリギリ♂ eye!
┓┏┓┏┓┃キリキリ♂ mind!
┛┗┛┗┛┃\○/
┓┏┓┏┓┃ /
┛┗┛┗┛┃ノ)
┓┏┓┏┓┃
┛┗┛┗┛┃
┓┏┓┏┓┃
┛┗┛┗┛┃
┓┏┓┏┓┃
┛┗┛┗┛┃
┓┏┓┏┓┃
┃┃┃┃┃┃
┻┻┻┻┻┻
*/
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <climits>
#include <complex>
#include <fstream>
#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("%lld", &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), 0x7f7f, sizeof(a))
#define lp p << 1
#define rp p << 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 map<string, int> msi;
typedef vector<int> vi;
typedef vector<LL> vl;
typedef vector<vl> vvl;
typedef vector<bool> vb; const int maxn = ;
int n;
LL k;
int bit[maxn<<][];
int t[maxn], dp[maxn]; void add(int i, int x, int j) {
while(i <= maxn) {
bit[i][j] += x;
i += lowbit(i);
}
} int sum(int i, int j) {
int s = ;
while(i) {
s += bit[i][j];
i -= lowbit(i);
}
return s;
} bool ok(int x) {
Cls(dp); Cls(bit);
Rep(i, n+) {
if(t[i] >= x) dp[i] = dp[i-] + ;
else dp[i] = dp[i-];
}
Rep(i, n+) dp[i] = * dp[i] - i + ;
LL ret = ;
Rep(i, n+) {
ret += sum(dp[i]-, !(i&));
add(dp[i], , i&);
}
if(ret >= k) return ;
return ;
} int main() {
// FRead();
while(~Rint(n) && ~Rll(k)) {
int l = , r = ;
For(i, , n+) {
Rint(t[i]);
r = max(r, t[i]);
}
while(l <= r) {
int m = (l + r) >> ;
if(ok(m)) l = m + ;
else r = m - ;
}
printf("%d\n", r);
}
RT ;
}

E

E题:

二分中位数x,dp(i)维护[1,i]区间内大于等于x的数量。注意到长为奇数的区间[l,r],l和r奇偶一定不同,这一点非常重要。

如果区间[l,r]内的中位数大于等于x的话,那么(dp(r)-dp(l))*2>r-l+1,即2*dp[r]-r>2*dp(l)-l+1。

更新dp,使dp(i)-2*dp(i)-i,统计有多少个dp(j)<dp(i) j<i 且i,j奇偶不同。

有一个问题,就是2*dp[i]-i<0,解决方法就是加一个数,并且不至于让dp[i]计算后溢出的数。