結果

問題 No.502 階乗を計算するだけ
コンテスト
ユーザー 👑 tails
提出日時 2017-04-07 23:04:39
言語 C
(gcc 15.2.0)
結果
CE  
(最新)
AC  
(最初)
実行時間 -
コード長 293 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 91 ms
コンパイル使用メモリ 25,780 KB
最終ジャッジ日時 2026-02-21 23:38:51
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)
コンパイルエラー時のメッセージ・ソースコードは、提出者また管理者しか表示できないようにしております。(リジャッジ後のコンパイルエラーは公開されます)
ただし、clay言語の場合は開発者のデバッグのため、公開されます。

コンパイルメッセージ
main.c:1:1: warning: data definition has no type or storage class
    1 | a[]={
      | ^
main.c:1:1: error: type defaults to 'int' in declaration of 'a' [-Wimplicit-int]
main.c:15:1: error: return type defaults to 'int' [-Wimplicit-int]
   15 | main(){
      | ^~~~
main.c: In function 'main':
main.c:17:9: error: implicit declaration of function 'scanf' [-Wimplicit-function-declaration]
   17 |         scanf("%ld",&n);
      |         ^~~~~
main.c:1:1: note: include '<stdio.h>' or provide a declaration of 'scanf'
  +++ |+#include <stdio.h>
    1 | a[]={
main.c:17:9: warning: incompatible implicit declaration of built-in function 'scanf' [-Wbuiltin-declaration-mismatch]
   17 |         scanf("%ld",&n);
      |         ^~~~~
main.c:17:9: note: include '<stdio.h>' or provide a declaration of 'scanf'
main.c:26:9: error: implicit declaration of function 'printf' [-Wimplicit-function-declaration]
   26 |         printf("%ld",r);
      |         ^~~~~~
main.c:26:9: note: include '<stdio.h>' or provide a declaration of 'printf'
main.c:26:9: warning: incompatible implicit declaration of built-in function 'printf' [-Wbuiltin-declaration-mismatch]
main.c:26:9: note: include '<stdio.h>' or provide a declaration of 'printf'

ソースコード

diff #
raw source code

a[]={
1,
927880474,
933245637,
668123525,
429277690,
733333339,
724464507,
957939114,
203191898,
586445753,
698611116,
};

main(){
	long n;
	scanf("%ld",&n);
	long r=0;
	if(n<1000000007){
		r=a[n/100000000];
		long i=n%100000000;
		while(i--){
			r=r*n--%1000000007;
		}
	}
	printf("%ld",r);
}
0