結果
問題 |
No.129 お年玉(2)
|
ユーザー |
![]() |
提出日時 | 2020-10-27 22:12:05 |
言語 | C (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 1 ms / 5,000 ms |
コード長 | 901 bytes |
コンパイル時間 | 207 ms |
コンパイル使用メモリ | 30,848 KB |
実行使用メモリ | 5,376 KB |
最終ジャッジ日時 | 2024-07-21 22:05:19 |
合計ジャッジ時間 | 1,790 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 46 |
コンパイルメッセージ
main.c: In function 'calc': main.c:29:23: warning: implicit declaration of function 'ffs' [-Wimplicit-function-declaration] 29 | int k=ffs(j)-1; | ^~~ main.c: At top level: main.c:40:1: warning: return type defaults to 'int' [-Wimplicit-int] 40 | main(){ | ^~~~ main.c: In function 'main': main.c:41:9: warning: implicit declaration of function 'read' [-Wimplicit-function-declaration] 41 | read(0,rbuf,sizeof rbuf); | ^~~~ main.c:53:9: warning: implicit declaration of function 'printf' [-Wimplicit-function-declaration] 53 | 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:53:9: warning: incompatible implicit declaration of built-in function 'printf' [-Wbuiltin-declaration-mismatch] 53 | printf("%ld",(rem<<two)%MOD); | ^~~~~~ main.c:53:9: note: include '<stdio.h>' or provide a declaration of 'printf'
ソースコード
// original: // https://yukicoder.me/submissions/9008 #pragma GCC optimize("Ofast") #pragma GCC target("avx2") char rbuf[256]; #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(){ read(0,rbuf,sizeof rbuf); char*rp=rbuf; 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); }