結果

問題 No.1966 Median of Divisors
ユーザー tailstails
提出日時 2022-06-06 20:24:20
言語 C
(gcc 12.3.0)
結果
AC  
実行時間 24 ms / 2,000 ms
コード長 861 bytes
コンパイル時間 989 ms
コンパイル使用メモリ 31,324 KB
実行使用メモリ 6,384 KB
最終ジャッジ日時 2023-10-21 03:40:29
合計ジャッジ時間 2,737 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,348 KB
testcase_01 AC 1 ms
4,348 KB
testcase_02 AC 1 ms
4,348 KB
testcase_03 AC 1 ms
4,348 KB
testcase_04 AC 18 ms
5,436 KB
testcase_05 AC 24 ms
6,164 KB
testcase_06 AC 21 ms
6,384 KB
testcase_07 AC 3 ms
4,348 KB
testcase_08 AC 12 ms
5,088 KB
testcase_09 AC 17 ms
5,372 KB
testcase_10 AC 17 ms
5,376 KB
testcase_11 AC 9 ms
4,348 KB
testcase_12 AC 11 ms
4,348 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.c: In function 'main':
main.c:38:9: warning: implicit declaration of function 'write' [-Wimplicit-function-declaration]
   38 |         write(1,wbuf,wp-wbuf);
      |         ^~~~~
main.c:39:9: warning: implicit declaration of function '_exit'; did you mean '_Exit'? [-Wimplicit-function-declaration]
   39 |         _exit(0);
      |         ^~~~~
      |         _Exit

ソースコード

diff #

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

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

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

typedef unsigned long ulong;
char wbuf[1<<25];

#define MD 1000000007

int main(){
	char*mmap();
	char*rp=mmap(0l,1l<<25,1,2,0,0ll);
	char*wp=wbuf;

	rd_skip();
	while(*rp){
		ulong n=rd();
		ulong m=rd()>>1;
		ulong r=1;
		while(m){
			if(m&1){
				r=r*n%MD;
			}
			m>>=1;
			n=n*n%MD;
		}
		ulong z=((r*500000004+666666671)%MD*r%MD*r+833333339)%MD*r%MD;
		wt(z);
		*wp++='\n';
	}
	
	write(1,wbuf,wp-wbuf);
	_exit(0);
}
0