結果

問題 No.2170 Left Addition Machine
ユーザー tailstails
提出日時 2022-12-22 11:54:42
言語 C90
(gcc 11.4.0)
結果
AC  
実行時間 19 ms / 2,000 ms
コード長 1,608 bytes
コンパイル時間 2,667 ms
コンパイル使用メモリ 30,136 KB
実行使用メモリ 11,140 KB
最終ジャッジ日時 2023-08-11 13:04:03
合計ジャッジ時間 12,061 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 2 ms
4,384 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 14 ms
10,396 KB
testcase_04 AC 6 ms
5,668 KB
testcase_05 AC 9 ms
7,448 KB
testcase_06 AC 9 ms
7,728 KB
testcase_07 AC 12 ms
9,244 KB
testcase_08 AC 4 ms
4,868 KB
testcase_09 AC 9 ms
7,880 KB
testcase_10 AC 3 ms
4,380 KB
testcase_11 AC 6 ms
6,596 KB
testcase_12 AC 14 ms
10,956 KB
testcase_13 AC 15 ms
10,932 KB
testcase_14 AC 15 ms
11,020 KB
testcase_15 AC 15 ms
10,956 KB
testcase_16 AC 14 ms
10,980 KB
testcase_17 AC 14 ms
11,032 KB
testcase_18 AC 15 ms
10,940 KB
testcase_19 AC 15 ms
11,076 KB
testcase_20 AC 15 ms
10,932 KB
testcase_21 AC 7 ms
6,920 KB
testcase_22 AC 7 ms
6,912 KB
testcase_23 AC 8 ms
6,912 KB
testcase_24 AC 7 ms
7,012 KB
testcase_25 AC 8 ms
6,992 KB
testcase_26 AC 8 ms
6,968 KB
testcase_27 AC 7 ms
6,988 KB
testcase_28 AC 7 ms
6,944 KB
testcase_29 AC 8 ms
6,992 KB
testcase_30 AC 16 ms
11,028 KB
testcase_31 AC 17 ms
10,932 KB
testcase_32 AC 16 ms
11,040 KB
testcase_33 AC 18 ms
11,040 KB
testcase_34 AC 17 ms
11,032 KB
testcase_35 AC 17 ms
11,012 KB
testcase_36 AC 17 ms
11,128 KB
testcase_37 AC 17 ms
11,040 KB
testcase_38 AC 17 ms
10,936 KB
testcase_39 AC 8 ms
6,972 KB
testcase_40 AC 8 ms
7,008 KB
testcase_41 AC 8 ms
6,916 KB
testcase_42 AC 8 ms
6,968 KB
testcase_43 AC 8 ms
7,100 KB
testcase_44 AC 8 ms
7,008 KB
testcase_45 AC 8 ms
6,996 KB
testcase_46 AC 8 ms
7,048 KB
testcase_47 AC 8 ms
7,012 KB
testcase_48 AC 17 ms
10,980 KB
testcase_49 AC 16 ms
11,036 KB
testcase_50 AC 17 ms
10,964 KB
testcase_51 AC 16 ms
10,988 KB
testcase_52 AC 18 ms
10,940 KB
testcase_53 AC 16 ms
11,064 KB
testcase_54 AC 18 ms
10,960 KB
testcase_55 AC 19 ms
10,948 KB
testcase_56 AC 18 ms
10,940 KB
testcase_57 AC 14 ms
11,084 KB
testcase_58 AC 15 ms
11,120 KB
testcase_59 AC 13 ms
11,120 KB
testcase_60 AC 12 ms
10,992 KB
testcase_61 AC 13 ms
10,992 KB
testcase_62 AC 13 ms
11,124 KB
testcase_63 AC 13 ms
11,120 KB
testcase_64 AC 14 ms
11,064 KB
testcase_65 AC 13 ms
11,140 KB
testcase_66 AC 3 ms
4,692 KB
testcase_67 AC 9 ms
7,928 KB
testcase_68 AC 13 ms
11,004 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.c: In function ‘mkwd’:
main.c:23:13: warning: multi-character character constant [-Wmultichar]
  unsigned v='0000';
             ^~~~~~
main.c: In function ‘main’:
main.c:56:8: warning: conversion from ‘long long unsigned int’ to ‘unsigned int’ changes value from ‘18446744073709551615’ to ‘4294967295’ [-Woverflow]
   a[0]=~0ull;
        ^
main.c:97:2: warning: implicit declaration of function ‘write’ [-Wimplicit-function-declaration]
  write(1,wbuf,wp-wbuf);
  ^~~~~
main.c:98:2: warning: implicit declaration of function ‘_exit’ [-Wimplicit-function-declaration]
  _exit(0);
  ^~~~~
main.c:98:2: warning: incompatible implicit declaration of built-in function ‘_exit’

ソースコード

diff #

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

#define getrp() ({char*mmap();mmap(0l,1l<<25,1,2,0,0ll);})
#define rd_skip() while(*rp++>=48)
#define rd() ({int _v=0,_c;while(_c=*rp++-48,_c>=0)_v=_v*10+_c;_v;})
#define rep(v,e) for(long v=0;v<e;++v)
#define rep3(v,s,e) for(long v=s;v<e;++v)
#define aaa(x) ({ulong _r=x;_r-(_r<MD?0:MD);})
#define aas(x) ({ulong _r=x;_r+(_r<MD?0:MD);})
#define MD 998244353

typedef unsigned long ulong;

unsigned a[200001];
unsigned b[200001];
unsigned t[200001];
int c[200001];
char wbuf[1<<25];
unsigned wd[10000];

void mkwd(){
	unsigned v='0000';
	long i=0;
	rep(a,10){
		rep(b,10){
			rep(c,10){
				rep(d,10){
					wd[i++]=v;
					v+=1<<24;
				}
				v+=(1<<16)-(10<<24);
			}
			v+=(1<<8)-(10<<16);
		}
		v+=(1<<0)-(10<<8);
	}
}

void mkt(){
	ulong x=1;
	rep(i,200001){
		t[i]=x;
		x=x*(MD+1>>1)%MD;
	}
}

int main(){
	mkwd();
	mkt();
	char*rp=getrp();
	long n=rd();
	rd_skip();
	{
		ulong m=0;
		a[0]=~0ull;
		rep3(i,1,n+1){
			ulong x=rd();
			a[i]=x;
			if(x<=a[i-1]){
				b[i]=x;
				c[i]=0;
				m=1;
			}else{
				b[i]=(b[i-1]+x*m)%MD;
				c[i]=c[i-1]+1;
				m=aaa(m*2);
			}
		}
	}
	char*wp=wbuf;
	while(*rp){
		ulong l=rd()-1;
		ulong r=rd();
		unsigned z;
		if(r-l==c[r]-c[l]){
			z=(aas((int)(b[r]-b[l+1]))*t[c[l+1]]+a[l+1])%MD;
		}else{
			z=b[r];
		}
		if(z>=100000000){
			*wp++=z/100000000+'0';
			z%=100000000;
			*(int*)wp=wd[z/10000];
			wp+=4;
			*(int*)wp=wd[z%10000];
			wp+=4;
		}else{
			long n=0;
			ulong d=0;
			while(++n,d=d<<8|0x30|z%10,z/=10);
			*(ulong*)wp=d;
			wp+=n;
		}
		*wp++='\n';
	}
	write(1,wbuf,wp-wbuf);
	_exit(0);
}
0