結果

問題 No.747 循環小数N桁目 Hard
コンテスト
ユーザー testestest
提出日時 2018-10-19 21:31:54
言語 C11(gcc12 gnu拡張)
(gcc 12.4.0)
コンパイル:
gcc-12 -O2 -std=gnu11 -DONLINE_JUDGE -o a.out _filename_ -lm
実行:
./a.out
結果
AC  
実行時間 1 ms / 2,000 ms
コード長 289 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 89 ms
コンパイル使用メモリ 30,284 KB
実行使用メモリ 7,848 KB
最終ジャッジ日時 2026-03-08 16:18:27
合計ジャッジ時間 2,599 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 120
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.c: In function ‘main’:
main.c:5:9: warning: implicit declaration of function ‘gets’ [-Wimplicit-function-declaration]
    5 |         gets(s);
      |         ^~~~
main.c:16:9: warning: implicit declaration of function ‘printf’ [-Wimplicit-function-declaration]
   16 |         printf("%d",a[temp]);
      |         ^~~~~~
main.c:2:1: note: include ‘<stdio.h>’ or provide a declaration of ‘printf’
    1 | #include <string.h>
  +++ |+#include <stdio.h>
    2 | int a[]={4,2,8,5,7,1};
main.c:16:9: warning: incompatible implicit declaration of built-in function ‘printf’ [-Wbuiltin-declaration-mismatch]
   16 |         printf("%d",a[temp]);
      |         ^~~~~~
main.c:16:9: note: include ‘<stdio.h>’ or provide a declaration of ‘printf’
/usr/bin/ld: /tmp/ccda4pT6.o: in function `main':
main.c:(.text.startup+0x15): 警告: the `gets' function is dangerous and should not be used.

ソースコード

diff #
raw source code

#include <string.h>
int a[]={4,2,8,5,7,1};
char s[100010];
int main(){
	gets(s);
	int n=strlen(s);
	int temp=0;
	for(int i=0;i<n;i++)temp+=s[i]-48;
	temp%=3;
	int temp2=s[n-1]%2;
	gets(s);
	int k=s[strlen(s)-1]%2;
	if(k==0)temp=!!temp;
	
	if(temp%2!=temp2)temp+=3;
	printf("%d",a[temp]);
}
0