AtCoder Regular Contest 004

Submission #1572991

Source codeソースコード

#include<stdio.h>
int mbk(long long a,int n,int m){return n?(mbk((a*a)%m,n/2,m)*(n%2?a:1))%m:1;}
int inv(int a,int m){return mbk((long long)a,m-2,m);}
int aCb(int a,int b,int m){
  long long s=1,i;
  if(b>a-b)b=a-b;
  for(i=0;i<b;i++)s=(((s*(a-i))%m)*inv(i+1,m))%m;  
  return (int)s;
}
int main(){
	long long n,m,i,j,s=1,M=1e9+7;
	scanf("%lld %lld",&n,&m);
	m--;
	if(n<0)n=-n;
	for(i=2;i*i<=n;i++){
		for(j=0;n%i==0;j++)n/=i;
		s=s*aCb(j+m,m,M)%M;
	}
	if(n-1)s=s*(m+1)%M;
	printf("%lld\n",(s*mbk(2,m,M))%M);
	return 0;
}

Submission

Task問題 D - 表現の自由 ( Freedom of expression )
User nameユーザ名 T.M
Created time投稿日時
Language言語 C (GCC 5.4.1)
Status状態 AC
Score得点 100
Source lengthソースコード長 542 Byte
File nameファイル名
Exec time実行時間 1 ms
Memory usageメモリ使用量 128 KB

Compiler messageコンパイルメッセージ

./Main.c: In function ‘main’:
./Main.c:12:2: warning: ignoring return value of ‘scanf’, declared with attribute warn_unused_result [-Wunused-result]
scanf("%lld %lld",&n,&m);
^

Test case

Set

Set name Score得点 / Max score Cases
All 100 / 100 00_max.txt,00_max2.txt,00_max3.txt,00_min.txt,00_sample_01.txt,00_sample_02.txt,00_sample_03.txt,00_sample_04.txt,01_rnd_00.txt,01_rnd_01.txt,01_rnd_02.txt,01_rnd_03.txt,01_rnd_04.txt,01_rnd_05.txt,01_rnd_06.txt,01_rnd_07.txt,01_rnd_08.txt,01_rnd_09.txt,01_rnd_10.txt,01_rnd_11.txt,01_rnd_12.txt,01_rnd_13.txt,01_rnd_14.txt,01_rnd_15.txt,01_rnd_16.txt,01_rnd_17.txt,01_rnd_18.txt,01_rnd_19.txt,01_rnd_20.txt,01_rnd_21.txt,01_rnd_22.txt,01_rnd_23.txt,01_rnd_24.txt,01_rnd_25.txt,01_rnd_26.txt,01_rnd_27.txt,01_rnd_28.txt,01_rnd_29.txt,04_primes_01.txt,04_primes_02.txt

Test case

Case name Status状態 Exec time実行時間 Memory usageメモリ使用量
00_max.txt AC
00_max2.txt AC
00_max3.txt AC 1 ms 128 KB
00_min.txt AC
00_sample_01.txt AC 1 ms 128 KB
00_sample_02.txt AC 1 ms 128 KB
00_sample_03.txt AC
00_sample_04.txt AC
01_rnd_00.txt AC
01_rnd_01.txt AC 1 ms 128 KB
01_rnd_02.txt AC 1 ms 128 KB
01_rnd_03.txt AC 1 ms 128 KB
01_rnd_04.txt AC
01_rnd_05.txt AC
01_rnd_06.txt AC 1 ms 128 KB
01_rnd_07.txt AC 1 ms 128 KB
01_rnd_08.txt AC
01_rnd_09.txt AC 1 ms 128 KB
01_rnd_10.txt AC
01_rnd_11.txt AC
01_rnd_12.txt AC
01_rnd_13.txt AC 1 ms 128 KB
01_rnd_14.txt AC
01_rnd_15.txt AC 1 ms 128 KB
01_rnd_16.txt AC
01_rnd_17.txt AC 1 ms 128 KB
01_rnd_18.txt AC 1 ms 128 KB
01_rnd_19.txt AC
01_rnd_20.txt AC 1 ms 128 KB
01_rnd_21.txt AC
01_rnd_22.txt AC 1 ms 128 KB
01_rnd_23.txt AC 1 ms 128 KB
01_rnd_24.txt AC 1 ms 128 KB
01_rnd_25.txt AC 1 ms 128 KB
01_rnd_26.txt AC
01_rnd_27.txt AC 1 ms 128 KB
01_rnd_28.txt AC
01_rnd_29.txt AC
04_primes_01.txt AC 1 ms 128 KB
04_primes_02.txt AC 1 ms 128 KB