Prizes seen on tv canada for resource sharing Bowen connotation June recommended articles summarized Microsoft Azure Programming Contest questions concern hero CSDN community micro-letters, a lot of community welfare Q & A: Ye Jinfeng game engine architecture seen on tv canada describes the elements of a square matrix of order n is 1, 2,. .., and equal to n ^ 2, that each row, each column and the two elements on the diagonal, so that the square is called Cube. n is odd we have one kind of construction method, called "the upper right," such as when n = 3,5,7 given cube below 3 8 1 6,357,492,517,241,815,235 7,141,646,132,022,101,219 21 3,111,825,297,303,948,110 19 28 38 47 7 9,182,729,466,817,263,537 5,141,625,343,645,131,524 334,244,421,233,241 4,331,222,314,049,211 20 lines in the middle of the first number is always 1, the last line is the middle number n ^ 2, his right is 2, from the three cube You can see "at the top right" is what is intended.
# Include <stdio.h> # include <string.h> int main () {int i, j, n, m, a [20] [20], vis [20] [20], ans; scanf ("% d ", & m); while (m -) {scanf ("% d ", & n); memset (a, 0, sizeof (a)); memset (vis, 0, sizeof (vis)); i = 1 ;/ * 1 is always the first line * / j = (n +1) / 2 ;/ * intermediate that number * / ans = 1 ;/ * record from 1 * / while (ans <= n * n) / * 1 -> n ^ 2 * / {a [i] [j] = ans ;/ * record the current position value * / vis [i] [j] = 1; / * Record the current position to update * / if (i == 1 && j = n!) / * the first line is not the last row * / {i = n; / * last row * / j = j +1; / * behind a row * /} else if (j == n && i ! = 1) / * Last but not the first column * / {i = i-1; j = 1; / * first column of the line * /} else if (j! = n && vis [i-1]! [j +1]) / * update the value of the upper right corner seen on tv canada * / {i = i-1; j = j +1; / * right corner * /}! else if (i! = n && j = n && vis [i-1] [j +1]) / * upper right corner has been updated * / i = i +1; / * skip to the next line of the same column * / else if (i == 1 && j == n) / * upper right corner * / i = i +1; / * Skip to the same column of the next line * / ans + +;} for (i = 1; i <= n; i + +) {for (j = 1; j <= n; j + +) printf ("% 4d", a [i] [j]); printf ("\ n");}} return 0;}
All topics Hadoop AWS mobile games Java Android iOS Swift intelligent hardware Docker OpenStack VPN Spark ERP IE10 Eclipse CRM JavaScript database Ubuntu NFC WAP jQuery BI HTML5 Spring Apache. NET API HTML SDK IIS Fedora XML LBS Unity Splashtop UML components Windows Mobile Rails QEMU KDE Cassandra CloudStack FTC coremail OPhone CouchBase cloud iOS6 Rackspace Web App SpringSide Maemo Compuware large data aptech Perl Tornado Ruby Hibernate ThinkPHP HBase Pure Solr Angular Cloud Foundry Redis Scala Django Bootstrap
Article seen on tv canada Categories greedy algorithm (24) dynamic programming (34) Search (14) tree array (4) simple questions (25) race title (53) backpack (8) bipartite graph (3) Shortest (11) and check the set ( 7) math (31) trie (2) Number Theory (15) Computational Geometry (5) STL (14) string (10) UVA (25) study notes (9) violence (6) topological sorting (1) graph theory (7) Other (2) minimum spanning tree (2) kmp (1) matrix multiplication (3) interval dp (1) the state of compression dp (2) data structure (2)
August 2014 (7) July 2014 (20) June 2014 (1) May 2014 (4) April 2014 (31) March 2014 (14) February 2014 (16) 2014 In January (10) December 2013 (1) November 2013 (7) October 2013 (6) September 2013 (3) August 2013 (9) July 2013 (25) 2013 June (5) May 2013 (15) April 2013 (30) March 2013 (7) February 2013 (1) January 2013 (12)
Read the Top 01 classical knapsack problem completely backpack backpack + backpack + Multiple (1433) C language curriculum design - Student Management System (1428) hdu 1062 Text Reverse string (1006) hdu 1879 continues unimpeded Engineering minimum spanning tree (798) hdu The die is cast simply enumerate seen on tv canada the depth of search (596) hdu 1228-A + B (595) violence to solve Act - 1856 More is better search set (625) hdu 3496 Watch The Movie dimensional 01 backpack (606) UVA 657 (591) hdu 3033 I love sneakers! grouping backpack (566)
Comments Top NYOJ 586 mad cow & POJ 2456 (binary search + greedy) (5) NYOJ 301 recursive evaluation (matrix seen on tv canada fast power) seen on tv canada (3) Prov summary (3) hdu 2141 Can you find it? Binary search + array merge ( 2) NYOJ exercises seen on tv canada Splits the string (simple dynamic programming) (2) hdu 4901 The Romantic Hero (count dp) 2014 Multi - schools, training the first four games 1005 (1) C language curriculum design - Student Management System (1) hdu 3033 I love sneakers! grouping backpack (1) classic knapsack problem 01 backpack + backpack + multiple backpack full (1) BNUOJ 4064 barcode design (dynamic programming + recursive) (0)
ruzhuxiaogu: seen on tv canada @ LYHVOYAGE: seen on tv canada Thank you, have understood seen on tv canada NYOJ 301 recursive evaluation (matrix fast power)
No comments:
Post a Comment