結果

問題 No.1791 Repeat Multiplication
ユーザー tailstails
提出日時 2021-12-20 00:51:28
言語 C
(gcc 12.3.0)
結果
AC  
実行時間 131 ms / 3,000 ms
コード長 941 bytes
コンパイル時間 1,030 ms
コンパイル使用メモリ 32,164 KB
実行使用メモリ 26,036 KB
最終ジャッジ日時 2023-10-13 19:19:16
合計ジャッジ時間 7,123 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 114 ms
24,932 KB
testcase_01 AC 110 ms
24,936 KB
testcase_02 AC 111 ms
24,936 KB
testcase_03 AC 109 ms
24,832 KB
testcase_04 AC 111 ms
24,840 KB
testcase_05 AC 113 ms
24,880 KB
testcase_06 AC 113 ms
24,868 KB
testcase_07 AC 116 ms
24,928 KB
testcase_08 AC 123 ms
25,772 KB
testcase_09 AC 126 ms
25,696 KB
testcase_10 AC 122 ms
25,680 KB
testcase_11 AC 122 ms
25,612 KB
testcase_12 AC 118 ms
25,244 KB
testcase_13 AC 123 ms
25,972 KB
testcase_14 AC 125 ms
25,980 KB
testcase_15 AC 131 ms
25,816 KB
testcase_16 AC 128 ms
25,964 KB
testcase_17 AC 130 ms
25,980 KB
testcase_18 AC 124 ms
25,896 KB
testcase_19 AC 118 ms
25,912 KB
testcase_20 AC 119 ms
25,816 KB
testcase_21 AC 129 ms
25,904 KB
testcase_22 AC 123 ms
25,852 KB
testcase_23 AC 125 ms
25,888 KB
testcase_24 AC 125 ms
25,916 KB
testcase_25 AC 124 ms
25,904 KB
testcase_26 AC 125 ms
25,968 KB
testcase_27 AC 124 ms
25,956 KB
testcase_28 AC 124 ms
25,908 KB
testcase_29 AC 125 ms
25,916 KB
testcase_30 AC 125 ms
25,864 KB
testcase_31 AC 117 ms
24,928 KB
testcase_32 AC 124 ms
25,856 KB
testcase_33 AC 126 ms
26,036 KB
testcase_34 AC 128 ms
25,984 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.c: 関数 ‘f1’ 内:
main.c:41:9: 警告: 関数 ‘write’ の暗黙的な宣言です [-Wimplicit-function-declaration]
   41 |         write(1,wbuf,wp-wbuf);
      |         ^~~~~
main.c:42:9: 警告: implicit declaration of function ‘_exit’; did you mean ‘_Exit’? [-Wimplicit-function-declaration]
   42 |         _exit(0);
      |         ^~~~~
      |         _Exit
main.c: トップレベル:
main.c:45:1: 警告: 戻り値の型をデフォルトの ‘int’ にします [-Wimplicit-int]
   45 | 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){if(v>=10000000000000000l){WTHI(v/10000000000000000l);WTLO(v/100000000);}else WTHI(v/100000000);WTLO(v);}else{WTHI(v);}

#define M 1500001
long a[M];
long b[M];

void f0(){
	a[1]=1;
	for(long i=1;i<M;++i){
		for(long j=i*2;j<M;j+=i){
			a[j]+=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