結果

問題 No.747 循環小数N桁目 Hard
ユーザー greentea011
提出日時 2018-10-22 11:12:52
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
WA  
実行時間 -
コード長 466 bytes
コンパイル時間 297 ms
コンパイル使用メモリ 30,976 KB
実行使用メモリ 6,824 KB
最終ジャッジ日時 2024-11-19 03:39:37
合計ジャッジ時間 3,276 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 47 WA * 73
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:9:10: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
    9 |     scanf("%s", n);
      |     ~~~~~^~~~~~~~~
main.cpp:10:10: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   10 |     scanf("%s", k);
      |     ~~~~~^~~~~~~~~

ソースコード

diff #

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

int val[6] = {2, 8, 5, 7, 1, 4};

int main() {
    char n[100001], k[100001];
    scanf("%s", n);
    scanf("%s", k);

    long nn;
    if ((strlen(n)==1) || (n[strlen(n)-1]!='0')) {
        nn=n[strlen(n)-1]-'0';
    }
    else {
        nn=(n[strlen(n)-2]-'0')*10+(n[strlen(n)-1]-'0');
    }
    long nk=k[strlen(k)-1]-'0';

    long ans=pow(nn,nk);
    printf("%d\n",val[(int)(ans-1)%6]);
    return 0;
}
0