結果

問題 No.16 累乗の加算
ユーザー 14番14番
提出日時 2016-03-31 15:07:06
言語 C#(csc)
(csc 3.9.0)
結果
TLE  
実行時間 -
コード長 1,836 bytes
コンパイル時間 1,036 ms
コンパイル使用メモリ 114,108 KB
実行使用メモリ 29,592 KB
最終ジャッジ日時 2024-04-10 06:47:04
合計ジャッジ時間 7,716 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 25 ms
26,100 KB
testcase_01 AC 25 ms
23,924 KB
testcase_02 TLE -
testcase_03 -- -
testcase_04 -- -
testcase_05 -- -
testcase_06 -- -
testcase_07 -- -
testcase_08 -- -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
権限があれば一括ダウンロードができます
コンパイルメッセージ
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;
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();
    }
}
0