HDU 5879 Cure(数学)
2016-09-19 18:21
429 查看
吐槽一下,这道题真的是有毒,首先注意n很大,大约1000000位,因为输入文件为1M,然后就是字符串有可能有前导0,因此需要特判,网络赛真的是写出内伤。
#include <cmath> #include <vector> #include <cstdio> #include <cstring> #include <iostream> #include <algorithm> using namespace std; typedef long long LL; const double PI = acos(-1); const double xxx = PI*PI/6.0; double a[3000000]; char s[1000000]; int init(){ memset(a, 0, sizeof(a)); a[1] = 1.0; int i; for(i = 2; ; i++){ a[i] = a[i-1]+1.0/(1.0*i*i); if(abs(a[i] - xxx) < 1e-6) break; } return i; } int change(char *s){ int sum = 0; for(int i = 0; i < strlen(s); i++){ sum = sum*10 + s[i]-'0'; } return sum; } int judge(char *s){ int cnt = 0; for(int i = 0; i < strlen(s); i++) if(s[i] == '0') cnt++; return strlen(s) - cnt; } int main(){ int k = init(); while(scanf("%s", s) != EOF){ if(s[0] == '-') continue; int len = judge(s); if(len == 0) continue; if(len < 6) printf("%.5lf\n", a[change(s)]); else printf("%.5lf\n", xxx); } return 0; }
相关文章推荐
- [HDU 5879] Cure (数学+打表)
- HDU 5879 Cure (数学)
- HDU 5879 Cure
- HDU 5879-Cure(1/n^2之和)
- HDU 5879 - Cure【2016 ACM 区域赛青岛赛区网络赛】
- hdu 5879 Cure -ICPC网络赛青岛赛区
- 【HDU 5879】Cure(暴力+优化)
- HDU 5879 Cure
- HDU 5879---cure
- hdu 5879 -Cure 暴力打表
- HDU 5879 Cure(打表预处理)
- hdu 5879 Cure 2016ACM/ICPC青岛赛区网络赛1002
- HDU 5879 Cure .
- HDU 5879 Cure【数论】
- HDU-5879 Cure(精度)(极限)
- hdu 5879 Cure 打表
- hdu_5879_Cure(打表)
- HDU 5879 Cure 2016 ACM/ICPC Asia Regional Qingdao Online 1002
- hdu 5879 Cure
- HDU 5879 Cure -2016 ICPC 青岛赛区网络赛