結果

問題 No.689 E869120 and Constructing Array 3
コンテスト
ユーザー testestest
提出日時 2018-05-27 19:37:05
言語 C(gnu17)
(gcc 15.2.0)
コンパイル:
gcc-15 -O2 -std=gnu17 -Wno-error=implicit-function-declaration -Wno-error=implicit-int -Wno-error=incompatible-pointer-types -Wno-error=int-conversion -DONLINE_JUDGE -o a.out _filename_ -lm
実行:
./a.out
結果
CE  
(最新)
AC  
(最初)
実行時間 -
コード長 672 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 84 ms
コンパイル使用メモリ 28,176 KB
最終ジャッジ日時 2026-02-22 01:09:34
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)
コンパイルエラー時のメッセージ・ソースコードは、提出者また管理者しか表示できないようにしております。(リジャッジ後のコンパイルエラーは公開されます)
ただし、clay言語の場合は開発者のデバッグのため、公開されます。

コンパイルメッセージ
main.c:10:1: error: return type defaults to 'int' [-Wimplicit-int]
   10 | maekeisann(){
      | ^~~~~~~~~~
main.c:27:1: error: return type defaults to 'int' [-Wimplicit-int]
   27 | f(ll k){
      | ^
main.c: In function 'f':
main.c:29:17: error: implicit declaration of function 'sqrt' [-Wimplicit-function-declaration]
   29 |         ll temp=sqrt(k);
      |                 ^~~~
main.c:1:1: note: include '<math.h>' or provide a declaration of 'sqrt'
  +++ |+#include <math.h>
    1 | #define ll long long
main.c:29:17: warning: incompatible implicit declaration of built-in function 'sqrt' [-Wbuiltin-declaration-mismatch]
   29 |         ll temp=sqrt(k);
      |                 ^~~~
main.c:29:17: note: include '<math.h>' or provide a declaration of 'sqrt'
main.c: At top level:
main.c:36:1: error: return type defaults to 'int' [-Wimplicit-int]
   36 | main(){
      | ^~~~
main.c: In function 'main':
main.c:39:9: error: implicit declaration of function 'scanf' [-Wimplicit-function-declaration]
   39 |         scanf("%lld",&k);
      |         ^~~~~
main.c:1:1: note: include '<stdio.h>' or provide a declaration of 'scanf'
  +++ |+#include <stdio.h>
    1 | #define ll long long
main.c:39:9: warning: incompatible implicit declaration of built-in function 'scanf' [-Wbuiltin-declaration-mismatch]
   39 |         scanf("%lld",&k);
      |         ^~~~~
main.c:39:9: note: include '<stdio.h>' or provide a declaration of 'scanf'
main.c:41:9: error: implicit declaration of function 'printf' [-Wimplicit-function-declaration]
   41 |         printf("%d\n",n*2);
      |         ^~~~~~
main.c:41:9: note: include '<stdio.h>' or provide a declaration of 'printf'
main.c:41:9: warning: incompatible implicit declaration of built-in function 'printf' [-Wbuiltin-declaration-mismatch]
main.c:41:9: note: include '<stdio.h>' or provide a declaration of 'printf'

ソースコード

diff #
raw source code

#define ll long long
#define rep(i,l,r)for(ll i=(l);i<(r);i++)

int isp(ll n){
	for(ll i=2;i*i<=n;i++)if(n%i==0)return 0;
	return 1;
}

ll a[2][50];
maekeisann(){
	a[0][0]=3;
	a[1][0]=2;
	ll cnt=1;
	for(ll c=3;c<1000;c++)if(isp(c+c+1)){
		int f=1;
		rep(i,0,cnt)if(isp(c+  a[  c%2][i]))f=0;
		rep(i,0,cnt)if(isp(c+1+a[1-c%2][i]))f=0;
		if(f){
			a[0][cnt]=c%2?c:c+1;
			a[1][cnt]=c%2?c+1:c;
			cnt++;
		}
	}
}

ll ans[50],len,n;
f(ll k){
	if(k==0)return 0;
	ll temp=sqrt(k);
	k-=temp*temp;
	ans[len++]=temp;
	n+=temp;
	f(k);
}

main(){
	maekeisann();
	ll k;
	scanf("%lld",&k);
	f(k);
	printf("%d\n",n*2);
	rep(i,0,len)rep(j,0,ans[i])printf("%lld %lld ",a[0][i],a[1][i]);
}
0