Submission #2451285


Source Code Expand

#include<stdio.h>
#include<algorithm>
#include<string.h>
using namespace std;
char ch[20];
char in[20];
int perm[7]={1,3,5,7,9};
bool chk(long long a){
	for(long long i=2;i*i<=a;i++){
		if(a%i==0)return false;
	}
	return true;
}
int main(){
	scanf("%s",in);
	int n=strlen(in);
	int sz=0;
	for(int i=0;i<n;i++){
		bool fi=false;
		for(int j=0;j<sz;j++){
			if(in[i]==ch[j])fi=true;
		}
		if(!fi){
			ch[sz++]=in[i];
		}
	}
	if(sz>5){
		printf("-1\n");return 0;
	}
	do{
		long long val=0;
		for(int i=0;i<n;i++){
			val*=10;
			for(int j=0;j<sz;j++){
				if(ch[j]==in[i])val+=perm[j];
			}
		}
		if(val>1&&chk(val)){
			printf("%lld\n",val);return 0;
		}
	}while(next_permutation(perm,perm+5));
	printf("-1\n");
}

Submission Info

Submission Time
Task D - 文字列と素数
User luogu_bot3
Language C++ (GCC 5.4.1)
Score 50
Code Size 711 Byte
Status AC
Exec Time 1 ms
Memory 128 KB

Compile Error

./Main.cpp: In function ‘int main()’:
./Main.cpp:15:16: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
  scanf("%s",in);
                ^

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 50 / 50
Status
AC × 3
AC × 25
Set Name Test Cases
Sample 00_sample_00, 00_sample_01, 00_sample_02
All 00_sample_00, 00_sample_01, 00_sample_02, 05_rand_00, 05_rand_01, 05_rand_02, 05_rand_03, 05_rand_04, 05_rand_05, 05_rand_06, 05_rand_07, 05_rand_08, 05_rand_09, 15_rand_00, 15_rand_01, 15_rand_02, 15_rand_03, 15_rand_04, 15_rand_05, 15_rand_06, 15_rand_07, 15_rand_08, 15_rand_09, 20_teuti_00, 20_teuti_01
Case Name Status Exec Time Memory
00_sample_00 AC 0 ms 128 KB
00_sample_01 AC 0 ms 128 KB
00_sample_02 AC 0 ms 128 KB
05_rand_00 AC 1 ms 128 KB
05_rand_01 AC 0 ms 128 KB
05_rand_02 AC 0 ms 128 KB
05_rand_03 AC 1 ms 128 KB
05_rand_04 AC 0 ms 128 KB
05_rand_05 AC 0 ms 128 KB
05_rand_06 AC 0 ms 128 KB
05_rand_07 AC 1 ms 128 KB
05_rand_08 AC 0 ms 128 KB
05_rand_09 AC 0 ms 128 KB
15_rand_00 AC 1 ms 128 KB
15_rand_01 AC 1 ms 128 KB
15_rand_02 AC 0 ms 128 KB
15_rand_03 AC 1 ms 128 KB
15_rand_04 AC 1 ms 128 KB
15_rand_05 AC 0 ms 128 KB
15_rand_06 AC 1 ms 128 KB
15_rand_07 AC 1 ms 128 KB
15_rand_08 AC 0 ms 128 KB
15_rand_09 AC 1 ms 128 KB
20_teuti_00 AC 1 ms 128 KB
20_teuti_01 AC 1 ms 128 KB