結果

問題 No.207 世界のなんとか
ユーザー mannshi222jpmannshi222jp
提出日時 2022-01-27 23:03:26
言語 C
(gcc 12.3.0)
結果
AC  
実行時間 1 ms / 5,000 ms
コード長 2,051 bytes
コンパイル時間 578 ms
コンパイル使用メモリ 29,348 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-08-27 01:32:52
合計ジャッジ時間 1,060 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 0 ms
4,380 KB
testcase_01 AC 0 ms
4,380 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 0 ms
4,380 KB
testcase_04 AC 1 ms
4,380 KB
testcase_05 AC 1 ms
4,376 KB
testcase_06 AC 0 ms
4,384 KB
testcase_07 AC 1 ms
4,380 KB
testcase_08 AC 1 ms
4,380 KB
testcase_09 AC 0 ms
4,380 KB
testcase_10 AC 1 ms
4,380 KB
testcase_11 AC 0 ms
4,380 KB
testcase_12 AC 1 ms
4,380 KB
testcase_13 AC 0 ms
4,376 KB
testcase_14 AC 0 ms
4,380 KB
testcase_15 AC 0 ms
4,376 KB
testcase_16 AC 1 ms
4,376 KB
testcase_17 AC 1 ms
4,380 KB
testcase_18 AC 1 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <stdio.h>
#include <stdbool.h>
#include <string.h>

bool waru( char *A );
bool aru( char *A );
bool tasu( char *A );

int main()
{
        char A[100], B[100];

        scanf( "%s %s\n", &A, &B );
        while( strcmp( A, B ) ) {
                if( waru( A ) ) {
                        printf("%s\n", A );
                } else if( aru( A ) ) {
                        printf("%s\n", A );
                }
                tasu( A );
        }
        if( waru( A ) ) {
                printf("%s\n", A );
        } else if( aru( A ) ) {
                printf("%s\n", A );
        }

        return 0;
}

bool waru( char *A )
{
        int sum = 0;
for( int i = 0; A[i] != '\0'; i++ ) {
                sum += A[i] - '0';
        }
        if( ( sum % 3 ) == 0 ) {
                return true;
        }
        else {
                return false;
        }
}


bool aru( char *A )
{

        for( int i = 0; A[i] != '\0'; i++ ) {
                if( A[i] == '3' ) {
                        return true;
                }
        }
        return false;
}
bool tasu( char *A )
{
        int keta;
        bool crr;
        char tmp[1000];
        int i;
        crr = false;

        keta = strlen( A );

        if( A[keta-1] != '9' ) {
                A[keta-1] = A[keta-1] + 1;
                crr = false;
        }
        else {
                A[keta-1] = '0';
                crr = true;
        }

        for( i = keta - 2 ; i >= 0; i -- ) {
                if( A[i] == '9' ) {
                        if( crr == true ) {
                                A[i] = '0';
                                crr = true;
                        }
                }
                else {
                        if( crr == true ) {
                                A[i] += 1;
                                crr = false;
                        }
                }
        }
        if( crr == true ) {
                strcpy( tmp, A );
                strcpy( A, "1" );
                strcat( A, tmp );
        }

        return true;
}
0