結果
問題 | No.1747 Many Formulae 2 |
ユーザー |
|
提出日時 | 2021-11-21 15:18:35 |
言語 | C# (.NET 8.0.404) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,219 bytes |
コンパイル時間 | 7,740 ms |
コンパイル使用メモリ | 166,884 KB |
実行使用メモリ | 183,896 KB |
最終ジャッジ日時 | 2024-06-22 21:44:17 |
合計ジャッジ時間 | 9,519 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 12 WA * 7 |
コンパイルメッセージ
復元対象のプロジェクトを決定しています... /home/judge/data/code/main.csproj を復元しました (95 ms)。 MSBuild のバージョン 17.9.6+a4ecab324 (.NET) main -> /home/judge/data/code/bin/Release/net8.0/main.dll main -> /home/judge/data/code/bin/Release/net8.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; } } }