結果

問題 No.294 SuperFizzBuzz
ユーザー MoritaYasuakiMoritaYasuaki
提出日時 2016-05-09 03:57:30
言語 C90
(gcc 11.4.0)
結果
AC  
実行時間 378 ms / 5,000 ms
コード長 1,101 bytes
コンパイル時間 263 ms
コンパイル使用メモリ 22,144 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-04-15 14:54:39
合計ジャッジ時間 2,790 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
6,816 KB
testcase_01 AC 1 ms
6,940 KB
testcase_02 AC 378 ms
6,944 KB
testcase_03 AC 1 ms
6,940 KB
testcase_04 AC 0 ms
6,944 KB
testcase_05 AC 1 ms
6,944 KB
testcase_06 AC 1 ms
6,944 KB
testcase_07 AC 1 ms
6,944 KB
testcase_08 AC 15 ms
6,940 KB
testcase_09 AC 233 ms
6,944 KB
testcase_10 AC 0 ms
6,944 KB
testcase_11 AC 312 ms
6,940 KB
testcase_12 AC 340 ms
6,944 KB
testcase_13 AC 361 ms
6,940 KB
testcase_14 AC 378 ms
6,940 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.c:38:1: warning: return type defaults to ‘int’ [-Wimplicit-int]
   38 | main(void) {
      | ^~~~
main.c: In function ‘main’:
main.c:39:5: warning: ignoring return value of ‘scanf’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   39 |     scanf("%td\n", &N);
      |     ^~~~~~~~~~~~~~~~~~

ソースコード

diff #

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

#define int ptrdiff_t
#define div lldiv
#define div_t lldiv_t
#define abs(a) ((a)<0?-(a):(a))
#define min(a,b) ((a)<(b)?(a):(b))

int N;
int conb(int n, int r) {
    int p = 1;
    int q = 0;
    while (r--)
        p=p*n--/++q;
    return p;
}

int check(int a, int rank) {
    int t = 0;
    if (a%2 == 0) return 0;
    while (rank--)
        if (a & (1ULL << rank))
            t++;
    return t%3 == 0;
}

void print(int a, int rank) {
    while (rank--)
        if (a & (1ULL << rank))
            putchar('5');
        else
            putchar('3');
    printf("\n");
}

main(void) {
    scanf("%td\n", &N);
    int rank = 3;
    for (rank = 3; ; rank++) {
        int t = 0;
        int nfive;
        for (nfive = 3; nfive <= rank; nfive+=3)
            t += conb(rank-1, nfive-1);
        if (t < N) {
            N-=t;
        } else {
            break;
        }
    }
    int a=0;
    do {
       if (check(a, rank))
           if (--N == 0)
               break;
       a++;
    } while(1);
    print(a, rank);
    return 0;
}
0