結果

問題 No.2363 k-bonacci
ユーザー 👑 tails
提出日時 2023-06-30 11:22:05
言語 C90(gcc15)
(gcc 15.2.0)
コンパイル:
gcc-15 -O2 -std=c90 -DONLINE_JUDGE -o a.out _filename_ -lm
実行:
./a.out
結果
CE  
(最新)
AC  
(最初)
実行時間 -
コード長 601 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 143 ms
コンパイル使用メモリ 26,424 KB
最終ジャッジ日時 2026-02-24 01:14:51
ジャッジサーバーID
(参考情報)
judge2 / judge2
このコードへのチャレンジ
(要ログイン)
コンパイルエラー時のメッセージ・ソースコードは、提出者また管理者しか表示できないようにしております。(リジャッジ後のコンパイルエラーは公開されます)
ただし、clay言語の場合は開発者のデバッグのため、公開されます。

コンパイルメッセージ
main.c: In function 'main':
main.c:31:14: error: expected ';' before 'k'
   31 |         rep3(k,2,61){
      |              ^
main.c:5:35: note: in definition of macro 'rep3'
    5 | #define rep3(v,s,e) for(typeof(e) v=s;v<e;++v)
      |                                   ^
main.c:31:14: error: 'k' undeclared (first use in this function)
   31 |         rep3(k,2,61){
      |              ^
main.c:5:39: note: in definition of macro 'rep3'
    5 | #define rep3(v,s,e) for(typeof(e) v=s;v<e;++v)
      |                                       ^
main.c:31:14: note: each undeclared identifier is reported only once for each function it appears in
   31 |         rep3(k,2,61){
      |              ^
main.c:5:39: note: in definition of macro 'rep3'
    5 | #define rep3(v,s,e) for(typeof(e) v=s;v<e;++v)
      |                                       ^
main.c:33:17: error: 'for' loop initial declarations are only allowed in C99 or C11 mode
   33 |                 for(int j=k;a[j]<=n;++j){
      |                 ^~~
main.c:33:17: note: use option '-std=c99', '-std=gnu99', '-std=c11' or '-std=gnu11' to compile your code

ソースコード

diff #
raw source code

#pragma GCC optimize("Ofast")
#pragma GCC target("avx2")

#define rd() ({long _v=0,_c;while(_c=*rp++-48,_c>=0)_v=_v*10+_c;_v;})
#define rep3(v,s,e) for(typeof(e) v=s;v<e;++v)

long a[128]={1,1};

void found(int k){
	if(k<10){
		k+=48;
		write(1,&k,1);
	}else{
		k=k/10+k%10*256+12336;
		write(1,&k,2);
	}
	_exit(0);
}

int main(){
	long n;
	{
		char rbuf[64];
		read(0,rbuf,sizeof rbuf);
		char*rp=rbuf;
		n=rd();
	}
	if(n==1){
		found(2);
	}
	rep3(k,2,61){
		a[k]=1ll<<k-1;
		for(int j=k;a[j]<=n;++j){
			if(n==a[j]){
				found(k);
			}
			a[j+1]=a[j]*2-a[j-k];
		}
	}
	write(1,"-1",2);
	_exit(0);
}
0