Results 1 to 11 of 11

Thread: -

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Registered User
    Join Date: Jul:2009
    Location: Bulgaria
    Posts: 848

    -

    , . . 35 9 25 (35-25)9 = 90( , ) . : 1 - 1 000 000 1 - 1000 - 1 - ( - 1).
    :
    3 1
    20 1
    30 1
    40 1
    , 3 , 1 , . 30 1(40-20)+1(30-20)=30. :
    7 3
    9 15
    12 16
    16 13
    18 13
    31 11
    32 1
    36 9
    3 , . , . ( )/( ) - , - . ?
    Last edited by atom3; 17th March 2017 at 17:10.
    Alienware 17 R4, i7-6700hq, gtx-1060 OC, 16gb ddr4 2667 ram 256gb NVMe SSD, LSP, MMS, GPRS, UPS, FedEx, ZDR, kopr?, asl, W2F, ... .

  2. #2
    Registered User
    Join Date: Jan:2005
    Location: BG
    Posts: 4,903
    - 1 - ( - 1).
    - - ?
    , , ... ...

  3. #3
    Registered User
    Join Date: Jul:2009
    Location: Bulgaria
    Posts: 848
    Quote Originally Posted by flancer View Post
    - - ?
    , - . - . Java .
    Code:
    Scanner in = new Scanner(System.in);
            int n = in.nextInt();
            int k = in.nextInt();
            int allStacks[][] = new int[n][n];
            int max = 0;
            int h = 0;
            int w = 0;
            int allStones[][] = new int [n][2];
           
            for(int i = 0; i<n; i++){
                 int height = in.nextInt();
                int weight = in.nextInt();
                 allStones[i][0] = height;
                 allStones[i][1] = weight;
            }
            int minH = allStones[0][1]
    
            for(int i = n-1; i>=0; i--){
             allStones[i][0] = h;
             allStones[i][1] = w;
             max += (h-minH)*w;   
           }
          int break1 = max/k;
    , , . n , k - , allStones . allStacks break1( - - ) ... . allStacks , - .
    Last edited by atom3; 17th March 2017 at 14:52.
    Alienware 17 R4, i7-6700hq, gtx-1060 OC, 16gb ddr4 2667 ram 256gb NVMe SSD, LSP, MMS, GPRS, UPS, FedEx, ZDR, kopr?, asl, W2F, ... .

  4. #4
    Registered User
    Join Date: Oct:2011
    Location:
    Posts: 430
    https://ideone.com/im9mxw


    #include <stdio.h>

    int main(void) {
    int x;
    for(; scanf("%d",&x) > 0 && x != 42; printf("%d\n", x));


    int numb_stones = 7;
    int numb_piles = 3;
    long total_combination_number;
    volatile int first_pile_price=0;
    volatile int second_pile_price=0;
    volatile int third_pile_price=0;
    int flg_frf;
    volatile int i,j,n,kk=1;
    volatile int p1,p2,p3;
    int jkl;
    int total_pile_price[100];

    //--------
    const int a_data[7][2] = {
    {9, 15},
    {12, 16},
    {16, 13},
    {18, 13},
    {31, 11},
    {32, 1},
    {36, 9} };
    //----


    if(flg_frf==0)
    {
    flg_frf=1;


    for(i=0;i<numb_stones-numb_piles+1;i++)
    {

    for(j=i+1;j<numb_stones-numb_piles+2;j++)
    {
    for(n=j+1+1;n<numb_stones-numb_piles+3;n++)
    {
    third_pile_price += a_data[n][1];
    }
    ///obrabotka na informaciqta
    total_pile_price[kk] = third_pile_price + second_pile_price + first_pile_price;
    x = total_pile_price[kk];
    printf("%d\n", x);

    if(total_pile_price[kk]<total_pile_price[kk-1])
    {

    p1 = i;
    p2 = j;
    p3 = j+1;
    }
    kk++;
    ///



    third_pile_price = 0;
    second_pile_price += a_data[j][1];
    }
    second_pile_price = 0;
    first_pile_price += a_data[i][1];

    }



    }



    return 0;
    }

    - - - - - -

    3. .
    . . 1 2 &#224;

    34

    ::::::::
    https://ideone.com/0Qy7xD

    - - - - - -

    https://ideone.com/SDvmeu
    Last edited by NICHIRENSHU; 17th March 2017 at 21:57.
    . - , -

  5. #5
    Registered User
    Join Date: Jul:2009
    Location: Bulgaria
    Posts: 848
    , C# C ? - ,
    Code:
    for(; scanf("%d",&x) > 0 && x != 42; printf("%d\n", x));
    Code:
    if(flg_frf==0)
    {
    flg_frf=1;
    , 1 - 1000 1 - ( - 1) - .
    Last edited by atom3; 18th March 2017 at 00:25.
    Alienware 17 R4, i7-6700hq, gtx-1060 OC, 16gb ddr4 2667 ram 256gb NVMe SSD, LSP, MMS, GPRS, UPS, FedEx, ZDR, kopr?, asl, W2F, ... .

  6. #6
    Registered User
    Join Date: Oct:2011
    Location:
    Posts: 430
    Last edited by NICHIRENSHU; 18th March 2017 at 10:31.
    . - , -

  7. #7
    Registered User
    Join Date: Oct:2011
    Location:
    Posts: 430
    Quote Originally Posted by atom3 View Post
    , C# C ? - ,
    Code:
    for(; scanf("%d",&x) > 0 && x != 42; printf("%d\n", x));
    Code:
    if(flg_frf==0)
    {
    flg_frf=1;
    , 1 - 1000 1 - ( - 1) - .


    https://ideone.com/Rp4ReF


    Code:
    #include <stdio.h>
    
    
    	int x;
    
    //--------
    const int a_data[7][2] = {
    {9, 15},
    {12, 16},
    {16, 13},
    {18, 13},
    {31, 11},
    {32, 1},
    {36, 9} };
    
    #define PILES_LIMIT 10
    #define ROWS_LIMIT 10//(STONES)
    #define NUMBER_OF_STONES 7
    #define NUMBER_OF_PILES 3
    
    
    int flg_finished;
    int lvl;
    int piles_cnt[PILES_LIMIT];
    int price_pile[PILES_LIMIT];
    int l;
    int total_pile_price[100];//da se uvelichat spored broq kamuni
    int kk;
    int min_price = 9999;// da se uvelichato spored broq kamuni
    int pile_position[PILES_LIMIT];
    
    void manamana(int number_stones,int  number_piles)
    {
    
    	while(flg_finished==0)
    	{
    		// add the next price to the current pile
    		if(lvl != 0){price_pile[lvl] += a_data[piles_cnt[lvl]][1]*(a_data[piles_cnt[lvl]][0]-a_data[piles_cnt[lvl-1]][0]);}
    		else		{price_pile[lvl] += a_data[piles_cnt[lvl]][1]*(a_data[piles_cnt[lvl]][0]-a_data[0][0]);}
    
    			
    
    		if(piles_cnt[lvl] < (number_stones - number_piles + lvl + 1) )//if this is not the  current level maximum
    		{
    			piles_cnt[lvl]++;//increase the current level cnt
    			if(lvl < number_piles - 1)//if this is not the max level go to the next level
    			{
    				lvl++;
    				piles_cnt[lvl] = piles_cnt[lvl-1];//the next level cnt starts from this level cnt 
    			}
    			else//stay at this level
    			{
    				if(piles_cnt[lvl] == (number_stones - number_piles + lvl + 1) )//if this is the last max calculate total price
    				{
    					for(l=0;l<NUMBER_OF_PILES;l++){total_pile_price[kk] += price_pile[l];}//get the total price
    						x  = total_pile_price[kk];
    						printf("%d\n", x);
    					if(min_price > total_pile_price[kk])
    					{
    						min_price = total_pile_price[kk];
    						for(l=0;l<NUMBER_OF_PILES;l++)
    						{
    							pile_position[l+1] = piles_cnt[l]+1;
    						}
    						pile_position[0] = 1;
    					}
    					
    					kk++;
    				}
    				 
    			}
    		}
    		else//if the current level maximum is reached go one level below
    		{
    			if(lvl != 0)
    			{
    				price_pile[lvl] = 0;//clearing the current level price
    				lvl--;// go one level bellow
    			}
    			else {flg_finished = 1;}
    		}
    
    	}
    lvl = 9000;
    }
    
    int main(void) { 
    
    manamana(NUMBER_OF_STONES,NUMBER_OF_PILES);
    
    printf("min_price:");
    printf("%d\n", min_price);
    
    for(l=0;l<NUMBER_OF_PILES;l++)
    {
    	printf("%d\n", pile_position[l] );
    }
    	return 0;
    }
    Last edited by NICHIRENSHU; 21st March 2017 at 12:06.
    . - , -

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

Copyright © 1999-2011 . .
iskamPC.com | mobility.BG | Bloody's Techblog | | 3D Vision Blog |