結果
問題 | No.3 ビットすごろく |
ユーザー | 👑 testestest |
提出日時 | 2015-08-10 02:17:58 |
言語 | C90 (gcc 12.3.0) |
結果 |
AC
|
実行時間 | 70 ms / 5,000 ms |
コード長 | 379 bytes |
コンパイル時間 | 467 ms |
コンパイル使用メモリ | 21,228 KB |
実行使用メモリ | 5,376 KB |
最終ジャッジ日時 | 2024-07-01 07:28:45 |
合計ジャッジ時間 | 1,921 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 33 |
コンパイルメッセージ
main.c: In function ‘g’: main.c:9:1: warning: implicit declaration of function ‘memcpy’ [-Wimplicit-function-declaration] 9 | memcpy(b,a,n*4+4); | ^~~~~~ main.c:1:1: note: include ‘<string.h>’ or provide a declaration of ‘memcpy’ +++ |+#include <string.h> 1 | int f(int x){ main.c:9:1: warning: incompatible implicit declaration of built-in function ‘memcpy’ [-Wbuiltin-declaration-mismatch] 9 | memcpy(b,a,n*4+4); | ^~~~~~ main.c:9:1: note: include ‘<string.h>’ or provide a declaration of ‘memcpy’ main.c: In function ‘main’: main.c:22:1: warning: implicit declaration of function ‘scanf’ [-Wimplicit-function-declaration] 22 | scanf("%d",&n); | ^~~~~ main.c:1:1: note: include ‘<stdio.h>’ or provide a declaration of ‘scanf’ +++ |+#include <stdio.h> 1 | int f(int x){ main.c:22:1: warning: incompatible implicit declaration of built-in function ‘scanf’ [-Wbuiltin-declaration-mismatch] 22 | scanf("%d",&n); | ^~~~~ main.c:22:1: note: include ‘<stdio.h>’ or provide a declaration of ‘scanf’ main.c:24:1: warning: implicit declaration of function ‘printf’ [-Wimplicit-function-declaration] 24 | printf("%d",a[n]?i+1:-1); | ^~~~~~ main.c:24:1: note: include ‘<stdio.h>’ or provide a declaration of ‘printf’ main.c:24:1: warning: incompatible implicit declaration of built-in function ‘printf’ [-Wbuiltin-declaration-mismatch] main.c:24:1: note: include ‘<stdio.h>’ or provide a declaration of ‘printf’
ソースコード
int f(int x){ int s=x%2; while(x/=2)s+=x%2; return s; } int g(int*a,int n){ int b[10001],i,j,s=0; memcpy(b,a,n*4+4); for(i=1;i<=n;i++){ if(!a[i])continue; j=f(i); if(i+j<=n&&!a[i+j])b[i+j]++,s++; if(i-j>0&&!a[i-j])b[i-j]++,s++; } memcpy(a,b,n*4+4); return s; } int main(){ int a[10001]={0,1},i=0,n; scanf("%d",&n); while(!a[n]&&g(a,n))i++; printf("%d",a[n]?i+1:-1); return 0; }