結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
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 26 ms
5,400 KB
testcase_05 AC 29 ms
6,128 KB
testcase_06 AC 27 ms
6,348 KB
testcase_07 AC 3 ms
4,348 KB
testcase_08 AC 19 ms
5,052 KB
testcase_09 AC 25 ms
5,336 KB
testcase_10 AC 25 ms
5,340 KB
testcase_11 AC 11 ms
4,348 KB
testcase_12 AC 14 ms
4,348 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.c: In function 'main':
main.c:40:9: warning: implicit declaration of function 'write' [-Wimplicit-function-declaration]
   40 |         write(1,wbuf,wp-wbuf);
      |         ^~~~~
main.c:41:9: warning: implicit declaration of function '_exit'; did you mean '_Exit'? [-Wimplicit-function-declaration]
   41 |         _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);}

#define rep(v,e) for(long v=0;v<e;++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();
		ulong r=1;
		rep(i,31){
			r=r*r%MD;
			if((int)m<0){
				r=r*n%MD;
			}
			m<<=1;
		}
		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