結果
| 問題 |
No.265 数学のテスト
|
| コンテスト | |
| ユーザー |
btk
|
| 提出日時 | 2015-05-30 23:19:47 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
AC
|
| 実行時間 | 3 ms / 2,000 ms |
| コード長 | 1,139 bytes |
| コンパイル時間 | 490 ms |
| コンパイル使用メモリ | 63,472 KB |
| 実行使用メモリ | 5,248 KB |
| 最終ジャッジ日時 | 2024-11-24 11:16:52 |
| 合計ジャッジ時間 | 1,848 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 32 |
ソースコード
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
using namespace std;
#define LL long long
vector<LL> solve(int n,int d,string s){
vector<LL> res(d + 1,0);//解
vector<LL> fact(d + 1, 1);//階乗をメモ
int depth = 0;//現在の項を何回微分すれば良いか
LL nowC = 1;//現在の項の係数部
int nowD = 0;//現在の項のxの指数部
int nowDepth = 0;//現在の項の必要微分回数
/*階乗計算*/
for (int i = 1; i <= d; i++){
fact[i] = fact[i - 1] * i;
}
s += '+';
for (auto& var : s){
switch (var){
case '+':
if (nowD - nowDepth >= 0){
res[nowD - nowDepth] += nowC*(fact[nowD] / fact[nowD-nowDepth]);
}
nowC = 1; nowD = 0; nowDepth = 0;
case '*':
break;
case 'd':
depth++;
case '{':
break;
case '}':
depth--;
break;
case 'x':
nowDepth = depth;
nowD++;
break;
default :
nowDepth = depth;
nowC = (var - '0');
break;
}
}
return res;
}
int main(){
int n, d;
string s;
cin >> n >> d >> s;
auto res = solve(n, d, s);
for (int i = 0; i < d; i++){
cout << res[i] << " ";
}
cout << res[d] << endl;
return 0;
}
btk