結果
| 問題 |
No.375 立方体のN等分 (1)
|
| コンテスト | |
| ユーザー |
norioc
|
| 提出日時 | 2016-06-05 13:34:17 |
| 言語 | C#(csc) (csc 3.9.0) |
| 結果 |
RE
|
| 実行時間 | - |
| コード長 | 1,918 bytes |
| コンパイル時間 | 3,322 ms |
| コンパイル使用メモリ | 110,252 KB |
| 実行使用メモリ | 28,832 KB |
| 最終ジャッジ日時 | 2024-10-08 15:36:53 |
| 合計ジャッジ時間 | 4,134 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | RE * 2 |
| other | RE * 32 |
コンパイルメッセージ
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.Linq;
class Program {
static string ReadLine() { return Console.ReadLine(); }
static int ReadInt() { return int.Parse(ReadLine()); }
static int[] ReadInts() { return ReadLine().Split().Select(int.Parse).ToArray(); }
static string[] ReadStrings() { return ReadLine().Split(); }
static void Test() {
// m^n が 65535 を超える
for (int i = 2; ; i++) { // i 種類の文字を使って p 文字の文字列を作る
int p = 1;
while (Math.Pow(i, p+1) <= 63353) {
p++;
}
if (i <= p) {
Console.WriteLine("{0}^{1} = {2}", i, p, Math.Pow(i, p));
}
if (p == 1) break;
}
}
static int RunLength(int[] xs) {
int len = 0;
int x = xs[0];
int n = 1;
for (int i = 1; i < xs.Length; i++) {
if (x == xs[i]) {
n++;
}
else {
len += 1 + n.ToString().Length;
n = 1;
}
}
len += 1 + n.ToString().Length;
return len;
}
static int Calc_1(int p, int[] xs, int m) {
if (p == xs.Length) {
if (xs.Length > RunLength(xs)) return 1;
return 0;
}
int ret = 0;
for (int i = 0; i < m; i++) {
xs[p] = i;
ret += Calc_1(p+1, xs, m);
}
return ret;
}
static int Calc(int m, int n) {
var xs = new int[n];
return Calc_1(0, xs, m);
}
static void Main() {
// Test();
var mn = ReadLine().Split(new[] { ',' }).Select(int.Parse).ToArray();
int m = mn[0], n = mn[1];
int ans = Calc(m, n);
Console.WriteLine(ans);
}
}
/*
Input Output
2,5 10
3,10 2505
4,7 616
2,16 19898
8,5 232
*/
norioc