結果

問題 No.16 累乗の加算
ユーザー 明智重蔵
提出日時 2015-08-15 15:30:33
言語 C#(csc)
(csc 3.9.0)
結果
AC  
実行時間 30 ms / 5,000 ms
コード長 1,999 bytes
コンパイル時間 2,587 ms
コンパイル使用メモリ 108,416 KB
実行使用メモリ 19,328 KB
最終ジャッジ日時 2024-06-26 05:01:26
合計ジャッジ時間 2,223 ms
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 14
権限があれば一括ダウンロードができます
コンパイルメッセージ
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.Generic;
using System.Linq;
class Program
{
static string InputPattern = "Input3";
static List<string> GetInputList()
{
var WillReturn = new List<string>();
if (InputPattern == "Input1") {
WillReturn.Add("2 3");
WillReturn.Add("1 2 3");
//14
//x + x2 + x3 ,x=2
//x + x2 + x3 = 2 + 4 + 8 = 14
}
else if (InputPattern == "Input2") {
WillReturn.Add("2 2");
WillReturn.Add("0 100");
//253110
//x0 + x100 = 1 + 1267650600228229401496703205376
//1000003253110
}
else {
string wkStr;
while ((wkStr = Console.ReadLine()) != null) WillReturn.Add(wkStr);
}
return WillReturn;
}
static void Main()
{
List<string> InputList = GetInputList();
int X = InputList[0].Split(' ').Select(A => int.Parse(A)).First();
int[] AArr = InputList[1].Split(' ').Select(A => int.Parse(A)).ToArray();
long Answer = 0;
foreach (int EachInt in AArr) {
Answer = (Answer + DeriveBekijyou(X, EachInt)) % 1000003;
}
Console.WriteLine(Answer);
}
//2XN
static long DeriveBekijyou(int pX, int pN)
{
long CurrJyousuu = pX % 1000003;
long CurrShisuu = 1;
long WillReturn = 1;
while (true) {
//
if ((pN & CurrShisuu) > 0) {
WillReturn = (WillReturn * CurrJyousuu) % 1000003;
}
CurrShisuu *= 2;
if (CurrShisuu > pN) return WillReturn;
CurrJyousuu = (CurrJyousuu * CurrJyousuu) % 1000003;
}
}
}
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
0