結果

問題 No.1161 Many Powers
ユーザー tailstails
提出日時 2020-11-18 20:01:00
言語 C
(gcc 12.3.0)
結果
AC  
実行時間 13 ms / 2,000 ms
コード長 882 bytes
コンパイル時間 130 ms
コンパイル使用メモリ 30,468 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-09-30 15:10:16
合計ジャッジ時間 1,270 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

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

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

int w[100001];

main(){
	char rbuf[64];
	read(0,rbuf,sizeof rbuf);
	char*rp=rbuf;
	RDL(a);
	RDL(b);
	RDL(c);
	{
		long p=c/(c&-c);
		long e=p;
		long i=3;
		while(e>1){
			if(e%i==0){
				p-=p/i;
				while(e%i==0){
					e/=i;
				}
			}
			i+=2;
			if(i*i>e){
				i=e;
			}
		}
		if(b>=p){
			b=b%p+p;
		}
	}
	long z=0,y=0;
	long ac=a%c;
	for(long i=1;i<=c;++i){
		long x;
		if((i&1)==0&&i!=2){
			x=(long)w[2]*w[i/2]%c;
		}else if((int)i%3==0&&i!=3){
			x=(long)w[3]*w[i/3]%c;
		}else{
			x=1;
			long e=i;
			long d=b;
			while(d){
				if(d&1){
					x=x*e%c;
				}
				d>>=1;
				e=e*e%c;
			}
		}
		w[i]=x;
		y+=x;
		if(i==ac){
			z=y;
		}
	}
	z+=a/c*y;
	z=z%c;

	{
		long n=0,d=0;
		while(++n,d=d<<8|0x30|z%10,z/=10);
		write(1,&d,n);
	}
	_exit(0);
}
0