結果

問題 No.129 お年玉(2)
コンテスト
ユーザー 👑 tails
提出日時 2020-10-28 09:10:26
言語 C(gnu17)
(gcc 15.2.0)
コンパイル:
gcc-15 -O2 -std=gnu17 -Wno-error=implicit-function-declaration -Wno-error=implicit-int -Wno-error=incompatible-pointer-types -Wno-error=int-conversion -DONLINE_JUDGE -o a.out _filename_ -lm
実行:
./a.out
結果
CE  
(最新)
AC  
(最初)
実行時間 -
コード長 891 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 128 ms
コンパイル使用メモリ 26,624 KB
最終ジャッジ日時 2026-02-22 06:16:02
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)
コンパイルエラー時のメッセージ・ソースコードは、提出者また管理者しか表示できないようにしております。(リジャッジ後のコンパイルエラーは公開されます)
ただし、clay言語の場合は開発者のデバッグのため、公開されます。

コンパイルメッセージ
main.c: In function 'calc':
main.c:29:23: error: implicit declaration of function 'ffs' [-Wimplicit-function-declaration]
   29 |                 int k=ffs(j)-1;
      |                       ^~~
main.c: At top level:
main.c:40:1: error: return type defaults to 'int' [-Wimplicit-int]
   40 | main(){
      | ^~~~
main.c: In function 'main':
main.c:41:17: error: too many arguments to function 'mmap'; expected 0, have 6
   41 |         char*rp=mmap(0l,256l,1,2,0,0ll);
      |                 ^~~~ ~~
main.c:7:6: note: declared here
    7 | char*mmap();
      |      ^~~~
main.c:52:9: error: implicit declaration of function 'printf' [-Wimplicit-function-declaration]
   52 |         printf("%ld",(rem<<two)%MOD);
      |         ^~~~~~
main.c:1:1: note: include '<stdio.h>' or provide a declaration of 'printf'
  +++ |+#include <stdio.h>
    1 | // original:
main.c:52:9: warning: incompatible implicit declaration of built-in function 'printf' [-Wbuiltin-declaration-mismatch]
   52 |         printf("%ld",(rem<<two)%MOD);
      |         ^~~~~~
main.c:52:9: note: include '<stdio.h>' or provide a declaration of 'printf'

ソースコード

diff #
raw source code

// original:
// https://yukicoder.me/submissions/9008

#pragma GCC optimize("Ofast")
#pragma GCC target("avx2")

char*mmap();
#define RD(v) int v=0;{int c;while(c=*rp++-48,c>=0)v=v*10+c;}
#define RDL(v) long v=0;{int c;while(c=*rp++-48,c>=0)v=v*10+c;}

#define MOD 1000000000

long inverse(long a, long m){
	long b = m, u = 1, v = 0;
	while (b) {
		long t = a / b;
		long x;
		x=a-t*b; a=b; b=x;
		x=u-t*v; u=v; v=x;
	}
	return (u % m + m) % m;
}

int two = 0, five = 0;
long rem = 1;
void calc(int a, int b){
	for(int i=a;i<=b;i++){
		int j = i;
		int k=ffs(j)-1;
		j>>=k;
		two+=k;
		while(j % 5 == 0){
			++five;
			j /= 5;
		}
		rem = (rem * j) % MOD;
	}
}

main(){
	char*rp=mmap(0l,256l,1,2,0,0ll);
	RDL(n);
	RDL(m);
	n/=1000;
	n%=m;
	if(n+n>m) n=m-n;
	calc(1,n);
	rem=inverse(rem,MOD);
	two=-two; five=-five;
	calc(m-n+1,m);
	while(five--) rem=rem*5;
	printf("%ld",(rem<<two)%MOD);
}

0