結果
| 問題 |
No.265 数学のテスト
|
| コンテスト | |
| ユーザー |
kuuso1
|
| 提出日時 | 2015-08-07 23:24:37 |
| 言語 | C#(csc) (csc 3.9.0) |
| 結果 |
AC
|
| 実行時間 | 237 ms / 2,000 ms |
| コード長 | 1,727 bytes |
| コンパイル時間 | 5,603 ms |
| コンパイル使用メモリ | 107,392 KB |
| 実行使用メモリ | 20,224 KB |
| 最終ジャッジ日時 | 2024-11-24 11:23:23 |
| 合計ジャッジ時間 | 4,470 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 32 |
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc) Copyright (C) Microsoft Corporation. All rights reserved.
ソースコード
using System;
using System.Collections;
using System.Collections.Generic;
class TEST{
static void Main(){
Sol mySol =new Sol();
mySol.Solve();
}
}
class Sol{
public void Solve(){
var D=Calc(S);
Console.WriteLine(String.Join(" ",D));
}
long[] Calc(String s){
long[] ret=new long[d+1];
char[] dd=new char[s.Length];
int cnt=0;
for(int i=0;i<s.Length;i++){
if(s[i]=='d')cnt++;
if(s[i]=='}')cnt--;
if(s[i]=='+'){
dd[i]='+';continue;
}
dd[i]=(char)('0'+cnt);
}
String[] ss=s.Split('+');
String[] kk=new String(dd).Split('+');
//Console.WriteLine(String.Join(" ",ss));
//Console.WriteLine(String.Join(" ",kk));
for(int i=0;i<ss.Length;i++){
long x=1;
long deriv=0;
long deg=0;
for(int j=0;j<ss[i].Length;j++){
if(ss[i][j]>='0'&&ss[i][j]<='9'){
x=(long)(ss[i][j]-'0');
deriv=(kk[i][j]-'0');
}
if(ss[i][j]=='x'){deg++;deriv=(kk[i][j]-'0');}
}
for(int j=0;j<deriv;j++){
x*=deg;
deg--;
}
if(x!=0){
ret[deg]+=x;
}
}
return ret;
}
int N;
String S;
int d;
public Sol(){
N=ri();
d=ri();
S=rs();
}
static String rs(){return Console.ReadLine();}
static int ri(){return int.Parse(Console.ReadLine());}
static long rl(){return long.Parse(Console.ReadLine());}
static double rd(){return double.Parse(Console.ReadLine());}
static String[] rsa(){return Console.ReadLine().Split(' ');}
static int[] ria(){return Array.ConvertAll(Console.ReadLine().Split(' '),e=>int.Parse(e));}
static long[] rla(){return Array.ConvertAll(Console.ReadLine().Split(' '),e=>long.Parse(e));}
static double[] rda(){return Array.ConvertAll(Console.ReadLine().Split(' '),e=>double.Parse(e));}
}
kuuso1