結果
問題 | No.1747 Many Formulae 2 |
ユーザー | O2MT |
提出日時 | 2021-11-21 15:18:35 |
言語 | C# (.NET 8.0.203) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,219 bytes |
コンパイル時間 | 7,791 ms |
コンパイル使用メモリ | 146,124 KB |
実行使用メモリ | 164,304 KB |
最終ジャッジ日時 | 2023-09-05 00:32:51 |
合計ジャッジ時間 | 9,261 ms |
ジャッジサーバーID (参考情報) |
judge13 / judge11 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | WA | - |
testcase_01 | AC | 47 ms
28,376 KB |
testcase_02 | AC | 46 ms
28,352 KB |
testcase_03 | AC | 46 ms
28,332 KB |
testcase_04 | WA | - |
testcase_05 | AC | 47 ms
28,076 KB |
testcase_06 | AC | 46 ms
30,132 KB |
testcase_07 | WA | - |
testcase_08 | AC | 46 ms
28,588 KB |
testcase_09 | WA | - |
testcase_10 | AC | 47 ms
28,548 KB |
testcase_11 | AC | 46 ms
28,612 KB |
testcase_12 | AC | 46 ms
28,372 KB |
testcase_13 | AC | 46 ms
28,056 KB |
testcase_14 | AC | 46 ms
28,364 KB |
testcase_15 | WA | - |
testcase_16 | WA | - |
testcase_17 | AC | 46 ms
28,208 KB |
testcase_18 | WA | - |
コンパイルメッセージ
Determining projects to restore... Restored /home/judge/data/code/main.csproj (in 123 ms). .NET 向け Microsoft (R) Build Engine バージョン 17.0.0-preview-21470-01+cb055d28f Copyright (C) Microsoft Corporation.All rights reserved. プレビュー版の .NET を使用しています。https://aka.ms/dotnet-core-preview をご覧ください main -> /home/judge/data/code/bin/Release/net6.0/main.dll main -> /home/judge/data/code/bin/Release/net6.0/publish/
ソースコード
using System; namespace Sample { class Program { static void Main(string[] args) { var S = Console.ReadLine(); var N = S.Length; var count = 0; for (int i = 0; i < Math.Pow(2, N - 1); i++) { long num = 0; long n = long.Parse(S.Substring(0, 1)); for (int j = 0; j < N - 1; j++) { long x = (i >> j) & 1; if (x == 1) { num += n; n = long.Parse(S.Substring(j + 1, 1)); } else { n = n * 10 + long.Parse(S.Substring(j + 1, 1)); } } num += n; if (isPrime(num)) count++; } Console.WriteLine(count); } static bool isPrime(long num) { for (long i = 2; i < (long)Math.Sqrt(num); i++) { if (num % i == 0) { return false; } } return true; } } }