結果

問題 No.265 数学のテスト
ユーザー kuuso1kuuso1
提出日時 2015-08-07 23:24:37
言語 C#(csc)
(csc 3.9.0)
結果
AC  
実行時間 264 ms / 2,000 ms
コード長 1,727 bytes
コンパイル時間 3,065 ms
コンパイル使用メモリ 108,312 KB
実行使用メモリ 23,852 KB
最終ジャッジ日時 2023-08-16 02:02:37
合計ジャッジ時間 7,042 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 53 ms
20,804 KB
testcase_01 AC 264 ms
23,852 KB
testcase_02 AC 61 ms
21,324 KB
testcase_03 AC 62 ms
21,296 KB
testcase_04 AC 63 ms
21,104 KB
testcase_05 AC 63 ms
23,328 KB
testcase_06 AC 62 ms
23,284 KB
testcase_07 AC 62 ms
19,148 KB
testcase_08 AC 61 ms
19,328 KB
testcase_09 AC 60 ms
23,240 KB
testcase_10 AC 62 ms
23,276 KB
testcase_11 AC 60 ms
21,300 KB
testcase_12 AC 53 ms
20,636 KB
testcase_13 AC 60 ms
21,064 KB
testcase_14 AC 60 ms
23,120 KB
testcase_15 AC 55 ms
22,784 KB
testcase_16 AC 62 ms
20,888 KB
testcase_17 AC 52 ms
20,708 KB
testcase_18 AC 60 ms
20,752 KB
testcase_19 AC 58 ms
20,680 KB
testcase_20 AC 57 ms
20,968 KB
testcase_21 AC 51 ms
18,668 KB
testcase_22 AC 60 ms
22,948 KB
testcase_23 AC 49 ms
20,664 KB
testcase_24 AC 57 ms
22,776 KB
testcase_25 AC 59 ms
21,100 KB
testcase_26 AC 51 ms
20,660 KB
testcase_27 AC 52 ms
20,660 KB
testcase_28 AC 61 ms
20,852 KB
testcase_29 AC 56 ms
20,748 KB
testcase_30 AC 59 ms
20,968 KB
testcase_31 AC 54 ms
20,740 KB
testcase_32 AC 54 ms
22,656 KB
testcase_33 AC 54 ms
20,788 KB
testcase_34 AC 51 ms
20,760 KB
testcase_35 AC 51 ms
22,700 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc)
Copyright (C) Microsoft Corporation. All rights reserved.

ソースコード

diff #

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