結果

問題 No.434 占い
ユーザー greentea011
提出日時 2018-10-15 10:13:29
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
TLE  
実行時間 -
コード長 495 bytes
コンパイル時間 333 ms
コンパイル使用メモリ 23,296 KB
実行使用メモリ 13,640 KB
最終ジャッジ日時 2024-10-12 18:27:50
合計ジャッジ時間 10,591 ms
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 9 TLE * 3 -- * 15
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:17:10: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   17 |     scanf("%d", &t);
      |     ~~~~~^~~~~~~~~~
main.cpp:19:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   19 |         scanf("%s", s);
      |         ~~~~~^~~~~~~~~

ソースコード

diff #

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

char s[1000000];
char f() {
   if (strlen(s)==1) return s[0];
   for (int i=0;i<strlen(s)-1;i++) {
       s[i]=((s[i]-'0')+(s[i+1]-'0'))/10+((s[i]-'0')+(s[i+1]-'0'))%10+'0';
   }
   s[strlen(s)-1] = '\0';
   return f();
}

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