Submission #4301

# Submission time Handle Problem Language Result Execution time Memory
4301 2013-09-12T08:07:24 Z zorrapower Inherited disease (kriii1_I) C++
Compilation error
0 ms 0 KB
#include<stdio.h>

void get_N_generationArea(unsigned long n,unsigned long *start, unsigned long *end);
unsigned long Factorial(unsigned long n);
unsigned long getResult(unsigned long n, unsigned long *start, unsigned long *end);

unsigned long Array[100];
unsigned long n;

unsigned long main(void){
	unsigned long start,end;
	get_N_generationArea(2, &start, &end);

	scanf("%d", &n);

	for(unsigned long i=0; i<n; i++)
		scanf("%d", &Array[i]);

	for(unsigned long i=1; i<=n; i++){
		printf("%d\n", getResult(i, &start, &end)%1000000007);
	}
	return 0;
}

void get_N_generationArea(unsigned long n,unsigned long *start, unsigned long *end){
	*start=0;
	*end=0;
	for(unsigned long i=1; i<=n; i++){
		*end+=Factorial(i);
		*start=*end-Factorial(i)+1;
	}
}

unsigned long Factorial(unsigned long n){
	unsigned long result=1;
	for(unsigned long i=1; i<=n; i++)
		result*=i;
	return result;
}

unsigned long getResult(unsigned long generation, unsigned long *start, unsigned long *end){
	unsigned long area;
	get_N_generationArea(generation, start, end);
	area=*end-*start+1;
	for(unsigned long i=0; i<generation; i++){
		area/=i+1;
		*start+=area*(Array[i]-1);
		*end=*start+area-1;

	}
	return *start;
}

Compilation message

I.cpp:10:24: error: '::main' must return 'int'
I.cpp: In function 'int main()':
I.cpp:14:16: warning: format '%d' expects argument of type 'int*', but argument 2 has type 'long unsigned int*' [-Wformat]
I.cpp:17:24: warning: format '%d' expects argument of type 'int*', but argument 2 has type 'long unsigned int*' [-Wformat]
I.cpp:20:55: warning: format '%d' expects argument of type 'int', but argument 2 has type 'long unsigned int' [-Wformat]
I.cpp:14:17: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
I.cpp:17:25: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]