結果
問題 | No.689 E869120 and Constructing Array 3 |
ユーザー | 👑 testestest |
提出日時 | 2018-05-27 19:37:05 |
言語 | C (gcc 12.3.0) |
結果 |
AC
|
実行時間 | 2 ms / 1,000 ms |
コード長 | 672 bytes |
コンパイル時間 | 149 ms |
コンパイル使用メモリ | 30,336 KB |
実行使用メモリ | 5,376 KB |
最終ジャッジ日時 | 2024-06-28 19:09:37 |
合計ジャッジ時間 | 1,412 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 2 ms
5,248 KB |
testcase_01 | AC | 2 ms
5,376 KB |
testcase_02 | AC | 2 ms
5,376 KB |
testcase_03 | AC | 2 ms
5,376 KB |
testcase_04 | AC | 2 ms
5,376 KB |
testcase_05 | AC | 2 ms
5,376 KB |
testcase_06 | AC | 1 ms
5,376 KB |
testcase_07 | AC | 2 ms
5,376 KB |
testcase_08 | AC | 2 ms
5,376 KB |
testcase_09 | AC | 2 ms
5,376 KB |
testcase_10 | AC | 2 ms
5,376 KB |
testcase_11 | AC | 2 ms
5,376 KB |
testcase_12 | AC | 2 ms
5,376 KB |
testcase_13 | AC | 2 ms
5,376 KB |
testcase_14 | AC | 2 ms
5,376 KB |
testcase_15 | AC | 2 ms
5,376 KB |
コンパイルメッセージ
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'
ソースコード
#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]); }