結果

問題 No.347 微分と積分
ユーザー HeyHey0111HeyHey0111
提出日時 2016-03-07 03:08:22
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 2 ms / 5,000 ms
コード長 1,416 bytes
コンパイル時間 775 ms
コンパイル使用メモリ 68,296 KB
実行使用メモリ 4,348 KB
最終ジャッジ日時 2023-10-24 20:11:58
合計ジャッジ時間 1,574 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,348 KB
testcase_01 AC 2 ms
4,348 KB
testcase_02 AC 1 ms
4,348 KB
testcase_03 AC 1 ms
4,348 KB
testcase_04 AC 1 ms
4,348 KB
testcase_05 AC 1 ms
4,348 KB
testcase_06 AC 2 ms
4,348 KB
testcase_07 AC 2 ms
4,348 KB
testcase_08 AC 1 ms
4,348 KB
testcase_09 AC 2 ms
4,348 KB
testcase_10 AC 2 ms
4,348 KB
testcase_11 AC 2 ms
4,348 KB
testcase_12 AC 1 ms
4,348 KB
testcase_13 AC 1 ms
4,348 KB
testcase_14 AC 1 ms
4,348 KB
testcase_15 AC 1 ms
4,348 KB
testcase_16 AC 1 ms
4,348 KB
testcase_17 AC 1 ms
4,348 KB
testcase_18 AC 1 ms
4,348 KB
testcase_19 AC 2 ms
4,348 KB
testcase_20 AC 1 ms
4,348 KB
testcase_21 AC 1 ms
4,348 KB
testcase_22 AC 1 ms
4,348 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<iostream>
#include<vector>
#include<algorithm>
#include<math.h>
#include<string>
using namespace std;

void countaToz(string s,int *c){
  for(int i=0;i<26;i++){
  c[i]=0;
  }
  for(int i=0;i<s.length();i++){
    c[s[i]-'a']++;
  }
}

bool check(string a,string b,string s){
  int ca[26],cb[26],cs[26];
  countaToz(a,ca);
  countaToz(b,cb);
  countaToz(s,cs);
  for(int i=0;i<26;i++){
    if(cs[i]>(ca[i]+cb[i]))return false;
  }
  return true;
}

int getInitial(string tmp,char c){
  for(int i=0;i<tmp.length();i++){
    if(tmp[i]==c)return i;
  }
  return -1;
}

int dp(string a,string b,string s,int count){
  if(check(a,b,s)==false)return -1;
  if(!s.length())return count;
  int ia=getInitial(a,s[0]);
  int ib=getInitial(b,s[0]);
  int reta=-1,retb=-1;
  if(ia!=-1)reta=dp(a.substr(ia+1),b,s.substr(1),count+ia+1);
  if(ib!=-1)retb=dp(a,b.substr(ib+1),s.substr(1),count+ib+1);
  if(reta==-1&&retb==-1)return -1;
  if(reta==-1)return retb;
  if(retb==-1)return reta;
  return min(retb,reta);
}

int main(){
  int n,b;
  double a[10]={};
  cin >> n >> b;
  //dif
  double bibun=0;
  double sekibun=0;
  for(int i=0;i<n;i++){
    cin >> a[i];
  }
  for(int i=0;i<n;i++){
    if(a[i]){
      bibun+=a[i]*pow(b,a[i]-1.);
    }else{
      bibun;
    }

    if(a[i]!=-1){
      sekibun+=pow(b,a[i]+1)/(a[i]+1.);
    }else{
      sekibun+=log(b);
    }
  }
  printf("%.6f\n%.6f\n",bibun,sekibun);
  return 0;
}
0