2015 Multi-school training 5 Puzzle and code

Source: Internet
Author: User

First of all, to talk nonsense for a while. This is one of the most common people in many schools that have ever seen. Because the English question is very short. But it is the most test of IQ (except the first ionization energy of chemistry) ...

After the game in the problem solving and the big giant of the help can fill up to 7 questions is also drunk. The description is the test model set up, no test to how deep knowledge points.


Poke me to see the official puzzle


1002:hdoj 5344

At first glance it seems to be or ah, but also mathematics ah, is not violent. The Xor of all ( a i + a j )( 1 ≤ i Span id= "MATHJAX-SPAN-17" class= "Mi" style= "font-family:mathjax_math; Font-style:italic; Padding-left:0.167em ">j ≤ n This is the key sentence. According to test instructions the need to write out, find all I! =j, can use a^a=0 elimination, all only left i==j. The final answer is (2*A1) ^ (2*A2) ^ (2*a3) ^ ..... (2*an)


Code (do not open an array to save AI):

while (t--) {scanf ("%i64d%i64d%i64d%i64d", &n,&m,&z,&l), A=ans=0;while (n--) {ans=ans^ (2*a); A= (a*m+z )%l;} printf ("%i64d\n", ans);}

1005:hdoj 5347

This online comment a lot, I just want to say: if out of the game, no Baidu no Google no wiki, how many college students still remember the first ionization energy is a what ghost ah ...

By the way, the university science Dog recalled his senior years: the first ionization energy

The important thing is that the picture inside shows a lot of characteristics, summarized as follows:

1. The larger the serial number of the same cycle the greater the first ionization energy

2. The smaller the number of the same family, the greater the first ionization energy

3. In the figure of the obvious 4 need to special, b,o,al,s ...


The details of the problem with the various if statements are good:


int A,b;int min,max;int num[]={8,18,32,16,26,36,50,34,44,68,52,76,84};bool Check (int x) {for (int i=0;i<=12;i++) if ( NUM[I]==X) return True;return false;} int main () {//input;while (scanf ("%d%d", &a,&b)!=eof) {Min=min (A, b); Max=max (A, B), if (max==5&&min==4) {if (a==4) puts ("first bigger"), Else puts ("SECOND bigger");} else if (max==8&&min==7) {if (a==7) puts ("first bigger"), Else puts ("SECOND bigger");} else if (max==13&&min==12) {if (a==12) puts ("first bigger"), Else puts ("SECOND bigger");} else if (max==16&&min==15) {if (a==15) puts ("first bigger"), Else puts ("SECOND bigger");} else if (check (max-min)) {if (a==min) puts ("first bigger"), Else puts ("SECOND bigger");} Else{if (B==min) puts ("first bigger"), Else puts ("SECOND bigger");}} return 0;}

1007:hdoj 5349

Simple problem is really easy, read the puzzle nothing to say ...

PS: Still have to learn to learn all kinds of self-created and STL data structure, according to the meaning of the topic to do


int main () {//input;while (scanf ("%d", &n)!=eof) {len=0;maxnum=-1*inf;for (i=1;i<=n;i++) {scanf ("%d", &j); if (j==1) {scanf ("%d", &k); Len++;maxnum=max (maxnum,k);} else if (j==2) {if (len) {len--;if (!len) Maxnum=-1*inf;}} else if (j==3) {if (len) printf ("%d\n", maxnum), Else printf ("0\n");}}} return 0;}

1008:hdoj 5350

Typical IQ question, if directly tell you is a Huffman the whole field certainly more than a few strong teams ac .... IQ is still more important than level, it is the detail and IQ that distinguishes the problem and the water problem.

The question of the surface of the Huffman hidden very deep, but,,, from the smaller can be seen DP thinking .... Results..... It proves it.

Using STL's priority queue implementations:


priority_queue<int,vector<int>,greater<int> > Que;int t,n,i,j,k;__int64 ans;int Main () {//input; scanf ("%d", &t), while (t--) {scanf ("%d", &n), while (!que.empty ())) Que.pop (); for (i=1;i<=n;i++) {scanf ("%d", &J); Que.push (j);} Ans=0;while (n>1) {i=que.top (); Que.pop (); J=que.top (); Que.pop (); K=i+j;ans+=k;que.push (k); n--;} printf ("%i64d\n", ans);} return 0;}

1009 Math Problem + large number: It is more convenient to use Java. I don't want anything, but we need a strong math teammate to help you in the game.


A large number is required to style the template:


Import Java.math.biginteger;import Java.util.scanner;public class Main {public static void main (String args[]) { BigInteger mod=biginteger.valueof (258280327); Biginteger[] Big;big=new biginteger[2000];big[1]=biginteger.valueof (1) big[2]=biginteger.valueof (1); for (int i=3;i <=1000;i++) Big[i]=big[i-1].add (big[i-2]); int t; BigInteger m; Scanner reader=new Scanner (system.in); T=reader.nextint (); for (int case=1; case<=t; case++) {M=reader.nextbiginteger (); M=reader.nextbiginteger (); int i,j;for (i=1;i<=1000;i++) {J=big[i].compareTo ( M.add (biginteger.valueof (1))); if (j>0) break;} System.out.println ((M.subtract (big[i-2)). MoD (mod));} Reader.close ();}}


Two questions left to thank my Goddess, Rosie Giant.

1006:hdoj 5348

The Goddess takes you to fly


1010:hdoj 5352

The Goddess takes you to fly



Every time you finish writing, it's nonsense:

1. Take a look at the question or be careful. Maybe others feel trouble, you understand the inside of the routine to know is a water problem

2. Mathematics is still very important.

3.Java large number is useful

Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.

2015 Multi-school training 5 Puzzle and code

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.