Submission #5021992


Source Code Expand

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <time.h>

#define _CRT_SECURE_NO_WARNINGS
#define TLong long long
#define TBMod 1000000007

// fact(n)
int fact(int n){
	if(n == 1)	return 1;
	else return (n * fact(n - 1));
}

// nCr(n,r)
int nCr(int n, int r){
	if(r == 0 || r == n)	return 1;
	else if(r == 1)	return n;
	return (nCr(n - 1, r - 1) + nCr(n - 1, r));
}

int gcd(int a,int b){
	if(!(a % b)) return b;
	return gcd(b,a % b);
}

// lcm(a.b)
int lcm(int a,int b){
	return (a * b) / gcd(a,b);
}

// qsort(array, size, sizeof(int),comp);
int comp(const int *a,const int *b){
	return (*a - *b);
}

// append(array,*size,addNum)
void append(int *array,int *size,int num){
	realloc(array, sizeof(int) * (*size + 1));
	array[(*size)] = num;
	++(*size);
}

// pop(array,*size) & nongetpop(array,*size)
int pop(int *array,int *size){
	int temp = array[(*size - 1)];
	nongetpop(array,&(*size));
	return temp;
}

int nongetpop(int *array,int *size){
	realloc(array,sizeof(int) * (*size - 1));
	--(*size);
}

int main(int argc, char const *argv[])
{
	TLong n,y;
	TLong k;
	scanf("%lld%lld",&n,&y);

	for (TLong i = 0; i <= y / 10000; ++i)
	{
		for (TLong j = 0; j <= y / 5000; ++j)
		{
			k = n - (i + j);
			if(10000 * i + 5000 * j + 1000 * k == y && i + j + k == n){
				printf("%d %d %d\n", i,j,k);
				return 0;
			}
		}
	}
	puts("-1 -1 -1");
	return 0;
}

Submission Info

Submission Time
Task A - Already 2018
User herp_sy
Language C (GCC 5.4.1)
Score 0
Code Size 1472 Byte
Status WA
Exec Time 2 ms
Memory 128 KB

Compile Error

./Main.c: In function ‘pop’:
./Main.c:49:2: warning: implicit declaration of function ‘nongetpop’ [-Wimplicit-function-declaration]
  nongetpop(array,&(*size));
  ^
./Main.c: In function ‘main’:
./Main.c:70:12: warning: format ‘%d’ expects argument of type ‘int’, but argument 2 has type ‘long long int’ [-Wformat=]
     printf("%d %d %d\n", i,j,k);
            ^
./Main.c:70:12: warning: format ‘%d’ expects argument of type ‘int’, but argument 3 has type ‘long long int’ [-Wformat=]
./Main.c:70:12: warning: format ‘%d’ expects argument of type ‘int’, but argument 4 has type ‘long long int’ [-Wformat=]
./Main.c: In function ‘append’:
./Main.c:41:2: warning: ignoring return value of ‘realloc’, declared with attribute warn_unused_result [-Wunused-result]
  realloc(array, sizeof(int) * (*size + 1));
  ^
./Main.c: In function ‘nongetpop’:
./Main.c:54:2: warning: ignoring return value of ‘realloc’, declared with attribute warn_unused_result [-Wunused-result]
  realloc(array,sizeof(int) * (*size - 1));
  ^
./Main.c...

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 0 / 100
Status
WA × 2
WA × 8
Set Name Test Cases
Sample a01, a02
All a01, a02, b03, b04, b05, b06, b07, b08
Case Name Status Exec Time Memory
a01 WA 1 ms 128 KB
a02 WA 1 ms 128 KB
b03 WA 2 ms 128 KB
b04 WA 1 ms 128 KB
b05 WA 1 ms 128 KB
b06 WA 1 ms 128 KB
b07 WA 1 ms 128 KB
b08 WA 1 ms 128 KB