結果

問題 No.2699 Simple Math (Returned)
ユーザー tailstails
提出日時 2024-04-09 21:05:58
言語 C90
(gcc 11.4.0)
結果
AC  
実行時間 55 ms / 2,000 ms
コード長 1,328 bytes
コンパイル時間 394 ms
コンパイル使用メモリ 26,112 KB
実行使用メモリ 8,092 KB
最終ジャッジ日時 2024-04-09 21:06:02
合計ジャッジ時間 2,842 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
6,812 KB
testcase_01 AC 7 ms
6,940 KB
testcase_02 AC 38 ms
7,616 KB
testcase_03 AC 4 ms
6,940 KB
testcase_04 AC 55 ms
7,836 KB
testcase_05 AC 30 ms
7,468 KB
testcase_06 AC 22 ms
7,260 KB
testcase_07 AC 44 ms
7,372 KB
testcase_08 AC 46 ms
7,540 KB
testcase_09 AC 51 ms
8,092 KB
testcase_10 AC 45 ms
7,656 KB
testcase_11 AC 45 ms
7,316 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.c: In function ‘main’:
main.c:47:9: warning: implicit declaration of function ‘write’ [-Wimplicit-function-declaration]
   47 |         write(1,wbuf,wp-wbuf);
      |         ^~~~~
main.c:48:9: warning: implicit declaration of function ‘_exit’ [-Wimplicit-function-declaration]
   48 |         _exit(0);
      |         ^~~~~
main.c:48:9: warning: incompatible implicit declaration of built-in function ‘_exit’ [-Wbuiltin-declaration-mismatch]

ソースコード

diff #

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

#define rd_init() char*rp=({char*mmap();mmap(0l,1l<<25,1,2,0,0ll);})
#define rd() ({int _v=0,_c;while(_c=*rp++-48,_c>=0)_v=_v*10+_c;_v;})

#define WTHI(v) {unsigned _z=v,_n=0;ulong _d=0;while(++_n,_d=_d<<8|0x30|_z%10,_z/=10);*(ulong*)wp=_d;wp+=_n;}
#define WTLO(v) {unsigned _z=v,_n=8;ulong _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 aas(x) ({unsigned _r=x;_r+(_r<MD?0:MD);})
#define MD 998244353

typedef unsigned long ulong;

static const unsigned t10[]={10,100,10000,100000000,346563789,246310186,888327925,509930427,480388543,344436,843324442,770612957,135021217,56147513,702052458,823499382,269498164,1127308,58265495,578627211,311282151,904490625,371975324,122371506,155543970,301496519,220050301,658891113,480750826,852127815,737081821,148579152};

static inline
unsigned p10(int a){
	unsigned r=1;
	for(int i=0;a;a>>=1,++i){
		if(a&1){
			r=(ulong)r*t10[i]%MD;
		}
	}
	return r;
}

char wbuf[1<<25];

int main(){
	char*wp=wbuf;
	rd_init();
	int t=rd();
	while(t--){
		unsigned n=rd();
		unsigned m=rd();
		n%=m*2;
		unsigned a;
		if(n<m){
			a=p10(n)-1;
		}else{
			a=aas(p10(m)-p10(n-m));
		}
		wt(a);
		*wp++='\n';
	}
	write(1,wbuf,wp-wbuf);
	_exit(0);
}
0