AtCoder Beginner Contest 021

Submission #2532136

Source codeソースコード

#include <stack>
#include <queue>
#include <cstdio>
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <math.h>
#include <string>
 
using namespace std;

#define rep(i,n) for(int i=0;i<n;i++)
#define Rep(i,n0,n) for(int i=n0;i<n;i++)
#define Com(i,j,n) for(int i=0;i<n-1;i++)for(int j=i+1;j<n;j++)
#define INF (1<<29)
#define test cout << "test" << endl;

long int MOD = 1000000007;

long int gyaku(long int a){
	int bits[33]={0};
	long int beki[33];
	long int bi=MOD-2;
	beki[0]=a;
	rep(i,32){
		beki[i+1] = (beki[i] * beki[i])%MOD;
	}
	rep(i,32){
		bits[i]=bi%2;
		bi = (bi-bits[i])/2;
	}
	long int ret=1;
	rep(i,32){
		if(bits[i]==1){
			ret = (ret * beki[i])%MOD;
		}
	}
	return ret%MOD;
}

long int bikkuri(long int a){
	return (a==1 || a==0)? 1:((bikkuri(a-1)*a)%MOD);
}

int main (){
	long int NNN,KKK;
	cin >> NNN >> KKK;
	long int n1k=bikkuri(NNN-1+KKK)%MOD;
	long int n1 =bikkuri(NNN-1)%MOD;
	long int ke =bikkuri(KKK)%MOD;
	long int n1ke = (n1*ke)%MOD;
	long int ans = (n1k * gyaku(n1ke))%MOD;

	cout << ans << endl;
	
	return 0;
}

Submission

Task問題 D - 多重ループ
User nameユーザ名 K_Karen
Created time投稿日時
Language言語 C++14 (GCC 5.4.1)
Status状態 AC
Score得点 100
Source lengthソースコード長 1118 Byte
File nameファイル名
Exec time実行時間 9 ms
Memory usageメモリ使用量 3328 KB

Test case

Set

Set name Score得点 / Max score Cases
Sample - subtask0_sample_01.txt,subtask0_sample_02.txt,subtask0_sample_03.txt,subtask0_sample_04.txt,subtask0_sample_05.txt
Subtask1 99 / 99 subtask0_sample_01.txt,subtask0_sample_02.txt,subtask0_sample_03.txt,subtask0_sample_04.txt,subtask1_01.txt,subtask1_02.txt,subtask1_03.txt,subtask1_04.txt,subtask1_05.txt,subtask1_06.txt,subtask1_07.txt,subtask1_08.txt,subtask1_09.txt,subtask1_10.txt,subtask1_11.txt,subtask1_12.txt,subtask1_13.txt,subtask1_14.txt,subtask1_15.txt,subtask1_16.txt,subtask1_17.txt,subtask1_18.txt,subtask1_19.txt
All 1 / 1 subtask0_sample_01.txt,subtask0_sample_02.txt,subtask0_sample_03.txt,subtask0_sample_04.txt,subtask0_sample_05.txt,subtask1_01.txt,subtask1_02.txt,subtask1_03.txt,subtask1_04.txt,subtask1_05.txt,subtask1_06.txt,subtask1_07.txt,subtask1_08.txt,subtask1_09.txt,subtask1_10.txt,subtask1_11.txt,subtask1_12.txt,subtask1_13.txt,subtask1_14.txt,subtask1_15.txt,subtask1_16.txt,subtask1_17.txt,subtask1_18.txt,subtask1_19.txt,subtask2_02.txt,subtask2_03.txt,subtask2_04.txt,subtask2_05.txt,subtask2_06.txt,subtask2_07.txt,subtask2_08.txt,subtask2_09.txt,subtask2_10.txt

Test case

Case name Status状態 Exec time実行時間 Memory usageメモリ使用量
subtask0_sample_01.txt AC 1 ms 256 KB
subtask0_sample_02.txt AC 1 ms 256 KB
subtask0_sample_03.txt AC 1 ms 256 KB
subtask0_sample_04.txt AC 1 ms 256 KB
subtask0_sample_05.txt AC 9 ms 3328 KB
subtask1_01.txt AC 1 ms 256 KB
subtask1_02.txt AC 1 ms 256 KB
subtask1_03.txt AC 1 ms 256 KB
subtask1_04.txt AC 1 ms 256 KB
subtask1_05.txt AC 1 ms 256 KB
subtask1_06.txt AC 1 ms 256 KB
subtask1_07.txt AC 1 ms 256 KB
subtask1_08.txt AC 1 ms 256 KB
subtask1_09.txt AC 1 ms 256 KB
subtask1_10.txt AC 1 ms 256 KB
subtask1_11.txt AC 1 ms 256 KB
subtask1_12.txt AC 1 ms 256 KB
subtask1_13.txt AC 1 ms 256 KB
subtask1_14.txt AC 1 ms 256 KB
subtask1_15.txt AC 1 ms 256 KB
subtask1_16.txt AC 1 ms 256 KB
subtask1_17.txt AC 1 ms 256 KB
subtask1_18.txt AC 1 ms 256 KB
subtask1_19.txt AC 1 ms 256 KB
subtask2_02.txt AC 4 ms 1408 KB
subtask2_03.txt AC 6 ms 2304 KB
subtask2_04.txt AC 3 ms 1152 KB
subtask2_05.txt AC 7 ms 2688 KB
subtask2_06.txt AC 2 ms 768 KB
subtask2_07.txt AC 5 ms 1792 KB
subtask2_08.txt AC 7 ms 2560 KB
subtask2_09.txt AC 5 ms 1792 KB
subtask2_10.txt AC 9 ms 3328 KB