結果
問題 |
No.16 累乗の加算
|
ユーザー |
![]() |
提出日時 | 2016-03-31 15:07:06 |
言語 | C#(csc) (csc 3.9.0) |
結果 |
TLE
|
実行時間 | - |
コード長 | 1,836 bytes |
コンパイル時間 | 975 ms |
コンパイル使用メモリ | 114,320 KB |
実行使用メモリ | 24,052 KB |
最終ジャッジ日時 | 2024-10-02 08:27:07 |
合計ジャッジ時間 | 7,312 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 2 TLE * 1 -- * 11 |
コンパイルメッセージ
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; using System.Text; public class Program { public void Proc() { Reader.IsDebug = false; int[] inpt = Reader.GetInt(); int baseNum = inpt[0]; int itemCount = inpt[1]; int[] powList = Reader.GetInt(); long ans = 0; for(int i=0; i<powList.Length; i++) { long subTotal = 1; if(powList[i] > 0) { for(int j=1;j<=powList[i]; j++) { subTotal = subTotal * baseNum; if(subTotal > Div) { subTotal = subTotal % Div; } } } ans += subTotal; ans = ans % Div; } Console.WriteLine(ans); } private int Div = 1000003; public class Reader { private static String InitText = @" 2 3 1 2 3 "; private static System.IO.StringReader sr = null; public static bool IsDebug = true; public static string ReadLine() { if(IsDebug) { if(sr == null) { sr = new System.IO.StringReader(InitText.Trim()); } return sr.ReadLine(); } else { return Console.ReadLine(); } } public static int[] GetInt(char delimiter = ' ') { string[] inpt = ReadLine().Split(delimiter); int[] ret = new int[inpt.Length]; for(int i=0; i<inpt.Length; i++) { ret[i] = int.Parse(inpt[i]); } return ret; } } public static void Main(string[] args) { Program prg = new Program(); prg.Proc(); } }