S+6-字符串
A. 文本校对
暴力HASH就好了1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495const int N = 1e6 + 5, base = 19260817, mod = 998244353;int n, m, h[N], pw[N], inv[N], now[N];string s;ll qpow(int x, int y){ ll res = 0; while (y) { if (y & 1) res = res * x % mod; x = x * x % mod; y >>= 1; } return res;}voi ...
S+4-数据结构2
A. 青蛙跳
根号分治去解决12345678910111213141516171819202122232425#define M 100005using namespace std;int A[M],sum[340][M];int main(){ int n,m; scanf("%d %d",&n,&m); for(int i=1;i<=n;i++)scanf("%d",&A[i]); int S=sqrt(n); for(int i=n;i>=1;i--) for(int j=1;j<=S;j++) sum[j][i]=sum[j][i+j]+A[i]; for(int i=1;i<=m;i++){ int a,b; scanf("%d %d",&a,&b); if(b<=S){ printf("%d\n",sum[b][a]); }else{ int r ...
S+3-数据结构1
A. 约瑟夫问题
还是很简单的,用链表直接维护就好了1234567891011121314151617181920212223242526272829303132signed main() { IOS; int n, m; cin >> n >> m; vector<int> P(n + 1), RE(n + 1); P[0] = 1; for (int i = 1; i <= n; i++) { P[i] = i + 1; RE[i] = i - 1; if (i == 1) { RE[i] = n; } if (i == n) { P[i] = 1; } } int idx = 0; for (int i = 1; i <= n; ...
TEST 7
A. 老C的输入法
模拟一下就好了12345678910111213141516171819202122232425#define int long longstring s,x[1009];int n,ans;string solve(string s){ string str=""; for(auto i:s){ if(i>='a'&&i<='c')str+="2"; else if(i>='d'&&i<='f')str+="3"; else if(i>='g'&&i<='i')str+="4"; else if(i>='j'&&i<='l')str ...
S+ 期望与概率
A. 骰子游戏123456789101112131415161718192021222324252627282930313233343536373839404142434445464748const int N = 2e3 + 10;const double eps = 1e-9;double p, q, f[N][N];double g(int n, int m){ if (f[n][m] != -1) return f[n][m]; if (!n) return f[n][m] = 0; if (!m) return f[n][m] = 1; //a赢 f[n][m] = 0; if (p > eps) f[n][m] += p * g(n, m - 1); if (q > eps) f[n][m] += q * g(n - 1, m); return f[n][m];}void solve(){ int n, m; cin >> n >> m; / ...
TEST 6
A. 比赛时间
easy12345678int d,h,m;int main(){ scanf("%d%d%d",&d,&h,&m); d=((d-11)*24+h-11)*60+m-11; if(d<0)printf("-1"); else printf("%d",d);}
B. 可怕和弦
只要写个check函数就很好解决12345678910111213141516171819202122232425262728293031323334353637383940414243444546int sc[15],n,c;int a[20005];int vis[89];int cd[15];int ans[20005],num;bool check(int x){ for(int i=1;i<=c;i++) { cd[i]=a[i+x-1]; } sort(cd+1,cd+c+1); ...
TEST 5
A 喝饮料
看似很麻烦,但只有一步123456789101112131415int n, x, y, k, ans;signed main() { IOS; cin >> n >> x >> y; k = n / x; ans += n / x; while (k >= y) { ans += k / y; k = k % y + k / y; } if (k + 1 == y) ans++; cout << ans << endl; return 0;}
B. 非零位
只要取一个大小差不多的十的倍数就好了12345678910111213141516const ll mod = 100000;signed main() { IOS; ll n, ans = 1; cin >> n; for (ll i = 1; i <= n; i++) ...
TEST 4
A 长方体12345678signed main() { IOS; int a, b, c; cin >> a >> b >> c; int d = sqrt(a * b * c); cout << 4 * (d / a + d / b + d / c) << endl; return 0;}
B 数括号1234567891011121314151617181920212223string s;int l[50005], ans;signed main() { IOS; cin >> s; s = ' ' + s; for (int i = 2; i < s.size(); i++) { l[i] = l[i - 1]; if (s[i] == '(' && s[i - 1] == '(') { ...
TEST 3
A. 不要落后
按照规则找就好了1234567891011121314151617181920212223242526272829303132333435363738map<string, int> q;set<int> g;signed main() { IOS; int n; cin >> n; for (int i = 1; i <= n; i++) { string s; int x; cin >> s >> x; q[s] += x; } for (auto x : q) { int y = x.second; g.insert(y); } if (g.size() == 1) { if (q.size() == 1) { for (auto x : q) { ...
TEST 2
A. 调饮料师
直接暴力就好了1234567891011121314151617signed main() { IOS; int c[3], s[3]; for (int i = 0; i < 3; i++) { cin >> c[i] >> s[i]; } for (int i = 0; i < 100; i++) { int idx = i % 3; int tmp = min(c[(idx + 1) % 3] - s[(idx + 1) % 3], s[idx]); s[idx] -= tmp; s[(idx + 1) % 3] += tmp; } for (int i = 0; i < 3; i++) { cout << s[i] << endl; } return 0;}
B. 心直口筷 ...