結果

問題 No.1529 Constant Lcm
ユーザー tailstails
提出日時 2021-06-04 22:47:41
言語 C
(gcc 12.3.0)
結果
AC  
実行時間 7 ms / 3,000 ms
コード長 913 bytes
コンパイル時間 563 ms
コンパイル使用メモリ 29,660 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-08-12 16:12:40
合計ジャッジ時間 1,797 ms
ジャッジサーバーID
(参考情報)
judge14 / judge2
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 4 ms
4,376 KB
testcase_01 AC 5 ms
4,380 KB
testcase_02 AC 5 ms
4,380 KB
testcase_03 AC 4 ms
4,380 KB
testcase_04 AC 5 ms
4,380 KB
testcase_05 AC 5 ms
4,380 KB
testcase_06 AC 5 ms
4,376 KB
testcase_07 AC 5 ms
4,376 KB
testcase_08 AC 5 ms
4,380 KB
testcase_09 AC 5 ms
4,384 KB
testcase_10 AC 7 ms
4,376 KB
testcase_11 AC 6 ms
4,376 KB
testcase_12 AC 5 ms
4,380 KB
testcase_13 AC 7 ms
4,380 KB
testcase_14 AC 7 ms
4,380 KB
testcase_15 AC 7 ms
4,384 KB
testcase_16 AC 5 ms
4,380 KB
testcase_17 AC 5 ms
4,384 KB
testcase_18 AC 5 ms
4,380 KB
testcase_19 AC 6 ms
4,376 KB
testcase_20 AC 7 ms
4,376 KB
testcase_21 AC 7 ms
4,380 KB
testcase_22 AC 7 ms
4,376 KB
testcase_23 AC 7 ms
4,376 KB
testcase_24 AC 7 ms
4,384 KB
testcase_25 AC 7 ms
4,376 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.c:23:1: 警告: 戻り値の型をデフォルトの ‘int’ にします [-Wimplicit-int]
   23 | main(){
      | ^~~~
main.c: 関数 ‘main’ 内:
main.c:27:9: 警告: implicit declaration of function ‘read’; did you mean ‘rd’? [-Wimplicit-function-declaration]
   27 |         read(0,rbuf,sizeof rbuf);
      |         ^~~~
      |         rd
main.c:56:9: 警告: 関数 ‘write’ の暗黙的な宣言です [-Wimplicit-function-declaration]
   56 |         write(1,wp,wbuf+sizeof wbuf-wp);
      |         ^~~~~
main.c:57:9: 警告: implicit declaration of function ‘_exit’; did you mean ‘_Exit’? [-Wimplicit-function-declaration]
   57 |         _exit(0);
      |         ^~~~~
      |         _Exit

ソースコード

diff #

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

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

#define wt(v) {long _z=v;do*--wp=_z%10+48;while(_z/=10);}


#define SIEVE_N 1000001
char sieve[SIEVE_N];
void mksieve(){
	for(long i=2;i<SIEVE_N;++i){
		if(sieve[i]==0){
			for(long j=i*i;j<SIEVE_N;j+=i){
				sieve[j]=1;
			}
		}
	}
}

#define MD 998244353

main(){
	mksieve();
	
	char rbuf[64];
	read(0,rbuf,sizeof rbuf);
	char*rp=rbuf;
	rd(n);
	
	long res=1;

	for(long p=2;p<n;++p){
		if(!sieve[p]){
			if(n%p==0){
				long maxc=0;
				long j=1;
				long c0=0;
				while(j<n){
					long c=c0++;
					long nn=n-j;
					while(nn%p==0) nn/=p,++c;
					maxc=maxc>=c?maxc:c;
					j*=p;
				}
				while(maxc--) res=res*p%MD;
			}else{
				long j=1;
				while(j*=p,j<n) res=res*p%MD;
			}
		}
	}

	char wbuf[64],*wp=wbuf+sizeof wbuf;
	wt(res);
	write(1,wp,wbuf+sizeof wbuf-wp);
	_exit(0);
}
0