UVa 1583 Dozen Watches

Source: Internet
Author: User

Background: 1--tle: timeout, without taking into account the complexity of the time, began to each number from 1 to 99999, so that is O (t*key) so that 20 groups of large number can be timed out. 2--wa:3--wa are the numbers mistakenly think up to 4 bits, in fact, five bit!!!

Idea: Find out that I (from 1 to 100000) produces a number of n,i is the generation of N, because up to 5 digits are added, so n-i<50. For each number of T to find the generator, if T is greater than 50, just search (t-50,t).

Study: 1. For all cases up to 100,000 levels can be played on the table.

#include <stdio.h>int str[99999];int main (void) {  str[0]=0;  for (int i=1;i<99999;i++) {  int temp=i;  str[i]=i;  for (int j=0;j<5;j++) {  str[i]+=temp%10;  temp/=10;  }  }  int t;  scanf ("%d", &t);  while (t--) {  int key,judege=0;  scanf ("%d", &key);  for (int i=1;i<99999;i++) {  if (i==1) {  if (key>50) i=key-50;  }   if (str[i]==key) {  judege=1;  printf ("%d\n", I);  break;  }  }  if (!judege) printf ("0\n");  } return 0; }


UVa 1583 Dozen Watches

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.