結果
| 問題 | No.12 限定された素数 |
| コンテスト | |
| ユーザー |
yuusti
|
| 提出日時 | 2014-12-05 03:42:36 |
| 言語 | C++11(廃止可能性あり) (gcc 15.2.0 + boost 1.89.0) |
| 結果 |
CE
(最新)
AC
(最初)
|
| 実行時間 | - |
| コード長 | 1,736 bytes |
| 記録 | |
| コンパイル時間 | 34 ms |
| 最終ジャッジ日時 | 2026-03-04 21:45:46 |
| 合計ジャッジ時間 | 379 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
コンパイルエラー時のメッセージ・ソースコードは、提出者また管理者しか表示できないようにしております。(リジャッジ後のコンパイルエラーは公開されます)
ただし、clay言語の場合は開発者のデバッグのため、公開されます。
ただし、clay言語の場合は開発者のデバッグのため、公開されます。
コンパイルメッセージ
af396dc31f34
[/j_bin/judge_tool judge 40000 ../CompileMemory.txt /dev/null sud /dev/null _ g++-15 -O2 -lm -std=gnu++11 -Wuninitialized -DONLINE_JUDGE -o a.out main.cpp]
strconv.Atoi: parsing "../CompileMemory.txt": invalid syntax
goroutine 1 [running]:
runtime/debug.Stack()
/home/yuki2006/go/pkg/mod/golang.org/toolchain@v0.0.1-go1.25.0.linux-amd64/src/runtime/debug/stack.go:26 +0x5e
main.main.func1()
/home/yuki2006/gopath/src/yukicoder/judge/main.go:22 +0x57
panic({0x7d6880?, 0xc0000f6240?})
/home/yuki2006/go/pkg/mod/golang.org/toolchain@v0.0.1-go1.25.0.linux-amd64/src/runtime/panic.go:783 +0x132
main.judgeMain({0xc000012150, 0x5?, 0x0?})
/home/yuki2006/gopath/src/yukicoder/judge/judge_linux.go:121 +0x4b1
main.main()
/home/yuki2006/gopath/src/yukicoder/judge/main.go:97 +0x277
ソースコード
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <sstream>
#include <cstring>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <numeric>
#include <cctype>
#include <tuple>
#include <climits>
#include <bitset>
#include <cassert>
#include <random>
#ifdef _MSC_VER
#include <agents.h>
#endif
#define FOR(i, a, b) for(int i = (a); i < (int)(b); ++i)
#define rep(i, n) FOR(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define REV(v) v.rbegin(), v.rend()
#define MEMSET(v, s) memset(v, s, sizeof(v))
#define UNIQUE(v) (v).erase(unique(ALL(v)), (v).end())
#define MP make_pair
#define MT make_tuple
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int N = 5e6+1;
int np[N];
int need[10];
int cnt[10];
bool can(){
rep(i, 10) if (!need[i] && cnt[i]) return false;
return true;
}
bool check(){
rep(i, 10) if (need[i] != (cnt[i] >= 1)) return false;
return true;
}
void f(int val, int k){
if (!val) return;
cnt[val % 10] += k;
f(val / 10, k);
}
int main(){
cin.tie(0);
ios::sync_with_stdio(false);
for (int i = 2; i*i < N; ++i){
if (!np[i]) for (int j = i * 2; j < N; j += i) np[j] = 1;
}
int n;
cin >> n;
rep(i, n){
int x;
cin >> x;
need[x] = 1;
}
int l = 1, r = 1;
int ans = -1;
while (1){
while (r < N && can()){
if(check()) ans = max(ans, r - l - 1);
if (!np[r]) f(r, 1);
++r;
}
if (check()) ans = max(ans, r - l - 1);
if (l >= r) break;
if (!np[l]) f(l, -1);
++l;
if(check()) ans = max(ans, r - l - 1);
}
cout << ans << endl;
return 0;
}
yuusti