結果
| 問題 |
No.1180 無限和
|
| コンテスト | |
| ユーザー |
LayCurse
|
| 提出日時 | 2020-08-21 22:35:07 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 4,003 bytes |
| コンパイル時間 | 2,643 ms |
| コンパイル使用メモリ | 211,580 KB |
| 最終ジャッジ日時 | 2025-01-13 06:18:17 |
|
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | WA * 40 |
ソースコード
#pragma GCC optimize ("Ofast")
#include<bits/stdc++.h>
using namespace std;
int next_mcomb(int len, int arr[], int lim){
int i;
for(i=(len)-1;i>=(0);i--){
if(arr[i]+1 < lim){
arr[i]++;
i++;
while(i < len){
arr[i] = arr[i-1];
i++;
}
return 1;
}
arr[i] = 0;
}
for(i=(0);i<(len);i++){
arr[i] = 0;
}
return 0;
}
inline int my_getchar_unlocked(){
static char buf[1048576];
static int s = 1048576;
static int e = 1048576;
if(s == e && e == 1048576){
e = fread_unlocked(buf, 1, 1048576, stdin);
s = 0;
}
if(s == e){
return EOF;
}
return buf[s++];
}
inline void rd(int &x){
int k;
int m=0;
x=0;
for(;;){
k = my_getchar_unlocked();
if(k=='-'){
m=1;
break;
}
if('0'<=k&&k<='9'){
x=k-'0';
break;
}
}
for(;;){
k = my_getchar_unlocked();
if(k<'0'||k>'9'){
break;
}
x=x*10+k-'0';
}
if(m){
x=-x;
}
}
struct MY_WRITER{
char buf[1048576];
int s;
int e;
MY_WRITER(){
s = 0;
e = 1048576;
}
~MY_WRITER(){
if(s){
fwrite_unlocked(buf, 1, s, stdout);
}
}
}
;
MY_WRITER MY_WRITER_VAR;
void my_putchar_unlocked(int a){
if(MY_WRITER_VAR.s == MY_WRITER_VAR.e){
fwrite_unlocked(MY_WRITER_VAR.buf, 1, MY_WRITER_VAR.s, stdout);
MY_WRITER_VAR.s = 0;
}
MY_WRITER_VAR.buf[MY_WRITER_VAR.s++] = a;
}
inline void wt_L(char a){
my_putchar_unlocked(a);
}
inline void wt_L(int x){
int s=0;
int m=0;
char f[10];
if(x<0){
m=1;
x=-x;
}
while(x){
f[s++]=x%10;
x/=10;
}
if(!s){
f[s++]=0;
}
if(m){
my_putchar_unlocked('-');
}
while(s--){
my_putchar_unlocked(f[s]+'0');
}
}
int WRITER_DOUBLE_DIGIT = 15;
inline int writerDigit_double(){
return WRITER_DOUBLE_DIGIT;
}
inline void writerDigit_double(int d){
WRITER_DOUBLE_DIGIT = d;
}
inline void wt_L(double x){
const int d = WRITER_DOUBLE_DIGIT;
int k;
int r;
double v;
if(x!=x || (x==x+1 && x==2*x)){
my_putchar_unlocked('E');
my_putchar_unlocked('r');
my_putchar_unlocked('r');
return;
}
if(x < 0){
my_putchar_unlocked('-');
x = -x;
}
x += 0.5 * pow(0.1, d);
r = 0;
v = 1;
while(x >= 10*v){
v *= 10;
r++;
}
while(r >= 0){
r--;
k = floor(x / v);
if(k >= 10){
k = 9;
}
if(k <= -1){
k = 0;
}
x -= k * v;
v *= 0.1;
my_putchar_unlocked(k + '0');
}
if(d > 0){
my_putchar_unlocked('.');
v = 1;
for(r=(0);r<(d);r++){
v *= 0.1;
k = floor(x / v);
if(k >= 10){
k = 9;
}
if(k <= -1){
k = 0;
}
x -= k * v;
my_putchar_unlocked(k + '0');
}
}
}
template<class T> inline T pow2_L(T a){
return a*a;
}
int N;
int ind[50];
double a2[50];
int main(){
int m;
double res;
double A;
double B;
rd(N);
if(N<=2){
wt_L(1);
wt_L('\n');
}
else{
wt_L(0);
wt_L('\n');
}
return 0;
for(m=(1);m<(1000);m++){
res = 0;
int Q5VJL1cS;
for(Q5VJL1cS=(0);Q5VJL1cS<(N);Q5VJL1cS++){
ind[Q5VJL1cS] = 0;
}
do{
{
int i;
for(i=(0);i<(N);i++){
a2[i] =(pow2_L((ind[i] + 1)));
}
A = 1;
for(i=(0);i<(N);i++){
A *= a2[i];
}
B = 0;
for(i=(0);i<(N);i++){
B += A / a2[i];
}
res += 1 / B / a2[0];
}
}
while(next_mcomb(N,ind,m));
wt_L(m);
wt_L(' ');
wt_L(res);
wt_L('\n');
}
return 0;
}
// cLay varsion 20200813-1 [beta]
// --- original code ---
// int N;
// int ind[50];
// double a2[50];
// {
// double res, A, B;
// rd(N);
// wt(if[N<=2, 1, 0]);
// return 0;
// rep(m,1,1000){
// res = 0;
// rep_mcomb(ind,N,m){
// rep(i,N) a2[i] = (ind[i] + 1) ** 2;
// A = 1;
// rep(i,N) A *= a2[i];
// B = 0;
// rep(i,N) B += A / a2[i];
// res += 1 / B / a2[0];
// }
// wt(m,res);
// }
// }
LayCurse