您的位置:首页 > 其它

BZOJ2134 单选错位

2014-11-17 13:09 344 查看
= =是道沙茶题,直接模拟即可。。。

/**************************************************************
Problem: 2134
User: rausen
Language: C++
Result: Accepted
Time:1292 ms
Memory:78932 kb
****************************************************************/

#include <cstdio>
#include <cmath>

using namespace std;
typedef double lf;
typedef long long ll;
const int N = 10000005;
const ll Mod = 100000001;
ll n, a, b, c, d
;

inline int read() {
int x = 0;
char ch = getchar();
while (ch < '0' || '9' < ch)
ch = getchar();
while ('0' <= ch && ch <= '9') {
x = x * 10 + ch - '0';
ch = getchar();
}
return x;
}

int main() {
int i;
n = read(), a = read(), b = read(), c = read();
for (d[1] = read(), i = 2; i <= n; ++i)
d[i] = (d[i - 1] * a + b) % Mod;
for (i = 1; i <= n; ++i)
d[i] = (d[i] % c) + 1;
d[n + 1] = d[1];
lf ans = 0;
for (i = 1; i <= n; ++i)
if (d[i] <= d[i + 1])
ans += (lf) 1.0 / d[i + 1];
else
ans += (lf) 1.0 / d[i];
printf("%.3lf", ans);
return 0;
}


View Code
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: