SDKD Summer Team Contest E
2015-08-04 20:11
369 查看
I:点击打开链接
D:点击打开链接
这个题给自己涨了点姿势, 枚举前缀和, 然后这个数学公式也是推得很好呀,自己脑子真是太笨了。。。
#include<iostream> #include<cstdio> #include<cstring> #include<algorithm> #include<cmath> using namespace std; int main() { double dis = 0; int T; cin >>T; while(T--) { int n; cin >> n; double t1, x1, y1; double t, x, y; dis = 0; for(int i = 0; i < n; ++i) { if(i==0) { cin >> t1 >> x1 >> y1; } else { cin >> t >> x >> y; dis = max(dis, sqrt((x-x1) * (x-x1) + (y-y1) * (y-y1)) * 1.0/ (1.0 *(t-t1))); t1 = t, x1 = x, y1 = y; } } printf("%.10lf\n", dis); } return 0; }
D:点击打开链接
这个题给自己涨了点姿势, 枚举前缀和, 然后这个数学公式也是推得很好呀,自己脑子真是太笨了。。。
#include<cstdio> #include<iostream> #include<cstring> #include<algorithm> #include<cmath> using namespace std; const int maxn = 50000 + 5; double a[maxn]; double sum1[maxn]; double sum2[maxn]; int main() { int T; cin >>T; while(T--) { memset(a,0,sizeof(a)); memset(sum1,0,sizeof(sum1)); memset(sum2,0,sizeof(sum2)); int n, k; cin >> n >> k; for(int i = 1; i <= n; ++i) scanf("%lf", &a[i]); if(n==k) { printf("%.9lf\n", 0); continue; } sort(a+1,a+n+1); for(int i = 1; i <= n; ++i) { sum1[i] = sum1[i-1] + a[i]; sum2[i] = sum2[i-1] + a[i] * a[i]; } double res = 1e20; //cout << res << endl; for(int i = 1; i <= k+1; ++i) { double x1 = sum2[i+n-k-1] - sum2[i-1]; double x2 = sum1[i+n-k-1] - sum1[i-1]; double tmp = x1 - x2*x2/(n-k); res = min(res, tmp); } printf("%.9lf\n", res); } return 0; }
相关文章推荐
- js 原型链 __proto__ prototype
- ios 二维码
- C 语言:返回两个数组中第一个相同元素的指针(我用了loop 、goto loop标签)
- 日常J2EE开发中遇到的问题积累
- HDU 5344 MZL's xor
- Unreal Engine 4 遍历文件夹读文件
- firefox ie chrome 设置单元格宽度 td width 有bug,不能正常工作。以下方式可以解决
- WAMPServer2.5中升级PHP/Apache
- HDU 5349
- 我的C语言入门到精通之路 day06
- SDKD Summer Team Contest D
- DRW入门之异常:java.lang.ClassNotFoundException: org.directwebremoting.servlet.DwrServlet.class
- javascript数值范围
- JavaScript 之 document对象
- 关于json反序列化字符串为java对象时科学计数法和精度问题
- hdu 5349 MZL's simple problem (set)
- 文件的上传下载
- css之display:inline-block与float区别(可以尝试用一下)
- Java大数加法 HDU1002 HDU1250
- Android中加载网络图片到本地