結果

問題 No.434 占い
ユーザー greentea011greentea011
提出日時 2018-10-15 10:43:50
言語 C++11
(gcc 11.4.0)
結果
TLE  
実行時間 -
コード長 501 bytes
コンパイル時間 233 ms
コンパイル使用メモリ 23,680 KB
実行使用メモリ 10,752 KB
最終ジャッジ日時 2024-04-20 20:24:05
合計ジャッジ時間 4,065 ms
ジャッジサーバーID
(参考情報)
judge3 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
10,752 KB
testcase_01 AC 2 ms
5,376 KB
testcase_02 AC 1 ms
5,376 KB
testcase_03 AC 1 ms
5,376 KB
testcase_04 AC 1 ms
5,376 KB
testcase_05 AC 1 ms
5,376 KB
testcase_06 AC 2 ms
5,376 KB
testcase_07 AC 2 ms
5,376 KB
testcase_08 AC 87 ms
5,376 KB
testcase_09 AC 10 ms
5,376 KB
testcase_10 AC 2 ms
5,376 KB
testcase_11 AC 2 ms
5,376 KB
testcase_12 AC 2 ms
5,376 KB
testcase_13 AC 85 ms
5,376 KB
testcase_14 AC 10 ms
5,376 KB
testcase_15 TLE -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:18:10: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   18 |     scanf("%d", &t);
      |     ~~~~~^~~~~~~~~~
main.cpp:20:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   20 |         scanf("%s", s);
      |         ~~~~~^~~~~~~~~

ソースコード

diff #

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

char s[10000001];
char f(int cnt) {
   if (cnt==1) return s[0];
   for (int i=0;i<cnt-1;i++) {
       s[i]=((s[i]-'0')+(s[i+1]-'0'))%9+'0';
       if (s[i]=='0') s[i]='9';
   }
   s[cnt-1] = '\0';
   return f(cnt-1);
}

int main() {
    int t;
    char ans[1000000];
    scanf("%d", &t);
    for (int i=0; i<t; i++) {
        scanf("%s", s);
        ans[i]=f(strlen(s));
    }
    for (int i=0; i<t; i++) {
        printf("%c\n", ans[i]);
    }
    return 0;
}
0