codeforces.com/contest/897/
来源:互联网 发布:最美的古诗词知乎 编辑:程序博客网 时间:2024/06/16 19:32
A
#include<stdio.h>int main(){ int n, m; char s[102]; while(scanf("%d%d%s", &n, &m, s) != EOF) { while(m--) { int l, r; char c1, c2; scanf("%d%d %c %c", &l, &r, &c1, &c2); for(int i = l; i <= r; ++i) { if(s[i - 1] == c1) { s[i - 1] = c2; } } } puts(s); } return 0;}
B
#include<stdio.h>const int MAXN = (int)1e5 + 5;int k, p, cnt, t;typedef long long ll;int mod_pow(int a, int n) { int res = 1; while(n) { if(n&1) res = 1LL * res * a % p; a = 1LL * a * a % p; n >>= 1; } return res;}int f(int j, int i) { return 1LL * mod_pow(10, i) * j % p;}int dfs(int i, int sum, bool fg) { if(cnt == k) return 0; if(i == t / 2) { ++cnt; return sum; } int res = 0; if(fg) res = dfs(i - 1, sum, true); for(int j = 1; j <= 9; ++j) { res += dfs(i - 1, ((sum + f(j, i - 1))%p + f(j, t - i)) % p, true); res %= p; } return res;}int work() { int res = 0; cnt = 0; for(int i = 2; cnt <= k; i += 2) { res += dfs(t = i, 0, false); res %= p; if(cnt == k) break; } return res;}int main(){ while(scanf("%d%d", &k, &p) != EOF) { int ans = work(); printf("%d\n", ans); } return 0;}
C
#include<stdio.h>#include<string.h>typedef long long ll;const char s0[] = "What are you doing at the end of the world? Are you busy? Will you save us?";const char s1[] = "What are you doing while sending \"";const char s2[] = "\"? Are you busy? Will you send \"";const char s3[] = "\"?";int l1, l2, l3, len, l0;void init() { l0 = strlen(s0); l1 = strlen(s1); l2 = strlen(s2); l3 = strlen(s3); len = l1 + l2 + l3;}ll a(int k) { if(k >= 55) return 5152117973711847356; return (1LL<<k) * (len + l0) - len;}ll f(int i, int k) { switch(i) { case 0: return 0; case 1: return l1; case 2: return f(i - 1, k) + a(k - 1); case 3: return f(i - 1, k) + l2; case 4: return f(i - 1, k) + a(k - 1); case 5: return f(i - 1, k) + l3; }}char slove(int n, ll k) { if(n == 0 && k <= l0) return s0[k - 1]; if(n == 0 && k > l0) return '.'; if(k <= f(1, n)) return s1[k - 1]; if(k <= f(2, n)) return slove(n - 1, k - f(1, n)); if(k <= f(3, n)) return s2[k - f(2, n) - 1]; if(k <= f(4, n)) return slove(n - 1, k - f(3, n)); if(k <= f(5, n)) return s3[k - f(4, n) - 1]; return '.';}int main(){ init(); /* for(int i = 0; i <= 60; ++i) { printf("# %d %lld\n", i, a(i)); }*/ int T; while(scanf("%d", &T) != EOF) { while(T--) { int n; ll k; scanf("%d%lld", &n, &k); printf("%c", slove(n, k)); } } return 0;}
阅读全文
0 0
- codeforces.com/contest/897/
- codeforces.com/contest/793
- codeforces.com/contest/805
- codeforces.com/contest/839/
- http://codeforces.com/contest/34
- http://codeforces.com/contest/34
- http://codeforces.com/contest/6/problem/A
- http://codeforces.com/contest/7/problem/B
- http://codeforces.com/contest/7/problem/A
- http://codeforces.com/contest/1/problem/A
- http://codeforces.com/contest/1/problem/B
- http://codeforces.com/contest/263/problem/D
- http://codeforces.com/contest/276/problem/C
- codeforces.com/contest/325/problem/B
- http://codeforces.com/contest/366/problem/D
- http://codeforces.com/contest/368/problem/D
- http://codeforces.com/contest/432/problem/D
- http://codeforces.com/contest/366/problem/C之01背包
- C++类 实例 数据成员 成员函数 构造函数 析构函数
- 一天一个设计模式之观察者模式
- 2017-12-05 Python第一日
- 1271技术流
- hypot
- codeforces.com/contest/897/
- 关于PE装载节区时候Virtual Size和Size Of Raw Data的关系猜想
- 不使用(a+b)/2这种方式,求两个数的平均值。
- 李宏毅机器学习2016 第一讲 回归案例分析
- ConcurrentHashMap实现原理及源码分析
- Python调用windows下DLL详解
- C++之实现MyString类
- android5.0之后用getConstantState()方法判断ImageView使用的是哪张图片
- viewpager+fragment页面切换,fragment用recylerview的坑