結果

問題 No.689 E869120 and Constructing Array 3
ユーザー testestesttestestest
提出日時 2018-05-27 19:35:50
言語 C
(gcc 12.3.0)
結果
WA  
実行時間 -
コード長 672 bytes
コンパイル時間 255 ms
コンパイル使用メモリ 30,208 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-06-28 19:09:33
合計ジャッジ時間 3,344 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 AC 2 ms
5,376 KB
testcase_14 WA -
testcase_15 WA -
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.c:10:1: warning: return type defaults to 'int' [-Wimplicit-int]
   10 | maekeisann(){
      | ^~~~~~~~~~
main.c:27:1: warning: return type defaults to 'int' [-Wimplicit-int]
   27 | f(ll k){
      | ^
main.c: In function 'f':
main.c:29:17: warning: 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: warning: return type defaults to 'int' [-Wimplicit-int]
   36 | main(){
      | ^~~~
main.c: In function 'main':
main.c:39:9: warning: 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: warning: 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 #

#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]=1;
	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