結果
問題 | No.1747 Many Formulae 2 |
ユーザー | O2MT |
提出日時 | 2021-11-21 15:25:50 |
言語 | C# (.NET 8.0.203) |
結果 |
AC
|
実行時間 | 48 ms / 2,000 ms |
コード長 | 1,226 bytes |
コンパイル時間 | 7,026 ms |
コンパイル使用メモリ | 142,908 KB |
実行使用メモリ | 160,984 KB |
最終ジャッジ日時 | 2023-09-05 00:41:20 |
合計ジャッジ時間 | 8,833 ms |
ジャッジサーバーID (参考情報) |
judge13 / judge14 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 46 ms
28,356 KB |
testcase_01 | AC | 47 ms
28,360 KB |
testcase_02 | AC | 47 ms
30,496 KB |
testcase_03 | AC | 46 ms
28,096 KB |
testcase_04 | AC | 47 ms
28,580 KB |
testcase_05 | AC | 46 ms
28,284 KB |
testcase_06 | AC | 46 ms
28,208 KB |
testcase_07 | AC | 47 ms
28,380 KB |
testcase_08 | AC | 46 ms
28,560 KB |
testcase_09 | AC | 46 ms
28,528 KB |
testcase_10 | AC | 47 ms
28,464 KB |
testcase_11 | AC | 47 ms
28,524 KB |
testcase_12 | AC | 48 ms
28,488 KB |
testcase_13 | AC | 47 ms
30,132 KB |
testcase_14 | AC | 47 ms
30,136 KB |
testcase_15 | AC | 47 ms
28,536 KB |
testcase_16 | AC | 47 ms
28,524 KB |
testcase_17 | AC | 47 ms
28,632 KB |
testcase_18 | AC | 47 ms
160,984 KB |
コンパイルメッセージ
Determining projects to restore... Restored /home/judge/data/code/main.csproj (in 117 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 (num != 1 && isPrime(num)) count++; } Console.WriteLine(count); } static bool isPrime(long num) { for (long i = 2; i <= Math.Sqrt(num); i++) { if (num % i == 0) { return false; } } return true; } } }