Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- * File: main.c
- * Author: Pablo
- *
- * Created on 20 de junio de 2014, 09:32 PM
- */
- #include <stdio.h>
- #include <stdlib.h>
- #define MAX 10000
- int max(int a,int b){
- if(a>b)
- return a;
- else
- return b;
- }
- int min(int a, int b){
- if(a<b)
- return a;
- else
- return b;
- }
- void llenarTabla(int A[MAX][2],int ini,int fin,int t){
- int i,j,k;
- for (i=0;i<ini;i++){
- A[i][0]=0;
- A[i][1]=i;
- }
- for(j=ini;j<fin;j++){
- A[j][0]= A[j-ini][0]+ 1;
- A[j][1]= A[j-ini][1];
- }
- if (fin % ini != 0){
- A[fin][0]= 1;
- A[fin][1]= 0;
- }
- int bandera = 1;
- for(k=fin+1;k<=t;k++){
- int m = k;
- if (m % ini != 0 && m % fin == 0 && bandera){
- A[k][0] = 2;
- A[k][1]= 0;
- bandera = 0;
- }else{
- A[k][0]= max(A[k-ini][0]+1,A[k-fin][0]+1);
- A[k][1]= min(A[k-ini][1],A[k-fin][1]);
- }
- }
- }
- /*
- *
- */
- int main(int argc, char** argv) {
- int m,n,t;
- int min,max;
- int A[MAX][2];
- while(scanf("%d %d %d",&m,&n,&t) != EOF){
- if (m>n){
- min = n;
- max = m;
- }else{
- min = m;
- max = n;
- }
- llenarTabla(A,min,max,t);
- if (A[t][1] != 0){
- printf("%d %d\n",A[t][0],A[t][1]);
- }else{
- printf("%d\n",A[t][0]);
- }
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement