結果
問題 | No.432 占い(Easy) |
ユーザー | jousen |
提出日時 | 2016-10-14 22:46:30 |
言語 | C#(csc) (csc 3.9.0) |
結果 |
AC
|
実行時間 | 162 ms / 2,000 ms |
コード長 | 1,369 bytes |
コンパイル時間 | 3,139 ms |
コンパイル使用メモリ | 104,576 KB |
実行使用メモリ | 21,760 KB |
最終ジャッジ日時 | 2024-11-22 08:06:41 |
合計ジャッジ時間 | 5,523 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 22 |
コンパイルメッセージ
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.Generic; using System.Collections; using System.Linq; namespace tes { class contest { static void Main(string[] args) { var n = int.Parse(Console.ReadLine()); var arr = new string[n]; for(int i =0; i< n; i++) { arr[i] = Console.ReadLine(); } var ans = new int[n]; for(int i =0; i< n; i++) { if (arr[i].Length > 1) ans[i] = ret(arr[i]); else ans[i] = int.Parse(arr[i]); } foreach(int item in ans) { Console.WriteLine(item); } } static int ret(string n) { string tmp = ""; while(true) { tmp = ""; for(int i=0; i<n.Length-1; i++) { int t = n[i] - '0' + n[i + 1] - '0'; if(t>=10) { string memo = t.ToString(); t = (memo[0]-'0') + (memo[1]-'0'); } tmp += t.ToString(); } n = tmp; if (n.Length == 1) break; } return int.Parse(n); } } }