結果

問題 No.212 素数サイコロと合成数サイコロ (2)
ユーザー itezpaceitezpace
提出日時 2016-06-27 08:30:31
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 664 bytes
コンパイル時間 480 ms
コンパイル使用メモリ 71,564 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-04-20 03:27:15
合計ジャッジ時間 1,030 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
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 -
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:43:4: warning: ‘z’ is used uninitialized [-Wuninitialized]
   43 |   z+=x/y;
      |   ~^~~~~

ソースコード

diff #

#include <iostream>
#include <vector>
#include <iomanip>
#include <cmath>
using namespace std;

vector<int> vp={2,3,5,7,11,13};
vector<int> vc={4,6,8,9,10,12};

int main(){
  int p,c;
  cin>>p>>c;

  double x,y,z;
  x=0;
  y=pow(6,p+c);

  double a,aa;
  aa=0;
  if(p>0) aa=1;
  for(int i=0; i<p; ++i){
    a=0;
    for(int j=0; j<6; ++j){
      a+=vp[j];
    }
    aa*=a;
  }

  double b,bb;
  bb=0;
  if(c>0) bb=1;
  for(int i=0; i<c; ++i){
    b=0;
    for(int j=0; j<6; ++j){
      b+=vc[j];
    }
    bb*=b;
  }

  if(aa>0 && bb==0) bb=1;
  if(aa==0 && bb>0) aa=1;
  x=aa*bb;
  z+=x/y;
  cout<<z<<endl;
  cout<<fixed<<setprecision(15)<<z<<endl;
  return 0;
}
0