New Ket Network _2018 Year National multi-school algorithm winter training Camp practice Competition (first game) _ part of the puzzle

Source: Internet
Author: User
Tags cmath

~__~ spent half an hour of water humorous, will investigate to see.

Competition Home > A prosperous, eat chicken tonight-firearms articles > 21035827

In the Jedi survival (eat chicken) game, different guns have different powers and can be paired with different accessories to improve the performance of firearms.

Every gun has its power and the type of accessories it can equip. Each accessory has its own type, which can be added as a percentage of the gun's power. Each gun can only be equipped with one of the same accessories. Here you are. N Guns and M accessories, the power of the gun for P, the number of accessories can be equipped with k, for k different types of accessories, the same kind of accessories can only be equipped with one. The accessory type is represented by the digital Q, and the accessory power is added with a fractional B. Please pick a gun and pair it with accessories to make it the most powerful.

Assuming the power of a gun is P, the power of the assembled K-Accessories is bi, then the gun's last power w=p* (1+B1+B2+...+BK).

Topic Idea: Enumerate all the accessories and only count the maximum damage that can be provided for each type of accessory, and then enumerate each type of firearm in turn.
1 the submitted code2 3Submission Time:2018- on- +Language: C + + Run Time: AboutMS Occupied Memory: 3556K Status: Correct answer4 5#include <cstdio>6#include <iostream>//7#include <cmath>8#include <algorithm>9#include <queue>Ten#include <cstring>//18:58 One using namespacestd; A #definell Long Long - structGun - { the     DoublePower//Maximum damage of G "I" -     intvt//Number of accessories -     intv[1001]; -}g[1001]; + structsub{ -     DoubleMaxx; +} sub[1010];//accessory Structure, Sub[i].maxx represents the maximum damage bonus that can be provided by the part I model accessories A BOOLCMP (gun A,gun b) { at     returnA.power>B.power; - } - intMain () { -   -     intN,m,t;DoubleK; -      while(SCANF ("%d%d", &n,&m)! =EOF) { in          for(intI=1; i<=n;i++){ -         toscanf"%lf%d",&g[i].power,&g[i].vt); +              for(intj=1; j<=g[i].vt;j++){ -scanf"%d", &g[i].v[j]);//Some accessories array the             } *         } $          for(intI=1; i<= +; i++){Panax Notoginsengsub[i].maxx=0.0; -         } the          for(intI=1; i<=m;i++) {//update the maximum value per read-in data +scanf"%D%LF",&t,&k); ASub[t].maxx=sub[t].maxx>k?sub[t].maxx:k; the         } +  -          for(intI=1; i<=n;i++) {//Each firearm is updated $                 Doublemm=0; $              for(intj=1; j<= g[i].vt;j++)//Enumerate accessories for each model -mm+=Sub[g[i].v[j]].maxx; -G[i].power=g[i].power* (1.0+mm); the         } - WuyiSort (g+1, g+1+N,CMP);//reverse Order theprintf"%.4lf\n", g[1].power); -     } Wu   -   About     return 0; $}
View CodeCompetition Home >I Find number > 21031579

Lulu likes a positive integer less than or equal to 1000, but if a number is a multiple of a or B, Lulu hates the number. If a number contains the numbers contained in a and b two numbers, Lulu is also annoying. (for example, a=14,b=23, if the number contains any of the four numbers of 1, 2, 3, 4, Lulu will hate this number). Now tell you a, B, you can tell how many Lulu like the number.

Topic Analysis: Water problem. @ Crazy Lei idea: You can take the initiative to heavy, the first time for (1-"1000) to remove multiples of a and a multiple of B, the second pass for (1-1000) to remove the number of a and B, and then output the total number of the remaining-so the complexity is generally lower than my thinking (in extreme cases). Try it yourself.
1 the submitted code2 3Submission Time:2018- on- +Language: C + + Run Time:6MS Occupied Memory: 484K Status: Correct answer4 5#include <cstdio>6#include <iostream>//7#include <cmath>8#include <algorithm>9#include <queue>Ten#include <cstring>//18:58 One using namespacestd; A #definell Long Long - intFactintIintAintb) - { the     intJ; -     intvis1[Ten]={0},vis2[Ten]={0}; -      while(i>0){ -vis1[i%Ten]=1; i/=Ten; +     } -      while(a>0){ +vis2[a%Ten]=1; a/=Ten; A     } at      while(b>0){ -vis2[b%Ten]=1; b/=Ten; -     } -      for(j=0; j<=9; j + +){ -         if(vis1[j]==vis2[j]&&Vis2[j]) { -             return 1; in         } -     } to     return 0; + } - intMain () the { *     intt,a,b,sum; $scanf"%d",&T);Panax Notoginsengsum=0; -      while(t--){ thescanf"%d%d",&a,&b); +sum= +; A          for(intI=1; i<= +; i++){ the                             //A concise idea, once for loop: remove multiples of a and B each time, and then write a function to determine if A and B's own numbers are included +             if(i%a==0|| i%b==0||fact (I,A,B)) { -sum--; $             } $         } -printf"%d\n", sum); -     } the   -     return 0;Wuyi}
View CodeCompetition Home >H block with storage box > 21030126

Now there is a storage box of size n*1, we have countless small squares of size 1*1 and 2*1, we need to fill the box with these blocks, how many different ways we fill this storage box.

Topic Analysis: Basic one-dimensional DP; Assuming the length is n, the state transfer equation is dp[i]=dp[i-1]+dp[i-2]; That is, the length of the n block is a n-1 block plus a piece of a spell or n-2 block plus two pieces of the spell. or self-analysis, from 1 dozen to 10 can find the rule.

  

#include <cstdio>#include<iostream>//#include <cmath>#include<algorithm>#include<queue>#include<cstring>//18:58using namespacestd;#definell Long LongintMain () {ll dp[ -]; dp[0]=1;DP [1]=1;  for(intI=2; i<= the; i++) {Dp[i]=dp[i-1]+dp[i-2]; }      intt,d; scanf ("%d",&T);  while(t--) {scanf ("%d",&d); printf ("%lld\n", Dp[d]); }     return 0;}
View Code

New Ket Network _2018 Year National multi-school algorithm winter training Camp practice Competition (first game) _ part of the puzzle

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.