結果
| 問題 |
No.16 累乗の加算
|
| コンテスト | |
| ユーザー |
mban
|
| 提出日時 | 2016-12-22 14:30:02 |
| 言語 | C#(csc) (csc 3.9.0) |
| 結果 |
AC
|
| 実行時間 | 27 ms / 5,000 ms |
| コード長 | 983 bytes |
| コンパイル時間 | 1,984 ms |
| コンパイル使用メモリ | 112,144 KB |
| 実行使用メモリ | 19,328 KB |
| 最終ジャッジ日時 | 2024-06-26 05:19:24 |
| 合計ジャッジ時間 | 2,961 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 14 |
コンパイルメッセージ
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.Collections.Specialized;
using System.Text;
using System.Text.RegularExpressions;
using System.Linq;
class Magatro
{
const int MOD = 1000003;
static void Main()
{
int x, N;
string[] s = Console.ReadLine().Split(' ');
x = int.Parse(s[0]);
N = int.Parse(s[1]);
int[] a = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
long cnt = 0;
for(int i = 0; i < N; i++)
{
cnt = (cnt + MyPow(x, a[i])) % MOD;
}
Console.WriteLine(cnt);
}
static long MyPow(long a,long b)
{
long res = 1;
while (b > 0)
{
if (b % 2 == 0)
{
a = (a * a) % MOD;
b /= 2;
}
else
{
res = (res * a) % MOD;
b--;
}
}
return res;
}
}
mban