結果
| 問題 |
No.8037 Restricted Lucas (Hard)
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2018-04-01 23:53:11 |
| 言語 | C#(csc) (csc 3.9.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,849 bytes |
| コンパイル時間 | 2,589 ms |
| コンパイル使用メモリ | 105,728 KB |
| 実行使用メモリ | 18,304 KB |
| 最終ジャッジ日時 | 2024-06-26 06:16:09 |
| 合計ジャッジ時間 | 3,407 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | WA * 1 |
| other | WA * 6 |
コンパイルメッセージ
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.IO;
using static System.Console;
class Program
{
static void Main()
{
SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
new Program().solve();
Out.Flush();
}
Scanner cin = new Scanner();
Dictionary<int, long> L;
int zero, one, two, three, seven, ten, h, mod;
void solve()
{
L = new Dictionary<int, long>();
one++;
two = one + one;
three = one + two;
seven = three + two + two;
ten = seven + three;
h = ten * ten;
mod = h * h * h * h * ten + seven;
L[zero] = two;
L[one] = one;
L[two] = three;
int T = cin.scanint[zero];
for (int i = zero; i < T; i++)
{
WriteLine(calc(cin.scanint[zero]));
}
}
long calc(int X)
{
if (L.ContainsKey(X)) return L[X];
Math.DivRem(X, two, out long r);
if (r == zero)
{
var t = calc(X >> one) * calc(X >> one);
Math.DivRem(X >> one, two, out r);
if (r == one)
{
t += two;
}
else
{
t -= two;
}
Math.DivRem(t, mod, out r);
return L[X] = r;
}
else
{
var t = calc(X + one) - calc(X - one) + mod;
Math.DivRem(t, mod, out r);
return L[X] = r;
}
}
}
class Scanner
{
public string[] scan { get { return ReadLine().Split(); } }
public int[] scanint { get { return Array.ConvertAll(scan, int.Parse); } }
public long[] scanlong { get { return Array.ConvertAll(scan, long.Parse); } }
public double[] scandouble { get { return Array.ConvertAll(scan, double.Parse); } }
}