HDU 1407 1248 Violent enumeration

Source: Internet
Author: User

Background: old age, did so long to forget the EOF to the end of the document,

Experience: Be sure to debug yourself, until you feel that all the situation is considered or WA again with the help of the network.

Learning: 1. This is entitled reduction of Time to all m tables, then check the table.

#include <stdio.h>int main (void) {         int num, x, y, Z;while (scanf ("%d", &num)!=eof) {for (int i = 1; i*i <= nu M i++) {for (int j = i, J*j <= num; j + +) {for (int k = j; k *k<= num; k++) {if (i*i + j*j + k*k = num) {x = I;y = J;z = k ; goto L1;}}}    L1:     printf ("%d%d%d\n", X, Y, z);}      
HDU 1248

Study: 1. It seems that the great God is solved by DP

#include <stdio.h>int main () {int t;scanf ("%d", &t), while (t--) {int. m, min = 10000000;scanf ("%d", &m); for ( int i = 0; I * <= m; i++) {for (int j = 0; J *, <= M; j + +) {for (int k = 0; K * <= m; k++) {if (I * + j * *) + K * <= M&A Mp;&m-(I * + J * + + K *) < min)  min = M-(i * + j * + K * 350);}} printf ("%d\n", Min);} return 0;}


HDU 1407 1248 Violent enumeration

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.