結果

問題 No.1084 積の積
ユーザー tailstails
提出日時 2021-03-16 15:44:18
言語 C
(gcc 12.3.0)
結果
AC  
実行時間 26 ms / 2,000 ms
コード長 1,069 bytes
コンパイル時間 293 ms
コンパイル使用メモリ 33,408 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-04-25 14:41:34
合計ジャッジ時間 2,224 ms
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
6,812 KB
testcase_01 AC 1 ms
6,940 KB
testcase_02 AC 0 ms
6,940 KB
testcase_03 AC 1 ms
6,944 KB
testcase_04 AC 10 ms
6,940 KB
testcase_05 AC 10 ms
6,940 KB
testcase_06 AC 10 ms
6,944 KB
testcase_07 AC 0 ms
6,944 KB
testcase_08 AC 1 ms
6,940 KB
testcase_09 AC 16 ms
6,940 KB
testcase_10 AC 1 ms
6,944 KB
testcase_11 AC 1 ms
6,944 KB
testcase_12 AC 10 ms
6,940 KB
testcase_13 AC 22 ms
6,944 KB
testcase_14 AC 9 ms
6,940 KB
testcase_15 AC 7 ms
6,940 KB
testcase_16 AC 26 ms
6,940 KB
testcase_17 AC 9 ms
6,940 KB
testcase_18 AC 16 ms
6,940 KB
testcase_19 AC 21 ms
6,940 KB
testcase_20 AC 5 ms
6,940 KB
testcase_21 AC 9 ms
6,940 KB
testcase_22 AC 6 ms
6,940 KB
testcase_23 AC 13 ms
6,940 KB
testcase_24 AC 12 ms
6,940 KB
testcase_25 AC 22 ms
6,944 KB
testcase_26 AC 24 ms
6,944 KB
testcase_27 AC 24 ms
6,940 KB
testcase_28 AC 24 ms
6,944 KB
testcase_29 AC 23 ms
6,944 KB
testcase_30 AC 24 ms
6,940 KB
testcase_31 AC 22 ms
6,940 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.c:42:1: warning: data definition has no type or storage class
   42 | a[100000];
      | ^
main.c:42:1: warning: type defaults to 'int' in declaration of 'a' [-Wimplicit-int]
main.c:44:1: warning: return type defaults to 'int' [-Wimplicit-int]
   44 | main(){
      | ^~~~
main.c: In function 'main':
main.c:59:9: warning: implicit declaration of function 'write' [-Wimplicit-function-declaration]
   59 |         write(1,wbuf,wp-wbuf);
      |         ^~~~~
main.c:60:9: warning: implicit declaration of function '_exit'; did you mean '_Exit'? [-Wimplicit-function-declaration]
   60 |         _exit(0);
      |         ^~~~~
      |         _Exit

ソースコード

diff #

#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;}

char wbuf[1<<28];

#define WTHI(v) {long _z=v,_n=0,_d=0;while(++_n,_d=_d<<8|0x30|_z%10,_z/=10);*(long*)wp=_d;wp+=_n;}
#define WTLO(v) {long _z=v,_n=8,_d=0;while(_d=_d<<8|0x30|_z%10,_z/=10,--_n);*(long*)wp=_d;wp+=8;}
#define WT(v) if(v>=100000000){WTHI(v/100000000);WTLO(v);}else{WTHI(v);}

#define MD 1000000007

long modpow(long a, int b){
  long r=1;
  while(b){
    if(b&1){
      r=r*a%MD;
    }
    b>>=1;
    a=a*a%MD;
  }
  return r;
}

int inverse(int a){
  int b=MD;
  int u=1;
  int v=0;
  while(b){
    int q=a/b,t;
	t=b, b=a-q*b, a=t;
	t=v, v=u-q*v, u=t;
  }
  if(u<0){
    u+=MD;
  }
  return u;
}

a[100000];

main(){
	char*rp=mmap(0l,1l<<28,1,2,0,0ll);
	RD(n);
	long d=1;
	int b=1,c=1,l=0;
	for(int r=0;r<n;++r){
		RD(ar);
		a[r]=ar;
		b=(long)b*modpow(ar,r-l+1)%MD;
		d*=ar;
		for(;d>=1000000000;d/=a[l++])b=(long)b*inverse(d%MD)%MD;
		c=(long)c*b%MD;
	}
	char*wp=wbuf;
	WT(c);
	write(1,wbuf,wp-wbuf);
	_exit(0);
}
0