結果

問題 No.294 SuperFizzBuzz
ユーザー akakimidoriakakimidori
提出日時 2017-05-06 15:24:43
言語 C90
(gcc 11.4.0)
結果
AC  
実行時間 384 ms / 5,000 ms
コード長 856 bytes
コンパイル時間 757 ms
コンパイル使用メモリ 25,088 KB
実行使用メモリ 339,224 KB
最終ジャッジ日時 2023-10-12 15:06:43
合計ジャッジ時間 5,263 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 229 ms
263,676 KB
testcase_01 AC 207 ms
263,700 KB
testcase_02 AC 384 ms
339,072 KB
testcase_03 AC 168 ms
263,664 KB
testcase_04 AC 168 ms
263,520 KB
testcase_05 AC 169 ms
263,484 KB
testcase_06 AC 167 ms
263,536 KB
testcase_07 AC 165 ms
263,532 KB
testcase_08 AC 158 ms
267,968 KB
testcase_09 AC 237 ms
329,252 KB
testcase_10 AC 136 ms
199,740 KB
testcase_11 AC 233 ms
301,980 KB
testcase_12 AC 251 ms
318,208 KB
testcase_13 AC 262 ms
328,080 KB
testcase_14 AC 271 ms
339,224 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<stdio.h>
#include<stdlib.h>

void run(void){
  const int len=25;
  int n;
  scanf("%d",&n);

  int *now=(int *)malloc(sizeof(int)*(1<<(len+1)));
  int *next=(int *)malloc(sizeof(int)*(1<<(len+1)));

  now[0]=3;
  now[1]=5;
  int count=0;
  int i;
  for(i=1;i<=len;i++){
    int j;
    for(j=0;j<(1<<i);j++){
      if(now[j]%3==0 && (j&0x01)){
        count++;
        if(n==count){
          int k=i-1;
          while(k>=0){
            if((j>>k)&0x01){
              printf("5");
            } else {
              printf("3");
            }
            k--;
          }
          printf("\n");
          j=(1<<i)-1;
          i=len;
        }
      }
      next[2*j+0]=now[j]+3;
      next[2*j+1]=now[j]+5;
    }
    int *swap=now;
    now=next;
    next=swap;
  }
  free(now);
  free(next);
  return;
}

int main(void){
  run();
  return 0;
}
0