結果

問題 No.1180 無限和
ユーザー LayCurseLayCurse
提出日時 2020-08-21 22:35:07
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 4,003 bytes
コンパイル時間 2,357 ms
コンパイル使用メモリ 207,492 KB
実行使用メモリ 6,948 KB
最終ジャッジ日時 2024-04-23 06:29:20
合計ジャッジ時間 3,269 ms
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,816 KB
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
testcase_30 WA -
testcase_31 WA -
testcase_32 WA -
testcase_33 WA -
testcase_34 WA -
testcase_35 WA -
testcase_36 WA -
testcase_37 WA -
testcase_38 WA -
testcase_39 WA -
testcase_40 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#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);
//   }
// }
0