結果

問題 No.1791 Repeat Multiplication
ユーザー tailstails
提出日時 2021-12-20 01:05:52
言語 C
(gcc 12.3.0)
結果
AC  
実行時間 64 ms / 3,000 ms
コード長 925 bytes
コンパイル時間 442 ms
コンパイル使用メモリ 32,176 KB
実行使用メモリ 20,168 KB
最終ジャッジ日時 2023-10-13 19:19:47
合計ジャッジ時間 4,602 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 52 ms
19,012 KB
testcase_01 AC 52 ms
19,144 KB
testcase_02 AC 52 ms
19,008 KB
testcase_03 AC 52 ms
19,124 KB
testcase_04 AC 51 ms
19,080 KB
testcase_05 AC 52 ms
19,024 KB
testcase_06 AC 53 ms
19,076 KB
testcase_07 AC 53 ms
19,016 KB
testcase_08 AC 57 ms
19,936 KB
testcase_09 AC 56 ms
19,832 KB
testcase_10 AC 56 ms
19,820 KB
testcase_11 AC 55 ms
19,636 KB
testcase_12 AC 55 ms
19,472 KB
testcase_13 AC 60 ms
20,052 KB
testcase_14 AC 60 ms
20,104 KB
testcase_15 AC 61 ms
20,020 KB
testcase_16 AC 60 ms
20,024 KB
testcase_17 AC 61 ms
20,052 KB
testcase_18 AC 61 ms
20,100 KB
testcase_19 AC 60 ms
20,044 KB
testcase_20 AC 59 ms
19,960 KB
testcase_21 AC 62 ms
20,112 KB
testcase_22 AC 64 ms
20,148 KB
testcase_23 AC 62 ms
20,092 KB
testcase_24 AC 61 ms
20,008 KB
testcase_25 AC 61 ms
20,104 KB
testcase_26 AC 60 ms
20,120 KB
testcase_27 AC 61 ms
20,052 KB
testcase_28 AC 63 ms
20,052 KB
testcase_29 AC 61 ms
20,060 KB
testcase_30 AC 60 ms
20,168 KB
testcase_31 AC 53 ms
18,948 KB
testcase_32 AC 62 ms
20,060 KB
testcase_33 AC 61 ms
20,124 KB
testcase_34 AC 61 ms
20,000 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.c: 関数 ‘f1’ 内:
main.c:45:9: 警告: 関数 ‘write’ の暗黙的な宣言です [-Wimplicit-function-declaration]
   45 |         write(1,wbuf,wp-wbuf);
      |         ^~~~~
main.c:46:9: 警告: implicit declaration of function ‘_exit’; did you mean ‘_Exit’? [-Wimplicit-function-declaration]
   46 |         _exit(0);
      |         ^~~~~
      |         _Exit
main.c: トップレベル:
main.c:49:1: 警告: 戻り値の型をデフォルトの ‘int’ にします [-Wimplicit-int]
   49 | main(){
      | ^~~~

ソースコード

diff #

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

char*mmap();
char wbuf[1<<25];

#define rd_skip() while(*rp++>=48)
#define rd(v) long v=0;{long _c;while(_c=*rp++-48,_c>=0)v=v*10+_c;}

#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 M 1500001
int a[M];
long b[M];

void f0(){
	a[1]=1;
	for(long i=0;++i<M/3+1;){
		int ai=a[i];
		for(long j=i;j+=i,j<M;){
			a[j]+=ai;
		}
	}
	for(long i=M/3;++i<=M/2;){
		a[i*2]+=a[i];
	}
	for(long i=1;i<M;++i){
		b[i]=b[i-1]+a[i];
	}
}

void f1(){
	char*rp=mmap(0l,1l<<25,1,2,0,0ll);
	char*wp=wbuf;
	rd(n);
	rd_skip();
	while(*rp){
		rd(x);
		long z=a[x]*b[n/x];
		wt(z);
		*wp++='\n';
	}
	write(1,wbuf,wp-wbuf);
	_exit(0);
}

main(){
	f0();
	f1();
}
0