結果

問題 No.1161 Many Powers
ユーザー tailstails
提出日時 2020-11-18 18:54:03
言語 C
(gcc 12.3.0)
結果
AC  
実行時間 32 ms / 2,000 ms
コード長 723 bytes
コンパイル時間 682 ms
コンパイル使用メモリ 29,960 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-09-30 15:09:38
合計ジャッジ時間 1,797 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

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

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=0;i<c;){
		long e=i+1;
		long x=1;
		long d=b;
		while(d){
			if(d&1){
				x=x*e%c;
			}
			d>>=1;
			e=e*e%c;
		}
		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