結果
問題 | No.81 すべて足すだけの簡単なお仕事です。 |
ユーザー | kuuso1 |
提出日時 | 2014-11-28 01:09:12 |
言語 | C#(csc) (csc 3.9.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 2,571 bytes |
コンパイル時間 | 4,409 ms |
コンパイル使用メモリ | 107,260 KB |
実行使用メモリ | 25,200 KB |
最終ジャッジ日時 | 2023-09-01 22:35:40 |
合計ジャッジ時間 | 6,638 ms |
ジャッジサーバーID (参考情報) |
judge11 / judge14 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 69 ms
20,916 KB |
testcase_01 | AC | 69 ms
25,012 KB |
testcase_02 | WA | - |
testcase_03 | AC | 69 ms
22,936 KB |
testcase_04 | AC | 69 ms
25,080 KB |
testcase_05 | WA | - |
testcase_06 | WA | - |
testcase_07 | WA | - |
testcase_08 | WA | - |
testcase_09 | WA | - |
testcase_10 | AC | 68 ms
25,052 KB |
testcase_11 | AC | 69 ms
23,096 KB |
testcase_12 | AC | 68 ms
23,024 KB |
testcase_13 | AC | 67 ms
25,044 KB |
testcase_14 | AC | 69 ms
23,024 KB |
testcase_15 | AC | 70 ms
23,048 KB |
testcase_16 | AC | 70 ms
23,032 KB |
testcase_17 | AC | 69 ms
23,036 KB |
testcase_18 | AC | 68 ms
25,036 KB |
testcase_19 | AC | 68 ms
23,116 KB |
testcase_20 | AC | 68 ms
22,940 KB |
testcase_21 | AC | 69 ms
23,056 KB |
testcase_22 | AC | 68 ms
23,104 KB |
testcase_23 | AC | 70 ms
24,992 KB |
testcase_24 | WA | - |
testcase_25 | AC | 66 ms
21,136 KB |
testcase_26 | AC | 68 ms
20,960 KB |
testcase_27 | AC | 70 ms
23,020 KB |
testcase_28 | AC | 68 ms
22,908 KB |
testcase_29 | AC | 68 ms
25,068 KB |
コンパイルメッセージ
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(){ String[] SS=new String[N]; for(int i=0;i<N;i++){ SS[i]=(double.Parse(S[i])).ToString("00000000000000.0000000000"); if(SS[i][0]!='-'){ SS[i]="+"+SS[i]; } } String Plus="+00000000000000.0000000000"; for(int i=0;i<N;i++){ if(SS[i][0]=='+')Plus=sum(Plus,SS[i]); } String Minus="-00000000000000.0000000000"; for(int i=0;i<N;i++){ if(SS[i][0]=='-')Minus=sum(Minus,SS[i]); } String sig=""; for(int i=1;i<Plus.Length;i++){ if(Plus[i]==Minus[i])continue; if(Minus[i]>Plus[i]){ sig="-"; break; } if(Minus[i]<Plus[i]){ break; } } String Ans=""; if(sig=="-"){ Ans=div(Minus,Plus).Substring(1); }else{ Ans=div(Plus,Minus).Substring(1); } int cur=0; for(int i=0;i<=12;i++){ if(Ans[i]!='0')break; cur=i; } Ans=Ans.Substring(cur+1); Console.WriteLine(sig+Ans); } String sum(String s,String t){ List<char> r=new List<char>(); int NN=s.Length; int carry=0; for(int i=NN-1;i>0;i--){ if(s[i]=='.'){ r.Add('.'); continue; } int d=carry+(int)(s[i]-'0'+t[i]-'0'); r.Add((char)(d%10+'0')); carry=d/10; } r.Reverse(); return s.Substring(0,1)+new String(r.ToArray()); } String div(String s,String t){ List<char> r=new List<char>(); int NN=s.Length; int carry=0; for(int i=NN-1;i>0;i--){ if(s[i]=='.'){ r.Add('.'); continue; } int d=carry+(int)(s[i]-'0'-(t[i]-'0')); carry=0; if(d<0){ d+=10; carry=-1; } r.Add((char)(d%10+'0')); } r.Reverse(); return s.Substring(0,1)+new String(r.ToArray()); } int N; String[] S; public Sol(){ N=ri(); S=new String[N]; for(int i=0;i<N;i++)S[i]=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));} }