南京邀请赛重现
来源:互联网 发布:怎么登陆淘宝店客服 编辑:程序博客网 时间:2024/04/29 23:31
只做了四道水题
A
ans = (m/n)ans + avg
注意m == n 和 avg == 0.0的情况
#include <set>#include <cmath>#include <queue>#include <stack>#include <string>#include <cstdio>#include <cstring>#include <algorithm>using namespace std;typedef long long LL;const double PI = acos(-1.0);template <class T> inline T MAX(T a, T b){if (a > b) return a;return b;}template <class T> inline T MIN(T a, T b){if (a < b) return a;return b;}const int N = 111;const int M = 11111;const LL MOD = 1000000007LL;const int dir[4][2] = {1, 0, -1, 0, 0, -1, 0, 1};const int INF = 0x3f3f3f3f;int a[222];int main(){ int n, m; while (scanf("%d", &n) != EOF) { int i, j , k, sum = 0; double ans; for (i = 0; i < n; ++i) { scanf("%d", &a[i]); sum += a[i]; } scanf("%d", &m); for (i = 0; i < m; ++i) scanf("%d", &k); if (sum == 0) { printf("0.00\n"); } else if (n == m) { printf("inf\n"); } else { ans = sum; ans = ans / (n - m); printf("%.2lf\n", ans); } } return 0;}
C 统计进位,只要预处理1-100000000的前缀和中每个位有多少个一,然后每次询问b-(a-1)再统计即可
#include <set>#include <cmath>#include <queue>#include <stack>#include <string>#include <cstdio>#include <cstring>#include <algorithm>using namespace std;typedef long long LL;const double PI = acos(-1.0);template <class T> inline T MAX(T a, T b){if (a > b) return a;return b;}template <class T> inline T MIN(T a, T b){if (a < b) return a;return b;}const int N = 111;const int M = 11111;const LL MOD = 1000000007LL;const int dir[4][2] = {1, 0, -1, 0, 0, -1, 0, 1};const int INF = 0x3f3f3f3f;void solve(LL cnt[], LL num){ LL i, j, k, bas = 1, lim = 0; for (i = 0; i <= 64; ++i) { if (num <= lim) break; cnt[i] = (num - lim) / (bas * 2) * bas; if ((num - lim) % (bas * 2) >= bas) cnt[i] = cnt[i] + bas; else cnt[i] = cnt[i] + ((num-lim) %(bas * 2)); bas *= 2; lim = bas - 1; }}LL c1[100], c2[100];int main(){ LL a, b; while (scanf("%I64d%I64d", &a, &b) != EOF) { memset(c1, 0, sizeof(c1));memset(c2, 0, sizeof(c2)); solve(c1, a - 1); solve(c2, b); LL tot = 0, ans = 0;// for (int i = 0; i <= 10; ++i)// printf("%d ", c1[i]);// printf("\n");// for (int i = 0; i <= 10; ++i)// printf("%d ", c2[i]);// printf("\n"); for (int i = 0; i <= 64; ++i) c2[i] = c2[i] - c1[i]; for (int i = 0; i <= 64; ++i) { ans = ans + c2[i] / 2; c2[i + 1] += c2[i] / 2; } printf("%I64d\n", ans); } return 0;}
H 统计哪个数字重复
#include <set>#include <cmath>#include <queue>#include <stack>#include <string>#include <cstdio>#include <cstring>#include <algorithm>using namespace std;typedef long long LL;const double PI = acos(-1.0);template <class T> inline T MAX(T a, T b){if (a > b) return a;return b;}template <class T> inline T MIN(T a, T b){if (a < b) return a;return b;}const int N = 111;const int M = 11111;const LL MOD = 1000000007LL;const int dir[4][2] = {1, 0, -1, 0, 0, -1, 0, 1};const int INF = 0x3f3f3f3f;int a[1111];int main(){ int n; while (scanf("%d", &n) != EOF) { int i, x, t; memset(a, 0, sizeof(a)); for (i = 0; i <= n; ++i) { scanf("%d", &x); if (a[x]) t = x; a[x]++; } printf("%d\n", t); } return 0;}
K
枚举两个区间的X的gcd的倍数在不在 两个区间只差的区间内,【Z[j]-Y[i],Y[j] - Z[i]】
#include <set>#include <cmath>#include <queue>#include <stack>#include <string>#include <cstdio>#include <cstring>#include <algorithm>using namespace std;typedef long long LL;const double PI = acos(-1.0);template <class T> inline T MAX(T a, T b){if (a > b) return a;return b;}template <class T> inline T MIN(T a, T b){if (a < b) return a;return b;}const int N = 111;const int M = 11111;const LL MOD = 1000000007LL;const int dir[4][2] = {1, 0, -1, 0, 0, -1, 0, 1};const int INF = 0x3f3f3f3f;int X[1111], Y[1111], Z[1111];inline int gcd(int a, int b){ if (!b) return a; return gcd(b, a % b);}bool check(int i, int j){ if (Z[i] < Y[j] || Y[i] > Z[j]) { int k; int d = gcd(X[i], X[j]); if (Z[i] > Z[j]) {k = i; i = j; j = k;} int l, r; l = Y[j] - Z[i]; r = Z[j] - Y[i];// printf("%d %d %d\n", d, l, r); if (l % d == 0 || r % d == 0) return true; else return l / d != r / d; } return true;}int main(){ int n; while (scanf("%d", &n) != EOF) { int i, j, k; for (i = 0; i < n; ++i) scanf("%d%d%d", &X[i], &Y[i], &Z[i]); bool flag = true; for (i = 0; i < n; ++i) for (j = i + 1; j < n; ++j) { if (check(i, j)) { flag = false; break; } } if (flag) printf("Can Take off\n"); else printf("Cannot Take off\n"); } return 0;}
- 南京邀请赛重现
- 2013 ACM-ICPC南京赛区全国邀请赛——题目重现
- HDU_2013 ACM-ICPC南京赛区全国邀请赛——题目重现
- 2013 成都邀请赛重现
- 2013 南京邀请赛 总结
- 南京邀请赛f
- 8#17 - 南京邀请赛
- 8#10 - 杭州邀请赛 重现
- 省赛 和 南京邀请赛总结
- HDUOJ 4576 2013杭州邀请赛重现 Robot
- HDUOJ 4578 2013杭州邀请赛重现 Transformation
- HDUOJ 4496 通化邀请赛重现 D-City
- 2017ACM/ICPC广西邀请赛-重现赛
- 2017ACM/ICPC广西邀请赛-重现赛
- A Math Problem (广西邀请赛-重现赛)
- 2017ACM/ICPC广西邀请赛-重现赛
- ICPC2013南京邀请赛 E. Eloh 解题报告
- 2013 南京邀请赛 C - Count The Carries
- Android调用WebService(Android+ksoap)
- Struts2返回JSON数据的具体应用范例
- 2013年8月17日、二维数组定义的格式|用java表现一个描述小汽车|基本数据类型参数传递|
- GDB调试手册
- 转载 --HTTP协议 (三) 压缩
- 南京邀请赛重现
- 浅谈:JavaScript名字由来
- (转) KMP算法和状态机的联系
- struts2 由标签param从JSP页面传中文参数过来后出现乱码
- android移植之android源码下载
- ios中常用的数学函数
- 转载--HTTP协议 (四) 缓存
- how to use MEF do DI(DEPENDENCY INJECTION )
- 转载--HTTP协议 (五) 代理